public final function get_right_controller_regarding_authorizations() { if (ModulesManager::is_module_installed(Environment::get_running_module_name())) { $module = ModulesManager::get_module(Environment::get_running_module_name()); if (!$module->is_activated()) { return PHPBoostErrors::module_not_activated(); } } else { return PHPBoostErrors::module_not_installed(); } return $this; }
public function get_formated_title() { $class_name = get_class($this); $module_name = strstr($class_name, 'ModuleMiniMenu', true); $module_name = strlen(preg_replace('/[a-z]*/', '', $module_name)) > 1 ? $module_name : strtolower($module_name); //Pour les modules qui ont plus de 2 majuscules on les garde, sinon on les enlève $module = ''; try { $module = ModulesManager::get_module($module_name); } catch (Exception $e) { } $localized_module_name = !empty($module) ? $module->get_configuration()->get_name() : ''; return !empty($localized_module_name) ? (!preg_match('/^' . Langloader::get_message('admin.main_menu', 'main') . ' /', $localized_module_name) ? Langloader::get_message('admin.main_menu', 'main') . ' ' : '') . $localized_module_name : $class_name; }
public final function get_right_controller_regarding_authorizations() { if (!AppContext::get_current_user()->is_admin()) { return new UserLoginController(UserLoginController::ADMIN_LOGIN, substr(REWRITED_SCRIPT, strlen(GeneralConfig::load()->get_site_path()))); } else { if (ModulesManager::is_module_installed(Environment::get_running_module_name())) { $module = ModulesManager::get_module(Environment::get_running_module_name()); if (!$module->is_activated()) { return PHPBoostErrors::module_not_activated(); } } else { return PHPBoostErrors::module_not_installed(); } } return $this; }
public static function display_actions_menu() { $module_name = Environment::get_running_module_name(); $tree_links = self::get_tree_links($module_name); if ($tree_links !== null) { $actions_tree_links = $tree_links->get_actions_tree_links(); $module = ModulesManager::get_module($module_name); $tpl = new FileTemplate('framework/module/module_actions_links_menu.tpl'); $tpl->put_all(array('C_DISPLAY' => $actions_tree_links->has_visible_links(), 'ID' => $module_name, 'MODULE_NAME' => $module->get_configuration()->get_name())); $home_page = $module->get_configuration()->get_home_page(); if (!empty($home_page)) { $module_home = new ModuleLink(LangLoader::get_message('home', 'main'), new Url('/' . $module->get_id() . '/' . $home_page)); $tpl->assign_block_vars('element', array(), array('ELEMENT' => $module_home->export())); } return self::display($actions_tree_links, $tpl); } }
public function execute(HTTPRequestCustom $request) { $module_id = $request->get_getstring('module_id', ''); $user_id = $request->get_getint('user_id', 0); if (!empty($user_id)) { try { $this->user = UserService::get_user($user_id); } catch (Exception $e) { $error_controller = PHPBoostErrors::unexisting_element(); DispatchManager::redirect($error_controller); } } if (!empty($module_id)) { $this->module = ModulesManager::get_module($module_id); } $this->init($request); return $this->build_response(); }
private function get_module_map($auth_mode) { $module = ModulesManager::get_module($this->categories_manager->get_module_id()); $module_configuration = $module->get_configuration(); $link = new SitemapLink($module_configuration->get_name(), new Url('/' . $module->get_id() . '/'), Sitemap::FREQ_DAILY, Sitemap::PRIORITY_MAX); $module_map = new ModuleMap($link, $module->get_id()); $categories = $this->categories_manager->get_categories_cache()->get_categories(); foreach ($categories as $id => $category) { if ($auth_mode == Sitemap::AUTH_PUBLIC) { $this_auth = Authorizations::check_auth(RANK_TYPE, User::VISITOR_LEVEL, $category->get_authorizations(), Category::READ_AUTHORIZATIONS); } else { $this_auth = AppContext::get_current_user()->check_auth($category->get_authorizations(), Category::READ_AUTHORIZATIONS); } if ($this_auth && $id != Category::ROOT_CATEGORY && $category->get_id_parent() == Category::ROOT_CATEGORY) { $module_map->add($this->create_module_map_sections($categories, $id, $auth_mode)); } } return $module_map; }
private function get_array_select_type() { $select = array(); $modules = $this->get_extended_fields_class_name(); foreach ($modules as $module => $files) { if (count($modules) > 1) { if ($module == 'kernel') { $kernel_select = array(); foreach ($files as $field_type) { $kernel_select[] = new FormFieldSelectChoiceOption($field_type->get_name(), get_class($field_type)); } $select[] = new FormFieldSelectChoiceGroupOption($this->lang['default-field'], $kernel_select); } else { $module_select = array(); foreach ($files as $field_type) { $module_select[] = new FormFieldSelectChoiceOption($field_type->get_name(), get_class($field_type)); } $module_name = ModulesManager::get_module($module)->get_configuration()->get_name(); $select[] = new FormFieldSelectChoiceGroupOption($module_name, $module_select); } } else { foreach ($files as $field_type) { $select[] = new FormFieldSelectChoiceOption($field_type->get_name(), get_class($field_type)); } } } return $select; }
private function list_files($theme_selected) { $files = array(); $files[] = new FormFieldSelectChoiceOption('--', ''); $folder = new Folder(PATH_TO_ROOT . $this->templates_path . $theme_selected . $this->tpl_files_path); foreach ($folder->get_files('`\\.tpl$`') as $file) { $files[] = new FormFieldSelectChoiceOption($file->get_name(), $file->get_name_without_extension()); } foreach (ModulesManager::get_activated_modules_map_sorted_by_localized_name() as $id => $module) { $folder = new Folder(PATH_TO_ROOT . '/' . $module->get_id() . '/templates'); if ($folder->exists()) { foreach ($folder->get_files('`\\.tpl$`') as $file) { $files[] = new FormFieldSelectChoiceOption(LangLoader::get_message('module', 'admin-modules-common') . ' ' . ModulesManager::get_module($module->get_id())->get_configuration()->get_name() . ' : ' . $file->get_name(), $module->get_id() . '/' . $file->get_name_without_extension()); } } } $folder = new Folder(PATH_TO_ROOT . '/user/templates'); if ($folder->exists()) { foreach ($folder->get_files('`\\.tpl$`') as $file) { $files[] = new FormFieldSelectChoiceOption(LangLoader::get_message('users', 'user-common') . ' : ' . $file->get_name(), 'user/' . $file->get_name_without_extension()); } } return $files; }
/** * @desc Gets the name of the module from which the notification. * @return string The module name. */ public function get_module_name() { if (!empty($this->module_id)) { $module = ModulesManager::get_module($this->module_id); return $module ? $module->get_configuration()->get_name() : ''; } else { return ''; } }
if ($search_in != 'all') { if (isset($used_modules[$search_in]) && isset($modules_args[$search_in])) { $used_modules = array($search_in => $used_modules[$search_in]); $modules_args = array($search_in => $modules_args[$search_in]); } else { $used_modules = array(); $modules_args = array(); } } else { // We remove modules that we're not searching in foreach ($modules_args as $module_id => $module_args) { if (!$query_mode && (!in_array($module_id, $selected_modules) || !isset($modules_args[$module_id]))) { unset($modules_args[$module_id]); unset($used_modules[$module_id]); } } } // Génération des résultats et passage aux templates $nbResults = get_search_results($search, $used_modules, $modules_args, $results, $idsSearch); foreach ($used_modules as $module_id => $extension_point) { $tpl->assign_block_vars('results', array('MODULE_NAME' => $module_id, 'L_MODULE_NAME' => ucfirst(ModulesManager::get_module($module_id)->get_configuration()->get_name()), 'ID_SEARCH' => $idsSearch[$module_id])); } $all_html_result = ''; if ($nbResults > 0) { get_html_results($results, $all_html_result, $search_in); } $tpl->assign_vars(array('NB_RESULTS_PER_PAGE' => NB_RESULTS_PER_PAGE, 'L_TITLE_ALL_RESULTS' => $LANG['title_all_results'], 'L_RESULTS' => $LANG['results'], 'L_RESULTS_CHOICE' => $LANG['results_choice'], 'L_PRINT' => $LANG['print'], 'L_NB_RESULTS_FOUND' => $nbResults > 1 ? $LANG['nb_results_found'] : ($nbResults == 0 ? $LANG['no_results_found'] : $LANG['one_result_found']), 'L_SEARCH_RESULTS' => $LANG['search_results'], 'NB_RESULTS' => $nbResults, 'ALL_RESULTS' => $all_html_result, 'SEARCH_IN' => $search_in, 'C_SIMPLE_SEARCH' => $search_in == 'all')); $tpl->display(); } //--------------------------------------------------------------------- Footer require_once '../kernel/footer.php';
* * 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. * ###################################################*/ if (defined('PHPBOOST') !== true) { exit; } $env = new AdminDisplayGraphicalEnvironment(); Environment::set_graphical_environment($env); if (!defined('TITLE')) { define('TITLE', $LANG['unknown']); } $module_id = Environment::get_running_module_name(); $section = ''; if (!Environment::home_page_running() && ModulesManager::is_module_installed($module_id)) { $section = ModulesManager::get_module($module_id)->get_configuration()->get_name(); } $env->set_page_title(TITLE, $section); ob_start();
/** * @desc Get the number of the installed version * @return string version */ private function get_installed_version() { switch ($this->type) { case self::KERNEL_TYPE: return GeneralConfig::load()->get_phpboost_major_version(); case self::MODULE_TYPE: if (ModulesManager::is_module_installed($this->id)) { return ModulesManager::get_module($this->id)->get_configuration()->get_version(); } return '0'; case self::TEMPLATE_TYPE: if (ThemesManager::get_theme_existed($this->id)) { return ThemesManager::get_theme($this->id)->get_configuration()->get_version(); } return '0'; default: return '0'; } }
/** * 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(); }
* * ################################################### * * 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 'init.php'; $running_module_name = Environment::get_running_module_name(); if (!in_array($running_module_name, array('user', 'admin', 'kernel'))) { if (ModulesManager::is_module_installed($running_module_name)) { $module = ModulesManager::get_module($running_module_name); if (!$module->is_activated()) { DispatchManager::redirect(PHPBoostErrors::module_not_activated()); } } else { DispatchManager::redirect(PHPBoostErrors::module_not_installed()); } }
} } elseif ($clearOutCache) { $querier = PersistenceContext::get_querier(); $querier->truncate(PREFIX . 'search_results'); $querier->truncate(PREFIX . 'search_index'); AppContext::get_response()->redirect(HOST . SCRIPT); } else { $tpl = new FileTemplate('search/admin_search.tpl'); $config = SearchConfig::load(); $tpl->assign_vars(array('L_SEARCH_MANAGEMENT' => $LANG['search_management'], 'L_SEARCH_CONFIG' => $LANG['search_config'], 'L_SEARCH_CONFIG_WEIGHTING' => $LANG['search_config_weighting'], 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'], 'C_WEIGHTING' => $weighting)); if (!$weighting) { $provider_service = AppContext::get_extension_provider_service(); foreach ($provider_service->get_providers(SearchableExtensionPoint::EXTENSION_POINT) as $module_id => $provider) { $module_configuration = ModulesManager::get_module($module_id)->get_configuration(); if (in_array($module_id, $config->get_unauthorized_providers())) { $selected = ' selected="selected"'; } else { $selected = ''; } $tpl->assign_block_vars('authorized_modules', array('MODULE' => $module_id, 'SELECTED' => $selected, 'L_MODULE_NAME' => ucfirst($module_configuration->get_name()))); } $tpl->put_all(array('L_REQUIRE' => LangLoader::get_message('form.explain_required_fields', 'status-messages-common'), 'L_CACHE_TIME' => $LANG['cache_time'], 'L_CACHE_TIME_EXPLAIN' => $LANG['cache_time_explain'], 'L_NB_RESULTS_P' => $LANG['nb_results_per_page'], 'L_MAX_USE' => $LANG['max_use'], 'L_MAX_USE_EXPLAIN' => $LANG['max_use_explain'], 'L_CLEAR_OUT_CACHE' => $LANG['clear_out_cache'], 'L_AUTHORIZED_MODULES' => $LANG['unauthorized_modules'], 'L_AUTHORIZED_MODULES_EXPLAIN' => $LANG['unauthorized_modules_explain'], 'L_SEARCH_CACHE' => $LANG['search_cache'], 'L_AUTHORIZATIONS' => $LANG['admin.authorizations'], 'L_READ_AUTHORIZATION' => $LANG['admin.authorizations.read'], 'CACHE_TIME' => $config->get_cache_lifetime(), 'MAX_USE' => $config->get_cache_max_uses(), 'NB_RESULTS_P' => $config->get_nb_results_per_page(), 'READ_AUTHORIZATION' => Authorizations::generate_select(SearchAuthorizationsService::READ_AUTHORIZATIONS, $config->get_authorizations()))); } else { foreach ($config->get_weightings()->get_modules_weighting() as $module_id => $weighting) { $tpl->assign_block_vars('weights', array('MODULE' => $module_id, 'L_MODULE_NAME' => ucfirst(ModulesManager::get_module($module_id)->get_configuration()->get_name()), 'WEIGHT' => $weighting)); } $tpl->assign_vars(array('L_MODULES' => $LANG['modules'], 'L_WEIGHTS' => $LANG['search_weights'], 'L_SEARCH_CONFIG_WEIGHTING_EXPLAIN' => $LANG['search_config_weighting_explain'])); } $tpl->display(); } require_once '../admin/admin_footer.php';