public static function __static() { $extension_points = AppContext::get_extension_provider_service()->get_extension_point(CssFilesExtensionPoint::EXTENSION_POINT); foreach ($extension_points as $module_id => $provider) { self::$modules_css_files[$module_id] = $provider; } }
public function execute(HTTPRequestCustom $request) { $module_id = $request->get_getstring('module_id', ''); if (empty($module_id)) { AppContext::get_response()->redirect(Environment::get_home_page()); } $this->init(); $module_category_id = $request->get_getint('module_category_id', 0); $feed_name = $request->get_getstring('feed_name', Feed::DEFAULT_FEED_NAME); $feed = new ATOM($module_id, $feed_name, $module_category_id); if ($feed !== null && $feed->is_in_cache()) { $this->tpl->put('SYNDICATION', $feed->read()); } else { $eps = AppContext::get_extension_provider_service(); if ($eps->provider_exists($module_id, FeedProvider::EXTENSION_POINT)) { $provider = $eps->get_provider($module_id); $feeds = $provider->feeds(); $data = $feeds->get_feed_data_struct($module_category_id, $feed_name); if ($data === null) { AppContext::get_response()->set_header('content-type', 'text/html'); DispatchManager::redirect(PHPBoostErrors::unexisting_element()); } else { $feed->load_data($data); $feed->cache(); $this->tpl->put('SYNDICATION', $feed->export()); } } else { DispatchManager::redirect(PHPBoostErrors::module_not_installed()); } } return $this->build_response($this->tpl); }
private function build_form() { $modules = AppContext::get_extension_provider_service()->get_extension_point(UserExtensionPoint::EXTENSION_POINT); foreach ($modules as $module) { $img = $module->get_messages_list_link_img(); $this->tpl->assign_block_vars('available_modules_msg', array('NAME_USER_MSG' => $module->get_messages_list_link_name(), 'IMG_USER_MSG' => $img, 'C_IMG_USER_MSG' => !empty($img), 'U_LINK_USER_MSG' => $module->get_messages_list_url($this->user->get_id()))); } $this->tpl->put_all(array('L_MESSAGES' => $this->lang['messages'])); }
public function get_modules_weighting() { $weighting = array(); $provider_service = AppContext::get_extension_provider_service(); foreach ($provider_service->get_providers(SearchableExtensionPoint::EXTENSION_POINT) as $module_id => $provider) { $weighting[$module_id] = $this->get_module_weighting($module_id); } return $weighting; }
function test_get_module() { global $MODULES; self::assertTrue(count($MODULES) > 0); $modulediscovery = AppContext::get_extension_provider_service(); $ret = $modulediscovery->get_provider('news'); self::assertIsA($ret, 'ExtensionPointProvider'); self::assertIsA($modulediscovery->loaded_modules['news'], 'ExtensionPointProvider'); }
private function load_commands_list() { $provider_service = AppContext::get_extension_provider_service(); $extension_point = $provider_service->get_extension_point(CLICommands::EXTENSION_POINT); foreach ($extension_point as $commands) { foreach ($commands->get_commands() as $command) { $this->commands[$command] = $commands; } } }
public static function get_tree_links($module_name) { try { return AppContext::get_extension_provider_service()->get_provider($module_name)->get_extension_point(ModuleTreeLinksExtensionPoint::EXTENSION_POINT); } catch (UnexistingExtensionPointProviderException $e) { return null; } catch (ExtensionPointNotFoundException $e) { return null; } }
private function call($command, array $args) { $provider_service = AppContext::get_extension_provider_service(); $providers = $provider_service->get_providers(CLICommands::EXTENSION_POINT); foreach ($providers as $provider) { $commands = $provider->get_extension_point(CLICommands::EXTENSION_POINT); if (in_array($command, $commands->get_commands())) { $commands->help($command, $args); return; } } CLIOutput::writeln('command ' . $command . ' does not exist'); $this->help(array()); }
/** * Renvoie une chaine contenant les resultats */ function get_html_results(&$results, &$html_results, &$results_name) { $provider_service = AppContext::get_extension_provider_service(); $display_all_results = $results_name == 'all' ? true : false; $tpl_results = new FileTemplate('search/search_generic_pagination_results.tpl'); $tpl_results->assign_vars(array('RESULTS_NAME' => $results_name, 'C_ALL_RESULTS' => $display_all_results)); $nb_pages = round(count($results) / NB_RESULTS_PER_PAGE) + 1; $nb_results = count($results); if (!$display_all_results) { $provider = $provider_service->get_provider(strtolower($results_name)); $extension_point = $provider->get_extension_point(SearchableExtensionPoint::EXTENSION_POINT); $results_data = array(); $personnal_parse_results = $extension_point->has_customized_results(); if ($personnal_parse_results && $results_name != 'all') { $results_data = $extension_point->compute_search_results(array('results' => $results)); $nb_results = min($nb_results, count($results_data)); } } for ($num_page = 0; $num_page < $nb_pages; $num_page++) { $tpl_results->assign_block_vars('page', array('NUM_PAGE' => $num_page, 'BLOCK_DISPLAY' => $num_page == 0 ? 'block' : 'none')); for ($i = 0; $i < NB_RESULTS_PER_PAGE; $i++) { $num_item = $num_page * NB_RESULTS_PER_PAGE + $i; if ($num_item >= $nb_results) { break; } if ($display_all_results || !$personnal_parse_results) { $tpl_result = new FileTemplate('search/search_generic_results.tpl'); $module = ModulesManager::get_module($results[$num_item]['module']); if ($display_all_results) { $tpl_result->assign_vars(array('C_ALL_RESULTS' => true, 'L_MODULE_NAME' => $module->get_configuration()->get_name())); } else { $tpl_result->assign_vars(array('C_ALL_RESULTS' => false, 'L_MODULE_NAME' => $module->get_configuration()->get_name())); } $tpl_result->assign_vars(array('TITLE' => $results[$num_item]['title'], 'U_LINK' => url($results[$num_item]['link']))); $tpl_results->assign_block_vars('page.results', array('result' => $tpl_result->render())); } else { $tpl_results->assign_block_vars('page.results', array('result' => $extension_point->parse_search_result($results_data[$num_item]))); } } } $html_results = $tpl_results->render(); }
public function execute(HTTPRequestCustom $request) { $general_config = GeneralConfig::load(); $other_home_page = $general_config->get_other_home_page(); if (strpos($other_home_page, '/index.php') !== false) { AppContext::get_response()->redirect(UserUrlBuilder::home()); } else { if (!empty($other_home_page)) { AppContext::get_response()->redirect($other_home_page); } else { try { $module = AppContext::get_extension_provider_service()->get_provider($general_config->get_module_home_page()); if ($module->has_extension_point(HomePageExtensionPoint::EXTENSION_POINT)) { $home_page = $module->get_extension_point(HomePageExtensionPoint::EXTENSION_POINT)->get_home_page(); return $this->build_response($home_page->get_view(), $home_page->get_title()); } else { AppContext::get_response()->redirect(UserUrlBuilder::home()); } } catch (UnexistingExtensionPointProviderException $e) { AppContext::get_response()->redirect(UserUrlBuilder::home()); } } } }
$tpl->assign_block_vars('image_up', array('NAME' => stripslashes($imageup['name']), 'IMG' => '<a href="gallery.php?cat=' . $imageup['idcat'] . '&id=' . $g_idpics . '#pics_max"><img src="pics/' . $imageup['path'] . '" alt="' . $imageup['name'] . '" /></a>', 'L_SUCCESS_UPLOAD' => $LANG['success_upload_img'], 'U_CAT' => '<a href="gallery.php?cat=' . $imageup['idcat'] . '">' . $categories[$imageup['idcat']]->get_name() . '</a>')); } //Affichage du quota d'image uploadée. $category_authorizations = GalleryService::get_categories_manager()->get_heritated_authorizations($id_category, Category::WRITE_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY); $quota = isset($category_authorizations['r-1']) ? $category_authorizations['r-1'] != '3' : true; if ($quota) { switch (AppContext::get_current_user()->get_level()) { case 2: $l_pics_quota = $LANG['illimited']; break; case 1: $l_pics_quota = $config->get_moderator_max_pics_number(); break; default: $l_pics_quota = $config->get_member_max_pics_number(); } $nbr_upload_pics = $Gallery->get_nbr_upload_pics(AppContext::get_current_user()->get_id()); $tpl->assign_block_vars('image_quota', array('L_IMAGE_QUOTA' => sprintf($LANG['image_quota'], $nbr_upload_pics, $l_pics_quota))); } $search_category_children_options = new SearchCategoryChildrensOptions(); $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS); $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS); $tpl->put_all(array('CAT_ID' => $id_category, 'GALLERY' => !empty($id_category) ? $categories[$id_category]->get_name() : $LANG['gallery'], 'CATEGORIES_TREE' => GalleryService::get_categories_manager()->get_select_categories_form_field('cat', LangLoader::get_message('form.category', 'common'), $id_category, $search_category_children_options)->display()->render(), 'WIDTH_MAX' => $config->get_max_width(), 'HEIGHT_MAX' => $config->get_max_height(), 'WEIGHT_MAX' => $config->get_max_weight(), 'IMG_FORMAT' => 'JPG, PNG, GIF', 'L_IMG_FORMAT' => $LANG['img_format'], 'L_WIDTH_MAX' => $LANG['width_max'], 'L_HEIGHT_MAX' => $LANG['height_max'], 'L_WEIGHT_MAX' => $LANG['weight_max'], 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $LANG['gallery'], 'L_GALLERY_INDEX' => $LANG['gallery_index'], 'L_CATEGORIES' => $LANG['categories'], 'L_NAME' => $LANG['name'], 'L_UNIT_PX' => LangLoader::get_message('unit.pixels', 'common'), 'L_UNIT_KO' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_UPLOAD' => $LANG['upload_img'], 'U_GALLERY_CAT_LINKS' => $cat_links, 'U_GALLERY_ACTION_ADD' => GalleryUrlBuilder::get_link_cat_add($id_category, null, AppContext::get_session()->get_token()), 'U_INDEX' => url('.php'))); $tpl->display(); } else { $module = AppContext::get_extension_provider_service()->get_provider('gallery'); if ($module->has_extension_point(HomePageExtensionPoint::EXTENSION_POINT)) { echo $module->get_extension_point(HomePageExtensionPoint::EXTENSION_POINT)->get_home_page()->get_view()->display(); } } require_once '../kernel/footer.php';
public static function get_extension_point() { return AppContext::get_extension_provider_service()->get_extension_point(MenusExtensionPoint::EXTENSION_POINT); }
private function get_extended_fields_class_name() { $providers = AppContext::get_extension_provider_service()->get_providers(ExtendedFieldExtensionPoint::EXTENSION_POINT); $extended_fields_class_name = array(); foreach ($providers as $name_provider => $properties) { $extended_fields_extension_point = $properties->get_extension_point(ExtendedFieldExtensionPoint::EXTENSION_POINT); $extended_fields = $extended_fields_extension_point->get_extended_fields(); $extended_fields_list = array(); foreach ($extended_fields as $extended_field) { if (!$extended_field->get_field_used_once() || get_class($extended_field) == $this->extended_field['field_type']) { $extended_fields_list[] = $extended_field; } } if (!empty($extended_fields_list)) { $extended_fields_class_name[$name_provider] = $extended_fields_list; } } return $extended_fields_class_name; }
/** * @desc Export a feed * @param string $module_id the module id * @param string $name the feed name / type * @param int $idcat the feed data category * @param mixed $tpl If false, uses de default tpl. If an associative array, * uses the default tpl but assigns it the array vars first. * It could also be a Template object * @param int $number the number of item to display * @param int $begin_at the first item to display * @return string The exported feed * @static */ public static function get_parsed($module_id, $name = self::DEFAULT_FEED_NAME, $idcat = 0, $template = false, $number = 10, $begin_at = 0) { if (!$template instanceof Template) { $template = new FileTemplate($module_id . '/framework/content/syndication/feed.tpl'); if (gettype($template) == 'array') { $template->put_all($template); } } $feed_data_cache_file_exists = true; // Get the cache content or recreate it if not existing $feed_data_cache_file = FEEDS_PATH . $module_id . '_' . $name . '_' . $idcat . '.php'; if (!file_exists($feed_data_cache_file)) { $extension_provider_service = AppContext::get_extension_provider_service(); $provider = $extension_provider_service->get_provider($module_id); if (!$provider->has_extension_point(FeedProvider::EXTENSION_POINT)) { // If the module is not installed or doesn't have the get_feed_data_struct // functionality we break return ''; } $feed_provider = $provider->get_extension_point(FeedProvider::EXTENSION_POINT); $data = $feed_provider->get_feed_data_struct($idcat); $feed_data_cache_file_exists = self::update_cache($module_id, $name, $data, $idcat); } if ($feed_data_cache_file_exists) { include $feed_data_cache_file; $feed = new Feed($module_id, $name); $feed->load_data($__feed_object); return $feed->export($template, $number, $begin_at); } else { MessageHelper::display(sprintf(ERROR_GETTING_CACHE, $module_id, $idcat), MessageHelper::WARNING); return ''; } }
public static function add_in_visit_counter() { $ip_address = AppContext::get_request()->get_ip_address(); $has_already_visited = PersistenceContext::get_querier()->row_exists(DB_TABLE_VISIT_COUNTER, 'WHERE ip=:ip', array('ip' => $ip_address)); $is_robot = Robots::is_robot(); if (!$has_already_visited && !$is_robot) { $now = new Date(Date::DATE_NOW, Timezone::SITE_TIMEZONE); $time = $now->format('Y-m-d', Timezone::SITE_TIMEZONE); PersistenceContext::get_querier()->inject("UPDATE " . DB_TABLE_VISIT_COUNTER . " SET ip = ip + 1, time=:time, total = total + 1 WHERE id = 1", array('time' => $time)); PersistenceContext::get_querier()->insert(DB_TABLE_VISIT_COUNTER, array('ip' => $ip_address, 'time' => $time, 'total' => 0)); } $jobs = AppContext::get_extension_provider_service()->get_extension_point(ScheduledJobExtensionPoint::EXTENSION_POINT); foreach ($jobs as $job) { $job->on_new_session(!$has_already_visited, $is_robot); } }
$module = $selected_modules['0']; $search_in = $module; } } //--------------------------------------------------------------------- Header define('TITLE', $LANG['title_search']); require_once '../kernel/header.php'; $tpl->assign_vars(array('L_TITLE_SEARCH' => TITLE, 'L_SEARCH' => $LANG['title_search'], 'TEXT_SEARCHED' => $unsecure_search, 'L_SEARCH_ALL' => $LANG['search_all'], 'L_SEARCH_KEYWORDS' => $LANG['search_keywords'], 'L_SEARCH_MIN_LENGTH' => $LANG['search_min_length'], 'L_SEARCH_IN_MODULES' => $LANG['search_in_modules'], 'L_SEARCH_IN_MODULES_EXPLAIN' => $LANG['search_in_modules_explain'], 'L_SEARCH_SPECIALIZED_FORM' => $LANG['search_specialized_form'], 'L_SEARCH_SPECIALIZED_FORM_EXPLAIN' => $LANG['search_specialized_form_explain'], 'L_WARNING_LENGTH_STRING_SEARCH' => TextHelper::to_js_string($LANG['warning_length_string_searched']), 'L_FORMS' => $LANG['forms'], 'L_ADVANCED_SEARCH' => $LANG['advanced_search'], 'L_SIMPLE_SEARCH' => $LANG['simple_search'], 'U_FORM_VALID' => url('../search/search.php#results'), 'C_SIMPLE_SEARCH' => $search_in == 'all' ? true : false, 'SEARCH_MODE_MODULE' => $search_in)); //------------------------------------------------------------- Other includes require_once '../search/search.inc.php'; //----------------------------------------------------------------------- Main $config = SearchConfig::load(); $modules_args = array(); $used_modules = array(); // Génération des formulaires précomplétés et passage aux templates $provider_service = AppContext::get_extension_provider_service(); $search_extensions_point_modules = array_keys($provider_service->get_extension_point(SearchableExtensionPoint::EXTENSION_POINT)); $search_extensions_point = $provider_service->get_extension_point(SearchableExtensionPoint::EXTENSION_POINT); foreach (ModulesManager::get_installed_modules_map_sorted_by_localized_name() as $id => $module) { if (in_array($module->get_id(), $search_extensions_point_modules)) { $module_configuration = $module->get_configuration(); if (!in_array($module->get_id(), $config->get_all_unauthorized_providers())) { // Ajout du paramètre search à tous les modules $modules_args[$module->get_id()]['search'] = $search; if ($search_extensions_point[$module->get_id()]->has_search_options()) { // Récupération de la liste des paramètres $form_module_args = $search_extensions_point[$module->get_id()]->get_search_args(); // Ajout des paramètres optionnels sans les sécuriser. // Ils sont sécurisés à l'intérieur de chaque module. if ($search_in != 'all') { foreach ($form_module_args as $arg) {
* begin : January 31, 2006 * copyright : (C) 2005 Viarre Régis / Sautel Benoît * email : crowkait@phpboost.com / ben.popeye@phpboost.com * * ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ require_once '../kernel/begin.php'; require_once '../stats/stats_begin.php'; require_once '../kernel/header.php'; $modulesLoader = AppContext::get_extension_provider_service(); $module = $modulesLoader->get_provider('stats'); if ($module->has_extension_point(HomePageExtensionPoint::EXTENSION_POINT)) { echo $module->get_extension_point(HomePageExtensionPoint::EXTENSION_POINT)->get_home_page()->get_view()->display(); } require_once '../kernel/footer.php';
private function add_modules_rules() { $this->add_section('Modules rules'); $modules = ModulesManager::get_activated_modules_map(); $eps = AppContext::get_extension_provider_service(); foreach ($modules as $module) { $id = $module->get_id(); $configuration = $module->get_configuration(); $rules = $configuration->get_url_rewrite_rules(); if (!empty($rules)) { $this->add_section($id); } foreach ($rules as $rule) { $this->add_line(str_replace('DIR', $this->general_config->get_site_path(), $rule)); } if ($eps->provider_exists($id, UrlMappingsExtensionPoint::EXTENSION_POINT)) { $this->add_section($id); $provider = $eps->get_provider($id); $url_mappings = $provider->get_extension_point(UrlMappingsExtensionPoint::EXTENSION_POINT); $this->add_url_mapping($url_mappings); } } }
private function list_modules_home_page() { $providers = array_keys(AppContext::get_extension_provider_service()->get_providers(HomePageExtensionPoint::EXTENSION_POINT)); $options = array(new FormFieldSelectChoiceOption($this->lang['general-config.other_start_page'], 'other')); $installed_modules = ModulesManager::get_installed_modules_map_sorted_by_localized_name(); foreach ($installed_modules as $id => $module) { if (in_array($module->get_id(), $providers)) { $options[] = new FormFieldSelectChoiceOption($module->get_configuration()->get_name(), $module->get_id()); } } if (empty($options)) { $options[] = new FormFieldSelectChoiceOption($this->lang['no_module_starteable'], ''); } return $options; }
private static function execute_modules_changepage_tasks() { $jobs = AppContext::get_extension_provider_service()->get_extension_point(ScheduledJobExtensionPoint::EXTENSION_POINT); foreach ($jobs as $job) { $job->on_changepage(); } }
function get_feeds($feed_cat, $module_id, $feed_type, $feed_url_edit = '', $level = 0) { return get_feeds_children($feed_cat->get_children(), $module_id, $feed_type, $feed_url_edit, $level + 1); } function get_feeds_children(array $children, $module_id, $feed_type, $feed_url_edit = '', $level) { if (!empty($children)) { foreach ($children as $id => $feed_cat) { $url = $feed_cat->get_url($feed_type); $urls[] = array('name' => $feed_cat->get_category_name(), 'url' => $url, 'level' => $level, 'feed_name' => $feed_type, 'selected' => $feed_url_edit == $url); } return array_merge($urls, get_feeds_children($feed_cat->get_children(), $module_id, $feed_type, $feed_url_edit, $level + 1)); } return array(); } $feeds_modules = AppContext::get_extension_provider_service()->get_providers(FeedProvider::EXTENSION_POINT); foreach (ModulesManager::get_installed_modules_map_sorted_by_localized_name() as $id => $module) { if (array_key_exists($module->get_id(), $feeds_modules)) { $list = $feeds_modules[$module->get_id()]->get_extension_point(FeedProvider::EXTENSION_POINT); $list = $list->get_feeds_list(); foreach ($list->get_feeds_list() as $feed_type => $object) { $urls = get_feeds($object, $module->get_id(), $feed_type, $feed_url); $root[0] = array('name' => $object->get_category_name(), 'url' => $object->get_url($feed_type), 'level' => 0, 'feed_name' => null, 'selected' => $feed_url == $object->get_url($feed_type)); } $urls = array_merge($root, $urls); $tpl->assign_block_vars('modules', array('NAME' => ucfirst($module->get_configuration()->get_name()))); foreach ($urls as $url) { $tpl->assign_block_vars('modules.feeds_urls', array('URL' => $url['url'], 'NAME' => $url['name'], 'SPACE' => str_repeat('--', $url['level']), 'FEED_NAME' => $url['feed_name'] != 'master' ? $url['feed_name'] : null, 'SELECTED' => $url['selected'] ? ' selected="selected"' : '')); } } }
/** * @desc Adds to the site map all maps of the installed modules * @param int $auth_mode AUTH_GUEST or AUTH_USERS, it depends if you want to display only the public pages or also the private ones. */ private function build_modules_maps($auth_mode = self::AUTH_PUBLIC) { $providers = AppContext::get_extension_provider_service()->get_providers(SitemapExtensionPoint::EXTENSION_POINT); foreach (ModulesManager::get_installed_modules_map_sorted_by_localized_name() as $id => $module) { if (array_key_exists($module->get_id(), $providers)) { $sitemap_provider = $providers[$module->get_id()]->sitemap(); if ($auth_mode == self::AUTH_PUBLIC) { $module_map = $sitemap_provider->get_public_sitemap(); } else { $module_map = $sitemap_provider->get_user_sitemap(); } $this->add($module_map); } } }