/** * @param ReflectionClass $reflection */ protected function _createFromReflection($reflection) { $this->_className = $reflection->getName(); $this->_endLine = $reflection->getEndLine(); $this->_filePath = $reflection->getFileName(); foreach ($reflection->getMethods() as $method) { //Method::create($this, $method); $this->addMethod(Method::create($this, $method)); } }
/** * Dispatch a method, whether a filter or function * @param Callable|string $method The method to call * @param array $args An array of arguments to be passed to the method * @return bool|mixed The return value from the dispatched method */ public static function dispatch_array($method, $args = array()) { if (is_callable($method)) { return call_user_func_array($method, $args); } elseif (is_string($method)) { array_unshift($args, $method, false); return call_user_func_array(Method::create('\\Habari\\Plugins', 'filter'), $args); } return false; }
/** * Add pre-defined rules to an array of rules only if rules with their names don't already exist * * @param array $rules An array of RewriteRule objects * @return array An array of rules with the system rules potentially added */ public static function add_system_rules($rules) { $default_rules = array(array('name' => 'display_home', 'parse_regex' => '#^(?:page/(?P<page>0|1))?/?$#', 'build_str' => '(page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_home', 'priority' => 1000, 'description' => 'Homepage (index) display'), array('name' => 'display_entries', 'parse_regex' => '#^(?:page/(?P<page>[2-9]|[1-9][0-9]+))/?$#', 'build_str' => '(page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_entries', 'priority' => 999, 'description' => 'Display multiple entries'), array('name' => 'display_entries_by_date', 'parse_regex' => '#^(?P<year>[1,2]{1}[\\d]{3})(?:/(?P<month>[\\d]{2}))?(?:/(?P<day>[\\d]{2}))?(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$year}(/{$month})(/{$day})(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_date', 'priority' => 2, 'description' => 'Displays posts for a specific date.'), array('name' => 'display_entries_by_tag', 'parse_regex' => '#^tag/(?P<tag>[^/]*)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'tag/{$tag}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_tag', 'priority' => 5, 'description' => 'Return posts matching specified tag.', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Tag', 'rewrite_tag_exists')))), array('name' => 'display_entry', 'parse_regex' => '#^(?P<slug>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 100, 'description' => 'Return entry matching specified slug', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Posts', 'rewrite_match_type'), 'content_type' => 'entry', 'request_types' => array('display_post')))), array('name' => 'display_page', 'parse_regex' => '#^(?P<slug>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 100, 'description' => 'Return page matching specified slug', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Posts', 'rewrite_match_type'), 'content_type' => 'page', 'request_types' => array('display_post')))), array('name' => 'display_search', 'parse_regex' => '#^search(?:/(?P<criteria>[^/]+))?(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'search(/{$criteria})(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'search', 'priority' => 8, 'description' => 'Searches posts'), array('name' => 'display_404', 'parse_regex' => '/^.*$/', 'build_str' => '', 'handler' => 'UserThemeHandler', 'action' => 'display_404', 'priority' => 9999, 'description' => 'Displays an error page when a URL is not matched.'), array('name' => 'display_post', 'parse_regex' => '#^(?P<slug>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}(/page/{$page})', 'handler' => 'UserThemeHandler', 'action' => 'display_post', 'priority' => 9998, 'description' => 'Fallback to return post matching specified slug if no content_type match'), array('name' => 'submit_feedback', 'parse_regex' => '#^(?P<id>[0-9]+)/feedback/?$#i', 'build_str' => '{$id}/feedback', 'handler' => 'FeedbackHandler', 'action' => 'add_comment', 'priority' => 8, 'description' => 'Adds a comment to a post'), array('name' => 'display_dashboard', 'parse_regex' => '#^admin/?$#', 'build_str' => 'admin', 'handler' => 'AdminDashboardHandler', 'action' => 'dashboard', 'priority' => 4, 'description' => 'Display the admin dashboard'), array('name' => 'display_publish', 'parse_regex' => '#^admin/publish/(?P<content_type_name>[^/]+)(?:/(?P<id>.+))?/?$#', 'build_str' => 'admin/publish/{$content_type_name}(/{$id})', 'handler' => 'AdminPostsHandler', 'action' => 'publish', 'priority' => 4, 'description' => 'Manage publishing posts'), array('name' => 'display_posts', 'parse_regex' => '#^admin/posts/?$#', 'build_str' => 'admin/posts', 'handler' => 'AdminPostsHandler', 'action' => 'posts', 'priority' => 4, 'description' => 'Manage posts'), array('name' => 'delete_post', 'parse_regex' => '#^admin/delete_post/?$#', 'build_str' => 'admin/delete_post', 'handler' => 'AdminPostsHandler', 'action' => 'delete_post', 'priority' => 4, 'description' => 'Delete a post'), array('name' => 'user_profile', 'parse_regex' => '#^admin/user/(?P<user>[^/]+)/?$#', 'build_str' => 'admin/user/{$user}', 'handler' => 'AdminUsersHandler', 'action' => 'user', 'priority' => 4, 'description' => 'The profile page for a specific user'), array('name' => 'display_users', 'parse_regex' => '#^admin/users/?$#', 'build_str' => 'admin/users', 'handler' => 'AdminUsersHandler', 'action' => 'users', 'priority' => 4, 'description' => 'Manage users'), array('name' => 'own_user_profile', 'parse_regex' => '#^admin/user/?$#', 'build_str' => 'admin/user', 'handler' => 'AdminUsersHandler', 'action' => 'user', 'priority' => 4, 'description' => 'The profile page for a specific user'), array('name' => 'display_themes', 'parse_regex' => '#^admin/themes/?$#', 'build_str' => 'admin/themes', 'handler' => 'AdminThemesHandler', 'action' => 'themes', 'priority' => 4, 'description' => 'Manage themes'), array('name' => 'activate_theme', 'parse_regex' => '#^admin/activate_theme/?$#', 'build_str' => 'admin/activate_theme', 'handler' => 'AdminThemesHandler', 'action' => 'activate_theme', 'priority' => 4, 'description' => 'Activate a theme'), array('name' => 'preview_theme', 'parse_regex' => '#^admin/preview_theme/?$#', 'build_str' => 'admin/preview_theme', 'handler' => 'AdminThemesHandler', 'action' => 'preview_theme', 'priority' => 4, 'description' => 'Preview a theme'), array('name' => 'configure_block', 'parse_regex' => '#^admin/configure_block/?$#i', 'build_str' => 'admin/configure_block', 'handler' => 'AdminThemesHandler', 'action' => 'configure_block', 'priority' => 4, 'description' => 'Configure a block in an iframe'), array('name' => 'display_plugins', 'parse_regex' => '#^admin/plugins(?:/(?P<configure>[0-9a-f]{8})/(?P<action>.+))?/?$#', 'build_str' => 'admin/plugins(/{$configure}/{$action})', 'handler' => 'AdminPluginsHandler', 'action' => 'plugins', 'priority' => 4, 'description' => 'Manage plugins'), array('name' => 'plugin_toggle', 'parse_regex' => '#^admin/plugin_toggle/?$#', 'build_str' => 'admin/plugin_toggle', 'handler' => 'AdminPluginsHandler', 'action' => 'plugin_toggle', 'priority' => 4, 'description' => 'Activate or deactivate a plugin'), array('name' => 'display_options', 'parse_regex' => '#^admin/options/?$#', 'build_str' => 'admin/options', 'handler' => 'AdminOptionsHandler', 'action' => 'options', 'priority' => 4, 'description' => 'The options page for the blog'), array('name' => 'display_comments', 'parse_regex' => '#^admin/comments/?$#', 'build_str' => 'admin/comments', 'handler' => 'AdminCommentsHandler', 'action' => 'comments', 'priority' => 4, 'description' => 'Manage comments'), array('name' => 'edit_comment', 'parse_regex' => '#^admin/comment/(?P<id>[0-9]+)/?$#i', 'build_str' => 'admin/comment/{$id}', 'handler' => 'AdminCommentsHandler', 'action' => 'comment', 'priority' => 4, 'description' => 'Edit a comment'), array('name' => 'display_groups', 'parse_regex' => '#^admin/groups/?$#', 'build_str' => 'admin/groups', 'handler' => 'AdminGroupsHandler', 'action' => 'groups', 'priority' => 4, 'description' => 'Manage groups'), array('name' => 'display_group', 'parse_regex' => '#^admin/group/(?P<id>[0-9]+)/?$#i', 'build_str' => 'admin/group/{$id}', 'handler' => 'AdminGroupsHandler', 'action' => 'group', 'priority' => 4, 'description' => 'Manage a group'), array('name' => 'display_tags', 'parse_regex' => '#^admin/tags/?$#i', 'build_str' => 'admin/tags', 'handler' => 'AdminTagsHandler', 'action' => 'tags', 'priority' => 4, 'description' => 'Manage tags'), array('name' => 'display_logs', 'parse_regex' => '#^admin/logs/?$#i', 'build_str' => 'admin/logs', 'handler' => 'AdminLogsHandler', 'action' => 'logs', 'priority' => 4, 'description' => 'Manage logs'), array('name' => 'display_import', 'parse_regex' => '#^admin/import/?$#i', 'build_str' => 'admin/import', 'handler' => 'AdminImportHandler', 'action' => 'import', 'priority' => 4, 'description' => 'Manage importing content'), array('name' => 'get_locale', 'parse_regex' => '#^admin/locale/?$#i', 'build_str' => 'admin/locale', 'handler' => 'AdminLocaleHandler', 'action' => 'locale', 'priority' => 4, 'description' => 'Fetch the locale data as javascript'), array('name' => 'display_sysinfo', 'parse_regex' => '#^admin/sysinfo/?$#i', 'build_str' => 'admin/sysinfo', 'handler' => 'AdminHandler', 'action' => 'sysinfo', 'priority' => 4, 'description' => 'Display system info'), array('name' => 'admin', 'parse_regex' => '#^admin(?:/?$|/(?P<page>[^/]*))/?$#i', 'build_str' => 'admin/({$page})', 'handler' => 'AdminHandler', 'action' => 'admin', 'priority' => 6, 'description' => 'An admin action'), array('name' => 'admin_ajax_dashboard', 'parse_regex' => '#^admin_ajax/(?P<context>dashboard)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminDashboardHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for the admin dashboard'), array('name' => 'admin_ajax_posts', 'parse_regex' => '#^admin_ajax/(?P<context>posts)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for the managing posts'), array('name' => 'admin_ajax_update_posts', 'parse_regex' => '#^admin_ajax/(?P<context>update_posts)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for the updating posts'), array('name' => 'admin_ajax_facets', 'parse_regex' => '#^admin_ajax/(?P<context>facets)/(?P<page>manage|tags)/(?P<component>facets|values)/?$#i', 'build_str' => 'admin_ajax/{$context}/{$page}/{$component}', 'handler' => 'AdminHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for retrieving post search facets'), array('name' => 'admin_ajax_media', 'parse_regex' => '#^admin_ajax/(?P<context>media)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling from media silos'), array('name' => 'admin_ajax_media_panel', 'parse_regex' => '#^admin_ajax/(?P<context>media_panel)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling from media panels'), array('name' => 'admin_ajax_media_upload', 'parse_regex' => '#^admin_ajax/(?P<context>media_upload)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminPostsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling from media panel uploads'), array('name' => 'admin_ajax_add_block', 'parse_regex' => '#^admin_ajax/(?P<context>add_block)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminThemesHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for adding a block', 'parameters' => serialize(array('require_permission' => array('manage_theme_config' => true)))), array('name' => 'admin_ajax_delete_block', 'parse_regex' => '#^admin_ajax/(?P<context>delete_block)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminThemesHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for deleting a block'), array('name' => 'admin_ajax_save_areas', 'parse_regex' => '#^admin_ajax/(?P<context>save_areas)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminThemesHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for saving areas'), array('name' => 'admin_ajax_comments', 'parse_regex' => '#^admin_ajax/(?P<context>comments)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminCommentsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for managing comments'), array('name' => 'admin_ajax_update_comment', 'parse_regex' => '#^admin_ajax/(?P<context>update_comment)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminCommentsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for updating a comment'), array('name' => 'admin_ajax_groups', 'parse_regex' => '#^admin_ajax/(?P<context>groups)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminGroupsHandler', 'action' => 'admin_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling for managing groups'), array('name' => 'admin_ajax_update_groups', 'parse_regex' => '#^admin_ajax/(?P<context>update_groups)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminGroupsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for updating a group'), array('name' => 'admin_ajax_tags', 'parse_regex' => '#^admin_ajax/(?P<context>tags)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminTagsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for managing tags'), array('name' => 'admin_ajax_get_tags', 'parse_regex' => '#^admin_ajax/(?P<context>get_tags)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminTagsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for retrieving tags'), array('name' => 'admin_ajax_logs', 'parse_regex' => '#^admin_ajax/(?P<context>logs)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminLogsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for managing logs'), array('name' => 'admin_ajax_delete_logs', 'parse_regex' => '#^admin_ajax/(?P<context>delete_logs)/?$#', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminLogsHandler', 'action' => 'admin_ajax', 'priority' => 4, 'description' => 'Authenticated ajax handler for deleting logs'), array('name' => 'admin_ajax', 'parse_regex' => '#^admin_ajax/(?P<context>[^/]+)/?$#i', 'build_str' => 'admin_ajax/{$context}', 'handler' => 'AdminHandler', 'action' => 'admin_ajax', 'priority' => 10, 'description' => 'Authenticated ajax handling for the admin'), array('name' => 'auth', 'parse_regex' => '#^auth/(?P<page>[^/]*)$#i', 'build_str' => 'auth/{$page}', 'handler' => 'UserHandler', 'action' => '{$page}', 'priority' => 7, 'description' => 'A user action or display, for instance the login screen'), array('name' => 'ajax', 'parse_regex' => '#^ajax/(?P<context>[^/]+)/?$#i', 'build_str' => 'ajax/{$context}', 'handler' => 'AjaxHandler', 'action' => 'ajax', 'priority' => 8, 'description' => 'Ajax handling'), array('name' => 'auth_ajax', 'parse_regex' => '#^auth_ajax/(?P<context>[^/]+)/?$#i', 'build_str' => 'auth_ajax/{$context}', 'handler' => 'AjaxHandler', 'action' => 'auth_ajax', 'priority' => 8, 'description' => 'Authenticated ajax handling'), array('name' => 'rsd', 'parse_regex' => '/^rsd$/i', 'build_str' => 'rsd', 'handler' => 'AtomHandler', 'action' => 'rsd', 'priority' => 1, 'description' => 'RSD output'), array('name' => 'atom_entry', 'parse_regex' => '#^(?P<slug>[^/]+)/atom/?$#i', 'build_str' => '{$slug}/atom', 'handler' => 'AtomHandler', 'action' => 'entry', 'priority' => 8, 'description' => 'Atom Publishing Protocol'), array('name' => 'atom_feed', 'parse_regex' => '#^atom/(?P<index>[^/]+)(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'atom/{$index}(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'collection', 'priority' => 8, 'description' => 'Atom collection'), array('name' => 'atom_feed_comments', 'parse_regex' => '#^atom/comments(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'atom/comments(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'comments', 'priority' => 7, 'description' => 'Entries comments'), array('name' => 'atom_feed_tag', 'parse_regex' => '#^tag/(?P<tag>[^/]+)/atom(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => 'tag/{$tag}/atom(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'tag_collection', 'priority' => 8, 'description' => 'Atom Tag Collection', 'parameters' => serialize(array('require_match' => Method::create('\\Habari\\Tag', 'rewrite_tag_exists')))), array('name' => 'atom_feed_entry_comments', 'parse_regex' => '#^(?P<slug>[^/]+)/atom/comments(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}/atom/comments(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'entry_comments', 'priority' => 8, 'description' => 'Entry comments'), array('name' => 'atom_feed_page_comments', 'parse_regex' => '#^(?P<slug>[^/]+)/atom/comments(?:/page/(?P<page>\\d+))?/?$#i', 'build_str' => '{$slug}/atom/comments(/page/{$page})', 'handler' => 'AtomHandler', 'action' => 'entry_comments', 'priority' => 8, 'description' => 'Page comments'), array('name' => 'atompub_servicedocument', 'parse_regex' => '/^atom$/i', 'build_str' => 'atom', 'handler' => 'AtomHandler', 'action' => 'introspection', 'priority' => 1, 'description' => 'Atom introspection'), array('name' => 'cron', 'parse_regex' => '#^cron/(?P<time>[0-9.]+)/?$#i', 'build_str' => 'cron/{$time}', 'handler' => 'CronHandler', 'action' => 'poll_cron', 'priority' => 1, 'description' => 'Asyncronous cron processing'), array('name' => 'xmlrpc', 'parse_regex' => '#^xmlrpc/?$#i', 'build_str' => 'xmlrpc', 'handler' => 'XMLRPCServer', 'action' => 'xmlrpc_call', 'priority' => 8, 'description' => 'Handle incoming XMLRPC requests.')); $default_rules = Plugins::filter('default_rewrite_rules', $default_rules); $default_rules_properties = array('is_active' => 1, 'rule_class' => RewriteRule::RULE_SYSTEM); $rule_names = array_flip(Utils::array_map_field($rules, 'name')); foreach ($default_rules as $default_rule) { if (!isset($rule_names[$default_rule['name']])) { $rule_properties = array_merge($default_rule, $default_rules_properties); $rules[] = new RewriteRule($rule_properties); } } return $rules; }
/** * Initialize the session handlers */ public static function init() { // the default path for the session cookie is /, but let's make that potentially more restrictive so no one steals our cookehs // we also can't use 'null' when we set a secure-only value, because that doesn't mean the same as the default like it should $path = Site::get_path('base', true); // the default is not to require a secure session $secure = false; // if we want to always require secure if (Config::get('force_secure_session') == true) { $secure = true; } // if this is an HTTPS connection by default we will // IIS sets HTTPS == 'off', so we have to check the value too if (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') { $secure = true; } // but if we have explicitly disabled it, don't // note the ===. not setting it (ie: null) should not be the same as setting it to false if (Config::get('force_secure_session') === false) { $secure = false; } // now we've got a path and secure, so set the cookie values session_set_cookie_params(null, $path, null, $secure); // figure out the session lifetime and let plugins change it $lifetime = ini_get('session.gc_maxlifetime'); self::$lifetime = Plugins::filter('session_lifetime', $lifetime); //$_SESSION = new SessionStorage(); if (isset($_COOKIE[self::HABARI_SESSION_COOKIE_NAME])) { self::$session_id = $_COOKIE[self::HABARI_SESSION_COOKIE_NAME]; self::read(); self::$stored_session_hash = self::session_data_hash(); } // make sure we check whether or not we should write the session after the page is rendered register_shutdown_function(Method::create('\\Habari\\Session', 'shutdown')); // process the write queue register_shutdown_function(Method::create('\\Habari\\Session', 'process_queue')); return true; }
/** * Handle methods called on this class or its descendants that are not defined by this class. * Allow plugins to provide additional theme actions, like a custom act_display_*() * * @param string $function The method that was called. * @param array $params An array of parameters passed to the method **/ public function __call($function, $params) { if (strpos($function, 'act_') === 0) { // The first parameter is an array, get it if (count($params) > 0) { list($user_filters) = $params; } else { $user_filters = array(); } $action = substr($function, 4); Plugins::act('theme_action', $action, $this, $user_filters); } else { $purposed = 'output'; if (preg_match('/^(.*)_(return|end|out)$/', $function, $matches)) { $purposed = $matches[2]; $function = $matches[1]; } array_unshift($params, $function, $this); $result = call_user_func_array(Method::create('\\Habari\\Plugins', 'theme'), $params); switch ($purposed) { case 'return': return $result; case 'end': return end($result); case 'out': $output = implode('', (array) $result); echo $output; return $output; default: $output = implode('', (array) $result); return $output; } } }
', ajaxConfigModule: '<?php echo URL::get('admin_ajax', array('context' => 'dashboard')); ?> ' } }; // An almost "catch all" for those old browsers that don't support the X-Frame-Options header. We don't bust out, we just don't show any content if ( top != self ) { self.location.replace( 'about:blank' ); } </script> <?php Plugins::act('admin_header', $this); Stack::out('admin_header_javascript', Method::create('\\Habari\\Stack', 'scripts')); Stack::out('admin_stylesheet', Method::create('\\Habari\\Stack', 'styles')); ?> <!--[if IE 7]> <link rel="stylesheet" type="text/css" href="<?php Site::out_url('admin_theme'); ?> /css/ie.css" media="screen"> <![endif]--> <?php Plugins::act('admin_header_after', $this); ?> </head> <body class="page-<?php echo $page;
/** * Handle calls to this Tag object that are implemented by plugins * @param string $name The name of the function called * @param array $args Arguments passed to the function call * @return mixed The value returned from any plugin filters, null if no value is returned */ public function __call($name, $args) { array_unshift($args, 'tag_call_' . $name, null, $this); return call_user_func_array(Method::create('\\Habari\\Plugins', 'filter'), $args); }
public function upgrade_db_post_5111() { // add the cronjob to perform garbage collection on sessions CronTab::add_hourly_cron('session_gc', Method::create('\\Habari\\Session', 'gc'), _t('Perform session garbage collection.')); }
?> </a></span> <?php } ?> </p> </div> <?php Plugins::act('admin_footer', $this); Stack::out('admin_footer_javascript', Method::create('\\Habari\\Stack', 'scripts')); include 'db_profiling.php'; ?> <?php if (Session::has_messages()) { ?> <script type="text/javascript"> jQuery(document).ready(function() { <?php Session::messages_out(true, Method::create('\\Habari\\Format', 'humane_messages')); ?> }) </script> <?php } ?> </body> </html> <?php
$installer = new InstallHandler(); $installer->upgrade_db(); } // If we're doing unit testing, stop here if (defined('UNIT_TEST')) { return; } // if this is an asyncronous call, ignore abort. if (isset($_GET['asyncronous']) && Utils::crypt(Options::get('GUID'), $_GET['asyncronous'])) { ignore_user_abort(true); } // Send the Content-Type HTTP header. // @todo Find a better place to put this. header('Content-Type: text/html;charset=utf-8'); // Load and upgrade all the active plugins. spl_autoload_register(Method::create('\\Habari\\Plugins', '_autoload')); Plugins::load_active(); // All plugins loaded, tell the plugins. Plugins::act('plugins_loaded'); // Start the session. Session::init(); // Set the locale from the user info else config, database, then default english locale if (User::identify()->loggedin && User::identify()->info->locale_lang) { Locale::set(User::identify()->info->locale_lang); } else { Locale::set(Config::get('locale', Options::get('locale', 'en-us'))); } if (Options::get('system_locale')) { Locale::set_system_locale(Options::get('system_locale')); } // Replace the $_COOKIE superglobal with an object representation
/** * Does a bitwise OR of all the numbers in an array * @param array $input An array of integers * @return int The bitwise OR of the input array */ public static function array_or($input) { return array_reduce($input, Method::create('\\Habari\\Utils', 'ror'), 0); }
<![endif]--> <?php Plugins::act('admin_header_after', $this); ?> </head> <body class="page-<?php echo $page; ?> modal"> <div id="spinner"></div> <div id="page"> <?php echo $content; ?> <?php Plugins::act('admin_footer', $this); Stack::out('admin_footer_javascript', Method::create('\\Habari\\Stack', 'scripts')); ?> </div> </body> </html> <?php
public static function get_plugin_classes() { $classes = get_declared_classes(); return array_filter($classes, Method::create('\\Habari\\Plugins', 'extends_plugin')); }
/** * Remove permissions to one or more tokens from a user * @param mixed a token ID, name, or array of the same **/ public function revoke($tokens) { $tokens = Utils::single_array($tokens); // get token IDs $tokens = array_map(Method::create('\\Habari\\ACL', 'token_id'), $tokens); foreach ($tokens as $token) { ACL::revoke_user_token($this->id, $token); EventLog::log(_t('User %1$s: Permission to %2$s revoked.', array($this->username, ACL::token_name($token))), 'notice', 'user', 'habari'); } }
/** * Applies a new set of specific tokens to a post * @param mixed $tokens A string token, or an array of tokens to apply to this post */ public function set_tokens($tokens) { $tokens = Utils::single_array($tokens); $new_tokens = array_map(Method::create('\\Habari\\ACL', 'token_id'), $tokens); $new_tokens = array_unique($new_tokens); DB::delete('{post_tokens}', array('post_id' => $this->id)); foreach ($new_tokens as $token_id) { DB::insert('{post_tokens}', array('post_id' => $this->id, 'token_id' => $token_id)); } $this->tokens = $new_tokens; }
/** * Compare the current set of plugins with those we last checked for updates. * This is run by AdminHandler on every page load to make sure we always have fresh data on the dashboard. */ public static function check_plugins() { // register the beacons self::register_beacons(); // get the list we checked last time $checked_list = Options::get('updates_beacons'); // if the lists are different if ($checked_list != self::instance()->beacons) { // remove any stored updates, just to avoid showing stale data Options::delete('updates_available'); // schedule an update check the next time cron runs CronTab::add_single_cron('update_check_single', Method::create('\\Habari\\Update', 'cron'), DateTime::create()->int, _t('Perform a single check for plugin updates, the plugin set has changed.')); } }
/** * function update_scheduled_posts_cronjob * * Creates or recreates the cronjob to publish * scheduled posts. It is called whenever a post * is updated or created * */ public static function update_scheduled_posts_cronjob() { $min_time = DB::get_value('SELECT MIN(pubdate) FROM {posts} WHERE status = ?', array(Post::status('scheduled'))); CronTab::delete_cronjob('publish_scheduled_posts'); if ($min_time) { CronTab::add_single_cron('publish_scheduled_posts', Method::create('\\Habari\\Posts', 'publish_scheduled_posts'), $min_time, 'Next run: ' . DateTime::create($min_time)->get('c')); } }
/** * Echo a version of the string translated into the current locale * @param string $text The text to echo translated * @param string $domain (optional) The domain to search for the message */ public static function _e() { $args = func_get_args(); echo call_user_func_array(Method::create('\\Habari\\Locale', '_t'), $args); }
/** * Runs any attached validation functions to check validation of this control. * * @return array An array of string validation error descriptions or an empty array if no errors were found. */ public function validate() { $valid = array(); foreach ($this->validators as $validator) { $validator_fn = array_shift($validator); if (is_callable($validator_fn)) { // Passed to validator function: $value, $control, $form, $validator_params... $params = array_merge(array($this->value, $this, $this->get_form()), $validator); $valid = array_merge($valid, call_user_func_array($validator_fn, $params)); } elseif (FormValidators::have($validator_fn)) { $validator_fn = Method::create('\\Habari\\FormValidators', $validator_fn); $params = array_merge(array($this->value, $this, $this->get_form()), $validator); $valid = array_merge($valid, call_user_func_array($validator_fn, $params)); } else { $params = array_merge(array($validator_fn, $valid, $this->value, $this, $this->get_form()), $validator); $valid = array_merge($valid, call_user_func_array(Method::create('\\Habari\\Plugins', 'filter'), $params)); } } // If there are errors, propagate them to the container control if the container is a label, by default if ($this->container instanceof FormControl) { $apply_errors_to = $this->get_setting('propagate_errors_to', $this->container instanceof FormControlLabel ? $this->container : $this); $apply_errors_to->errors = array_merge($apply_errors_to->errors, $valid); } else { $this->errors = array_merge($this->errors, $valid); } if (count($valid) > 0) { $this->has_errors = true; } return $valid; }
/** * function handle_errors * * Configures the Error class to handle all errors. */ public static function handle_errors() { set_error_handler(Method::create('\\Habari\\Error', 'error_handler')); set_exception_handler(Method::create('\\Habari\\Error', 'exception_handler')); register_shutdown_function(Method::create('\\Habari\\Error', 'shutdown_handler')); }