function displayPluginContent() { $curPlugin = new Plugins($_GET['pluginID']); if (file_exists($curPlugin->get_filename())) { include_once $curPlugin->get_filename(); $className = $curPlugin->get_class_name(); $pluginClass = new $className(); return $pluginClass->get_content(); } else { return "The file does not exist."; } /*$phpFile = $curPlugin->get_filename(); $fh = fopen($phpFile, 'r'); $data = fread($fh, filesize($phpFile)); fclose($fh); if (!preg_match("/echo/i", $data) && !preg_match("/print/i", $data) ) { if (class_exists($className)) { $pluginClass = new $className(); } else {return "Your class, \"".$className."\", taken from the database does not exist in your php file.";} if(method_exists($pluginClass, 'get_content')) { if($pluginClass->get_content() !='') { return $pluginClass->get_content(); } } else{return "No Content to retrieve";} } else {return "You cannot echo or print your content out, you must return a value";}*/ }
/** * action: plugin_activation * * @access public * @param string $file * @return void */ public function action_plugin_activation($file) { if (Plugins::id_from_file($file) != Plugins::id_from_file(__FILE__)) { return; } Post::add_new_type('revision'); }
/** * Respond to the URL that was created * Determine the post that was supposed to be displayed, and show it in raw * @params array $handlervars An array of values passed in from the URL requested */ function action_plugin_act_plaintext($handlervars) { $activetheme = Themes::create(); $user_filters = array('fetch_fn' => 'get_row', 'limit' => 1); $page_key = array_search('page', $activetheme->valid_filters); unset($activetheme->valid_filters[$page_key]); $user_filters = Plugins::filter('template_user_filters', $user_filters); $user_filters = array_intersect_key($user_filters, array_flip($activetheme->valid_filters)); $where_filters = Controller::get_handler()->handler_vars->filter_keys($activetheme->valid_filters); $where_filters = $where_filters->merge($user_filters); $where_filters = Plugins::filter('template_where_filters', $where_filters); $post = Posts::get($where_filters); $current_url = URL::get(); $created_at = $post->pubdate->get(); header('Content-type: text/plain; charset=utf-8'); echo <<<HERE # {$post->title} By {$post->author->displayname} <{$current_url}> {$created_at} \t {$post->content} HERE; exit; }
private function InitializePermissionsManager() { $RequiredPermissions = [1, 2, 3, 8]; foreach ($RequiredPermissions as $Permission) { parent::addPermission($Permission); } }
/** * Ouputs the default menu in the template footer, and runs the 'habmin_bar' plugin filter. * You can add menu items via the filter. See the 'filter_habminbar' method for * an example. */ public function action_template_footer() { if ( User::identify()->loggedin ) { $bar = '<div id="habminbar"><div>'; $bar.= '<div id="habminbar-name"><a href="' . Options::get('base_url') . '">' . Options::get('title') . '</a></div>'; $bar.= '<ul>'; $menu = array(); $menu['dashboard']= array( 'Dashboard', URL::get( 'admin', 'page=dashboard' ), "view the admin dashboard" ); $menu['write']= array( 'Write', URL::get( 'admin', 'page=publish' ), "create a new entry" ); $menu['option']= array( 'Options', URL::get( 'admin', 'page=options' ), "configure site options" ); $menu['comment']= array( 'Moderate', URL::get( 'admin', 'page=comments' ),"moderate comments" ); $menu['user']= array( 'Users', URL::get( 'admin', 'page=users' ), "administer users" ); $menu['plugin']= array( 'Plugins', URL::get( 'admin', 'page=plugins' ), "activate and configure plugins" ); $menu['theme']= array( 'Themes', URL::get( 'admin', 'page=themes' ), "select a theme" ); $menu = Plugins::filter( 'habminbar', $menu ); $menu['logout']= array( 'Logout', URL::get( 'user', 'page=logout' ), "logout" ); foreach ( $menu as $name => $item ) { list( $label, $url, $tooltip )= array_pad( $item, 3, "" ); $bar.= "\n\t<li><a href=\"$url\" class=\"$name\"" . ( ( $tooltip ) ? " title=\"$tooltip\"" : "" ) .">$label</a></li>"; } $bar.= '</ul><br style="clear:both;" /></div></div>'; echo $bar; } }
/** * Makes this plugin the first to be loaded. * - Bumps this plugin at the top of the active_plugins stack. */ function mdh_emailmagick_bump_me() { if (OC_ADMIN) { // @legacy : ALWAYS remove this if active. if (osc_plugin_is_enabled("madhouse_utils/index.php")) { Plugins::deactivate("madhouse_utils/index.php"); } // Sanitize & get the {PLUGIN_NAME}/index.php. $path = str_replace(osc_plugins_path(), '', osc_plugin_path(__FILE__)); if (osc_plugin_is_installed($path)) { // Get the active plugins. $plugins_list = unserialize(osc_active_plugins()); if (!is_array($plugins_list)) { return false; } // Remove $path from the active plugins list foreach ($plugins_list as $k => $v) { if ($v == $path) { unset($plugins_list[$k]); } } // Re-add the $path at the beginning of the active plugins. array_unshift($plugins_list, $path); // Serialize the new active_plugins list. osc_set_preference('active_plugins', serialize($plugins_list)); if (Params::getParam("page") === "plugins" && Params::getParam("action") === "enable" && Params::getParam("plugin") === $path) { //osc_redirect_to(osc_admin_base_url(true) . "?page=plugins"); } else { osc_redirect_to(osc_admin_base_url(true) . "?" . http_build_query(Params::getParamsAsArray("get"))); } } } }
public function __get($name) { // if there is a _ in the name, there is a filter at the end if (strpos($name, '_') !== false) { // pick off the last _'d piece preg_match('/^(.*)_([^_]+)$/', $name, $matches); list($junk, $name, $filter) = $matches; // so that we don't break every info value that has a _ in it, only _out is an acceptable filter name if ($filter != 'out') { // put it back together $name = $name . '_' . $filter; // turn off the filter $filter = false; } } else { $filter = false; } // get the value by calling our parent function directly $value = parent::__get($name); // apply the main filter so values can be altered regardless of any _filter $value = Plugins::filter("post_info_{$name}", $value); // if there is a filter, apply that specific one too if ($filter) { $value = Plugins::filter("post_info_{$name}_{$filter}", $value); } return $value; }
public function __get($name) { switch ($name) { case 'resource': return Plugins::filter('get_stackitem_resource', $this->resource, $this); } }
/** * Получение схемы БД из SQL файлов модулей и активированных плагинов * * @return string */ public static function install_schema() { $schema = ''; // Create a new directory iterator $path = new DirectoryIterator(CMS_MODPATH); foreach ($path as $dir) { if ($dir->isDot()) { continue; } $file_name = CMS_MODPATH . $dir->getBasename() . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'schema.sql'; if (file_exists($file_name)) { $schema .= file_get_contents($file_name); $schema .= "\n\n"; } } if (class_exists('Plugins')) { foreach (Plugins::activated() as $id) { $file_name = PLUGPATH . $id . DIRECTORY_SEPARATOR . 'install' . DIRECTORY_SEPARATOR . 'schema.sql'; if (file_exists($file_name)) { $schema .= file_get_contents($file_name); $schema .= "\n\n"; } } } return str_replace('__TABLE_PREFIX__', TABLE_PREFIX, $schema); }
public function test_delete() { $group = UserGroup::get( "new test group" ); Plugins::register( array( $this, 'filter_usergroup_delete_allow' ), 'filter','usergroup_delete_allow' ); $this->assert_true( $group instanceof UserGroup, 'Could not retrieve group named "new test group".' ); $this->allow_filter = false; $group->delete(); $this->assert_false( DB::get_value('SELECT count(*) FROM {groups} WHERE name = ?', array('new test group')) == 0, 'Was able to delete a group despite not being allowed to do so.' ); $this->allow_filter = true; $group->delete(); $this->assert_true( DB::get_value('SELECT count(*) FROM {groups} WHERE name = ?', array('new test group')) == 0, 'Was not able to delete a created group.' ); $group = UserGroup::get( "new test group" ); $this->assert_false( $group instanceof UserGroup, 'Was able to retrieve (deleted) group named "new test group".' ); }
public function filter_rssblocks_update($success, $force = false) { EventLog::log('Running rrsblocks update'); $blocks = DB::get_results('SELECT b.* FROM {blocks} b WHERE b.type = ?', array('rssblock'), 'Block'); Plugins::act('get_blocks', $blocks); $success = true; foreach ($blocks as $block) { $cachename = array('rssblock', md5($block->feed_url)); if ($force || Cache::expired($cachename)) { $r = new RemoteRequest($block->feed_url); $r->set_timeout(10); $r->execute(); $feed = $r->get_response_body(); try { if (is_string($feed)) { new SimpleXMLElement($feed); // This throws an exception if the feed isn't valid Cache::set($cachename, $feed, 3600, true); } } catch (Exception $e) { $success = false; } } } Session::notice('ran rssblocks update'); return $success; }
/** * Don't bother loading if the gd library isn't active */ public function action_plugin_activation($file) { if (!function_exists('imagecreatefromjpeg')) { Session::error(_t("Habari Silo activation failed. PHP has not loaded the gd imaging library.")); Plugins::deactivate_plugin(__FILE__); } }
/** * Constructor. * * @access protected */ protected function __construct() { // Init Config Config::init(); // Turn on output buffering ob_start(); // Display Errors Config::get('system.errors.display') and error_reporting(-1); // Set internal encoding function_exists('mb_language') and mb_language('uni'); function_exists('mb_regex_encoding') and mb_regex_encoding(Config::get('system.charset')); function_exists('mb_internal_encoding') and mb_internal_encoding(Config::get('system.charset')); // Set default timezone date_default_timezone_set(Config::get('system.timezone')); // Start the session Session::start(); // Init Cache Cache::init(); // Init Plugins Plugins::init(); // Init Blocks Blocks::init(); // Init Pages Pages::init(); // Flush (send) the output buffer and turn off output buffering ob_end_flush(); }
public function action_ajax_block(AjaxHandler $handler) { if (!isset($_SESSION['ajax_blocks'][$_GET['_b']])) { die; } $block = $_SESSION['ajax_blocks'][$_GET['_b']]; $context = null; $handler->setup_theme(); $theme = $handler->theme; $blocks = $theme->get_blocks($block->_area, $block->_scope_id, $theme); $blocks = array_filter($blocks, function ($b) use($block) { return $b->id == $block->id; }); $rebuildblock = reset($blocks); $rebuildblock->_area = $block->_area; $rebuildblock->_instance_id = $block->_instance_id; $rebuildblock->_area_index = $block->_area_index; $hook = 'block_content_' . $rebuildblock->type; Plugins::act($hook, $rebuildblock, $theme); Plugins::act('block_content', $rebuildblock, $theme); $rebuildblock->_content = $theme->content($rebuildblock, $context); $rebuildblock->_first = $block->_first; $rebuildblock->_last = $block->_last; // Set up the theme for the wrapper $theme->block = $rebuildblock; $theme->content = $rebuildblock->_content; // This is the block wrapper fallback template list $fallback = array($block->area . '.blockwrapper', 'blockwrapper', 'content'); if (!is_null($context)) { array_unshift($fallback, $context . '.blockwrapper'); array_unshift($fallback, $context . '.' . $block->area . '.blockwrapper'); } $output = $theme->display_fallback($fallback, 'fetch'); echo $output; }
/** * When Plugin is activated insert default options */ public function action_plugin_activation($file) { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { Options::set('syntax__default_lang', 'php'); Options::set('syntax__line_numbers', ''); } }
public function action_admin_header($theme) { if ($theme->page == 'configure_block' && $_GET['inline'] == 1) { Plugins::act('add_jwysiwyg_admin'); Stack::add('admin_stylesheet', array('#block_admin { display: none; } textarea { height: 250px; width: 540px; }', 'screen')); } }
public function test_format_priority() { Format::apply(function ($v) { return $v . '7'; }, 'test_filter_7'); Format::apply(function ($v) { return $v . '8'; }, 'test_filter'); $result = Plugins::filter('test_filter', 'test'); $this->assert_equal('test78', $result); Format::apply(function ($v, $c) { return $v . '7' . $c; }, 'test_filter2_7', 'a'); Format::apply(function ($v, $c) { return $v . '8' . $c; }, 'test_filter2', 'b'); $result = Plugins::filter('test_filter2', 'test'); $this->assert_equal('test7a8b', $result); Format::apply_with_hook_params(function ($v, $h, $c) { return $v . '7' . $h . $c; }, 'test_filter3_7', 'a'); Format::apply_with_hook_params(function ($v, $h, $c) { return $v . '8' . $h . $c; }, 'test_filter3', 'b'); $result = Plugins::filter('test_filter3', 'test', 'h'); $this->assert_equal('test7ha8hb', $result); }
static function init() { $base_hooks_dir = ROOT . "/hooks" ; if (is_dir($base_hooks_dir)) { $handle = opendir($base_hooks_dir); while ($file = readdir($handle)) { if (is_file("$base_hooks_dir/$file") && substr($file, -4) == '.php') { include_once "$base_hooks_dir/$file"; } } closedir($handle); } foreach ( Plugins::instance()->getActive() as $plugin ){ /* @var $plugin Plugin */ $plugin_hooks_dir = $plugin->getHooksPath(); if (is_dir($plugin_hooks_dir)) { $handle = opendir($plugin_hooks_dir); while ($file = readdir($handle)) { if (is_file("$plugin_hooks_dir/$file") && substr($file, -4) == '.php') { include_once "$plugin_hooks_dir/$file"; } } $plugin->getSystemName() ; closedir($handle); } } }
/** * All handlers must implement act() to conform to handler API. * This is the default implementation of act(), which attempts * to call a class member method of $this->act_$action(). Any * subclass is welcome to override this default implementation. * * @param string $action the action that was in the URL rule */ public function act($action) { if (null === $this->handler_vars) { $this->handler_vars = new SuperGlobal(array()); } $this->action = $action; $this->theme->assign('matched_rule', URL::get_matched_rule()); $request = new StdClass(); foreach (URL::get_active_rules() as $rule) { $request->{$rule->name} = false; } $request->{$this->theme->matched_rule->name} = true; $this->theme->assign('request', $request); $action_hook = 'plugin_act_' . $action; $before_action_hook = 'before_' . $action_hook; $theme_hook = 'route_' . $action; $after_action_hook = 'after_' . $action_hook; Plugins::act($before_action_hook, $this); Plugins::act($action_hook, $this); if (Plugins::implemented($theme_hook, 'theme')) { $theme = Themes::create(); $rule = URL::get_matched_rule(); Plugins::theme($theme_hook, $theme, $rule->named_arg_values, $this); } Plugins::act($after_action_hook); }
/** * All handlers must implement act() to conform to handler API. * This is the default implementation of act(), which attempts * to call a class member method of $this->act_$action(). Any * subclass is welcome to override this default implementation. * * @param string $action the action that was in the URL rule */ public function act($action) { if (null === $this->handler_vars) { $this->handler_vars = new SuperGlobal(array()); } $this->action = $action; $action_method = 'act_' . $action; $before_action_method = 'before_' . $action_method; $after_action_method = 'after_' . $action_method; if (method_exists($this, $action_method)) { if (method_exists($this, $before_action_method)) { $this->{$before_action_method}(); } /** * Plugin action to allow plugins to execute before a certain * action is triggered * * @see ActionHandler::$action * @action before_act_{$action} */ Plugins::act($before_action_method, $this); $this->{$action_method}(); /** * Plugin action to allow plugins to execute after a certain * action is triggered * * @see ActionHandler::$action * @action before_act_{$action} */ Plugins::act($after_action_method); if (method_exists($this, $after_action_method)) { $this->{$after_action_method}(); } } }
/** * action: plugin_activation * * @access public * @param string $file * @return void */ public function action_plugin_activation($file) { if (Plugins::id_from_file($file) != Plugins::id_from_file(__FILE__)) { return; } Options::set('calendar__week_start', 0); }
/** * Serves the locale Javascript to translate javascript strings. */ public function locale_js() { header('Expires: ' . gmdate('D, d M Y H:i:s ', time() + 432000) . 'GMT'); header('content-type: text/javascript'); $domain = HabariLocale::get_messages(); $domain_json = json_encode($domain); $js = <<<TEEHEE function _t() { var domain = {$domain_json}; var s = arguments[0]; if(domain[s] != undefined) { s = domain[s][1][0]; } for(var i = 1; i <= arguments.length; i++) { r = new RegExp('%' + (i) + '\\\\\$s', 'g'); if(!s.match(r)) { r = new RegExp('%s'); } s = s.replace(r, arguments[i]); } return s; } TEEHEE; echo Plugins::filter('locale_js', $js); }
/** * Remove notify_all options on deactivation */ public function action_plugin_deactivation($file) { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { Options::delete('notify_all__notify_posts'); Options::delete('notify_all__notify_comments'); Options::delete('notify_all__user_can_override'); } }
/** * Sets default to always show themeswitcher in footer if not using $theme->swithcer(); **/ public function action_plugin_activation($file) { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { if (Options::get('themeswitcher__show') == null) { Options::set('themeswitcher__show', 1); } } }
/** * Adds a template to the default theme that is stored in a specified path. * Use this function as a shortcut to make available additional templates to a theme * from within the plugin directory. * * @param string $name The name of the template that will be displayed, sans extension * @param string $filename The full path of the template file used for the specified name * @param boolean $override If false, allow a template with the same name in the active theme directory to override this one. * If true, always override the active theme's template with this one. */ protected function add_template($name, $filename, $override = false) { if (count($this->_added_templates) == 0) { Plugins::register(array(&$this, '_plugin_available_templates'), 'filter', 'available_templates'); Plugins::register(array(&$this, '_plugin_include_template_file'), 'filter', 'include_template_file'); } $this->_added_templates[$name] = array($filename, $override); }
/** * When adding dashboard modules, the titles should remain as they're written in their providing plugin * This function adds a value for the title of the block that is the same as the name of the type of block. * The value is in _title because overwriting the main title value causes the block data to reload. * @param Block $block The block that has data stored for the title * @param Theme $theme The theme displaying this block */ public function action_block_content($block, $theme) { static $available_modules; if (!isset($available_modules)) { $available_modules = Plugins::filter('dashboard_block_list', array()); } $block->_title = $available_modules[$block->type]; }
/** * action: plugin_activation * * @access public * @param string $file * @return void */ public function action_plugin_activation($file) { if (Plugins::id_from_file($file) != Plugins::id_from_file(__FILE__)) { return; } Options::set('socialink__link_pos', 'top'); Options::set('socialink__services', serialize(array('digg', 'delicious', 'technorati', 'google', 'yahoo', 'furl', 'reddit', 'magnolia'))); }
/** * Handles GET requests for the groups page. */ public function get_groups() { // prepare the WSSE tokens $this->theme->wsse = Utils::WSSE(); $groups = UserGroups::get_all(); $this->theme->groups = Plugins::filter('admin_groups_visible', $groups); $this->display('groups'); }
/** * action_plugin_deactivation * Unregisters the core modules. * @param string $file plugin file */ function action_plugin_deactivation($file) { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { Modules::remove_by_name('Latest Entries'); Modules::remove_by_name('Latest Comments'); Modules::remove_by_name('Latest Log Activity'); } }
public function action_plugin_deactivation($file = '') { if (Plugins::id_from_file($file) == Plugins::id_from_file(__FILE__)) { $class_name = strtolower(get_class($this)); // dump our cached list Cache::expire($class_name . ':list'); } }