viewpath . "views/{$viewtype}/{$view}.php")) { $success = false; if ($viewtype != "default") { if (@include($CONFIG->viewpath . "views/default/{$view}.php")) { $success = true; } } if (!$success && $debug == true) { echo " [This view ({$view}) does not exist] "; } } $content = ob_get_clean(); return $content; } /** * Library loading and handling */ /** * Recursive function designed to load library files on start * (NB: this does not include plugins.) * * @param string $directory Full path to the directory to start with * @param string $file_exceptions A list of filenames (with no paths) you don't ever want to include * @param string $file_list A list of files that you know already you want to include * @return array Array of full filenames */ function get_library_files($directory, $file_exceptions = array(), $file_list = array()) { if (is_file($directory)) { $file_list[] = $directory; } else if ($handle = opendir($directory)) { while ($file = readdir($handle)) { if (!in_array($file,$file_exceptions)) { $file_list = get_library_files($directory . "/" . $file, $file_exceptions, $file_list); } } } return $file_list; } /** * Ensures that the installation has all the correct files, that PHP is configured correctly, and so on. * Leaves appropriate messages in the error register if not. * * @return true|false True if everything is ok (or Elgg is fit enough to run); false if not. */ function sanitised() { $sanitised = true; if (!file_exists(dirname(dirname(__FILE__)) . "/settings.php")) { register_error(elgg_view("messages/sanitisation/settings")); $sanitised = false; } return $sanitised; } /** * Registers */ /** * Message register handling * If no parameter is given, the function returns the array of messages so far and empties it. * Otherwise, any message or array of messages is added. * * @param string|array $message Optionally, a single message or array of messages to add * @param string $register By default, "errors". This allows for different types of messages, eg errors. * @return true|false|array Either the array of messages, or a response regarding whether the message addition was successful */ function system_messages($message = null, $register = "messages", $count = false) { static $messages; if (!isset($messages)) { $messages = array(); } if (!isset($messages[$register]) && !empty($register)) { $messages[$register] = array(); } if (!$count) { if (!empty($message) && is_array($message)) { $messages[$register] = array_merge($messages[$register], $message); return true; } else if (!empty($message) && is_string($message)) { $messages[$register][] = $message; return true; } else if (!is_string($message) && !is_array($message)) { if (!empty($register)) { $returnarray = $messages[$register]; $messages[$register] = array(); } else { $returnarray = $messages; $messages = array(); } return $returnarray; } } else { if (!empty($register)) { return sizeof($messages[$register]); } else { $count = 0; foreach($messages as $register => $submessages) { $count += sizeof($submessages); } return $count; } } return false; } /** * An alias for system_messages($message) to handle standard user information messages * * @param string|array $message Message or messages to add * @return true|false Success response */ function system_message($message) { return system_messages($message, "messages"); } /** * An alias for system_messages($message) to handle error messages * * @param string|array $message Error or errors to add * @return true|false Success response */ function register_error($error) { return system_messages($error, "errors"); } /** * Counts the number of messages, either globally or in a particular register * * @param string $register Optionally, the register * @return integer The number of messages */ function count_messages($register = "") { return system_messages(null,$register,true); } ?>