コード例 #1
0
 public function render()
 {
     $this->newSource = preg_replace_callback('(\\$[\\w\\[\\]\\(\\)\'\\-\\>]*)', function ($matches) {
         if (strpos($matches[0], 'style') !== FALSE || strpos($matches[0], '$presenter') !== FALSE) {
             return $matches[0];
         }
         return "'" . str_replace(array("'"), array('"'), $matches[0]) . "'";
     }, parent::getSource());
     $this->newSource = preg_replace_callback('/\\{[^}]*\\}/', function ($matches) {
         if (strpos($matches[0], '{if') !== FALSE || strpos($matches[0], '/if}') !== FALSE || strpos($matches[0], '{ifset') !== FALSE || strpos($matches[0], '/ifset}') !== FALSE || strpos($matches[0], '{for') !== FALSE || strpos($matches[0], '/for}') !== FALSE || strpos($matches[0], '/foreach}') !== FALSE || strpos($matches[0], '{else') !== FALSE || strpos($matches[0], '{var') !== FALSE || strpos($matches[0], '|round') !== FALSE || strpos($matches[0], 'round(') !== FALSE || strpos($matches[0], 'strtolower') !== FALSE || strpos($matches[0], 'nl2br') !== FALSE || strpos($matches[0], '{?') !== FALSE || strpos($matches[0], 'count(') !== FALSE || strpos($matches[0], '|count') !== FALSE || strpos($matches[0], '|replace') !== FALSE || strpos($matches[0], 'replace(') !== FALSE || strpos($matches[0], '_replace') !== FALSE || strpos($matches[0], '{sep') !== FALSE || strpos($matches[0], '/sep}') !== FALSE || strpos($matches[0], '{last') !== FALSE || strpos($matches[0], '/last}') !== FALSE || strpos($matches[0], '{first') !== FALSE || strpos($matches[0], '/first}') !== FALSE || strpos($matches[0], '{*') !== FALSE || strpos($matches[0], '*}') !== FALSE) {
             return '';
         } elseif (strpos($matches[0], 'number') !== FALSE || strpos($matches[0], '|ceil') !== FALSE || strpos($matches[0], 'ceil(') !== FALSE) {
             return "{'NUMBER'}";
         } elseif (strpos($matches[0], '{control') !== FALSE) {
             return "{'control'}";
         } elseif (strpos($matches[0], '|ucwords') !== FALSE || strpos($matches[0], 'ucwords(') !== FALSE) {
             return "{'NAME'}";
         } elseif (strpos($matches[0], '|date') !== FALSE || strpos($matches[0], 'date(') !== FALSE || strpos($matches[0], 'format(') !== FALSE) {
             return "{'DATE'}";
         } elseif (strpos($matches[0], '?') !== FALSE) {
             return str_replace(array(':', '?'), '.', $matches[0]);
         }
         return $matches[0];
     }, $this->newSource);
     $this->newSource = str_replace(array("n:", "[''", "{*", "*}", "ucwords", "{('", "')}", ")' }", "', ('"), array("", "[", '', '', '', "{'", "'}", "') }", "', '"), $this->newSource);
     // Uncomment for debugging code
     //die($this->newSource);
     parent::render();
 }
コード例 #2
0
 public function get_menu_content()
 {
     $tpl = new FileTemplate('calendar/CalendarModuleMiniMenu.tpl');
     $tpl->add_lang(LangLoader::get('common', 'calendar'));
     $tpl->put('CALENDAR', CalendarAjaxCalendarController::get_view(true));
     return $tpl->render();
 }
コード例 #3
0
 public function display()
 {
     $tpl = new FileTemplate('ReCaptcha/ReCaptcha.tpl');
     $this->lang = LangLoader::get('common', 'ReCaptcha');
     $tpl->add_lang($this->lang);
     $tpl->put_all(array('C_RECAPTCHA_V2' => $this->is_recaptcha_v2, 'SITE_KEY' => $this->is_recaptcha_v2 ? $this->config->get_site_key() : self::DEFAULT_SITE_KEY, 'HTML_ID' => $this->get_html_id()));
     return $tpl->render();
 }
コード例 #4
0
 /**
  * @return Template The html code for the file input.
  */
 function display()
 {
     $template = $this->get_template_to_use();
     $tpl = new FileTemplate('framework/builder/form/FormFieldMultipleFilePicker.tpl');
     $tpl->put_all(array('MAX_FILE_SIZE' => $this->get_max_file_size(), 'NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input));
     $this->assign_common_template_variables($template);
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #5
0
 public function display()
 {
     $question_id = array_rand(self::$questions);
     //Question aléatoire
     $question = new QuestionCaptchaQuestion();
     $question->set_properties(self::$questions[$question_id]);
     $tpl = new FileTemplate('QuestionCaptcha/QuestionCaptcha.tpl');
     $tpl->put_all(array('QUESTION_ID' => $question_id, 'QUESTION' => $question->get_label(), 'HTML_ID' => $this->get_html_id()));
     return $tpl->render();
 }
コード例 #6
0
 public function get_menu_content()
 {
     global $LANG;
     //Chargement de la langue du module.
     load_module_lang('stats');
     $tpl = new FileTemplate('stats/stats_mini.tpl');
     $stats_cache = StatsCache::load();
     $l_member_registered = $stats_cache->get_stats_properties('nbr_members') > 1 ? $LANG['member_registered_s'] : $LANG['member_registered'];
     $group_color = User::get_group_color($stats_cache->get_stats_properties('last_member_groups'), $stats_cache->get_stats_properties('last_member_level'));
     $tpl->put_all(array('L_MORE_STAT' => $LANG['more_stats'], 'L_USER_REGISTERED' => sprintf($l_member_registered, $stats_cache->get_stats_properties('nbr_members')), 'L_LAST_REGISTERED_USER' => $LANG['last_member'], 'U_LINK_LAST_USER' => '<a href="' . UserUrlBuilder::profile($stats_cache->get_stats_properties('last_member_id'))->rel() . '" class="' . UserService::get_level_class($stats_cache->get_stats_properties('last_member_level')) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . '>' . $stats_cache->get_stats_properties('last_member_login') . '</a>'));
     return $tpl->render();
 }
コード例 #7
0
 public function get_search_form($args = null)
 {
     require_once PATH_TO_ROOT . '/kernel/begin.php';
     load_module_lang('wiki');
     global $LANG;
     $tpl = new FileTemplate('wiki/wiki_search_form.tpl');
     if (!isset($args['WikiWhere']) || !in_array($args['WikiWhere'], explode(',', 'title,contents,all'))) {
         $args['WikiWhere'] = 'title';
     }
     $tpl->put_all(array('L_WHERE' => $LANG['wiki_search_where'], 'IS_TITLE_SELECTED' => $args['WikiWhere'] == 'title' ? ' selected="selected"' : '', 'IS_CONTENTS_SELECTED' => $args['WikiWhere'] == 'contents' ? ' selected="selected"' : '', 'IS_ALL_SELECTED' => $args['WikiWhere'] == 'all' ? ' selected="selected"' : '', 'L_TITLE' => $LANG['wiki_search_where_title'], 'L_CONTENTS' => $LANG['wiki_search_where_contents']));
     return $tpl->render();
 }
コード例 #8
0
 function display()
 {
     $template = $this->get_template_to_use();
     $tpl = new FileTemplate('QuestionCaptcha/QuestionCaptchaFormFieldQuestions.tpl');
     $tpl->add_lang(LangLoader::get('common', 'QuestionCaptcha'));
     $this->assign_common_template_variables($template);
     $i = 1;
     foreach ($this->get_value() as $id => $options) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'LABEL' => $options['label'], 'ANSWERS' => $options['answers'], 'C_DELETE' => $i > 1));
         $i++;
     }
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input, 'NBR_QUESTIONS' => $i));
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #9
0
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('guestbook/GuestbookModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'guestbook'));
     $tpl->put('U_GUESTBOOK', GuestbookUrlBuilder::home()->rel());
     $guestbook_cache = GuestbookMessagesCache::load();
     $random_message = $guestbook_cache->get_message(array_rand($guestbook_cache->get_messages()));
     if ($random_message !== null) {
         $user_group_color = User::get_group_color($random_message['groups'], $random_message['level']);
         $tpl->put_all(array('C_ANY_MESSAGE_GUESTBOOK' => true, 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'C_MORE_CONTENTS' => strlen($random_message['contents']) >= 200, 'C_VISITOR' => empty($random_message['user_id']), 'CONTENTS' => $random_message['contents'], 'SHORT_CONTENTS' => nl2br(TextHelper::substr_html($random_message['contents'], 0, 200)), 'USER_PSEUDO' => $random_message['login'], 'USER_LEVEL_CLASS' => UserService::get_level_class($random_message['level']), 'USER_GROUP_COLOR' => $user_group_color, 'U_MESSAGE' => GuestbookUrlBuilder::home($random_message['page'], $random_message['id'])->rel(), 'U_PROFILE' => UserUrlBuilder::profile($random_message['user_id'])->rel()));
     }
     return $tpl->render();
 }
コード例 #10
0
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('web/WebModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'web'));
     //Load module cache
     $web_cache = WebCache::load();
     $partners_weblinks = $web_cache->get_partners_weblinks();
     $tpl->put('C_PARTNERS', !empty($partners_weblinks));
     foreach ($partners_weblinks as $partner) {
         $partner_picture = new Url($partner['partner_picture']);
         $picture = $partner_picture->rel();
         $tpl->assign_block_vars('partners', array('C_HAS_PARTNER_PICTURE' => !empty($picture), 'NAME' => $partner['name'], 'U_PARTNER_PICTURE' => $picture, 'U_VISIT' => WebUrlBuilder::visit($partner['id'])->rel()));
     }
     return $tpl->render();
 }
 function display()
 {
     $template = $this->get_template_to_use();
     $lang = LangLoader::get('admin-user-common');
     $tpl = new FileTemplate('contact/ContactFormFieldRecipientsPossibleValues.tpl');
     $tpl->add_lang($lang);
     $this->assign_common_template_variables($template);
     $i = 0;
     foreach ($this->get_value() as $name => $options) {
         if (!empty($options)) {
             $tpl->assign_block_vars('fieldelements', array('C_DELETABLE' => $i > 0, 'ID' => $i, 'NAME' => stripslashes($options['title']), 'IS_DEFAULT' => (int) $options['is_default'], 'EMAIL' => $i > 0 ? stripslashes($options['email']) : implode(',', MailServiceConfig::load()->get_administrators_mails())));
             $i++;
         }
     }
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input, 'NBR_FIELDS' => $i));
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #12
0
 private function get_view()
 {
     global $Bread_crumb, $LANG, $encoded_title, $id_article, $article_infos, $id_cat;
     load_module_lang('wiki');
     include_once PATH_TO_ROOT . '/wiki/wiki_functions.php';
     $bread_crumb_key = 'wiki';
     require_once PATH_TO_ROOT . '/wiki/wiki_bread_crumb.php';
     $config = WikiConfig::load();
     $tpl = new FileTemplate('wiki/index.tpl');
     if ($config->get_number_articles_on_index() > 1) {
         $result = PersistenceContext::get_querier()->select("SELECT a.title, a.encoded_title, a.id\r\n\t\t\tFROM " . PREFIX . "wiki_articles a\r\n\t\t\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id_contents\r\n\t\t\tWHERE a.redirect = 0\r\n\t\t\tORDER BY c.timestamp DESC\r\n\t\t\tLIMIT :number_articles_on_index OFFSET 0", array('number_articles_on_index' => $config->get_number_articles_on_index()));
         $tpl->assign_block_vars('last_articles', array('C_ARTICLES' => $result->get_rows_count(), 'L_ARTICLES' => $LANG['wiki_last_articles_list']));
         $i = 0;
         while ($row = $result->fetch()) {
             $tpl->assign_block_vars('last_articles.list', array('ARTICLE' => $row['title'], 'TR' => $i > 0 && $i % 2 == 0 ? '</tr><tr>' : '', 'U_ARTICLE' => url('wiki.php?title=' . $row['encoded_title'], $row['encoded_title'])));
             $i++;
         }
         $result->dispose();
         if ($i == 0) {
             $tpl->put_all(array('L_NO_ARTICLE' => '<td class="center" colspan="2">' . $LANG['wiki_no_article'] . '</td>'));
         }
     }
     //Affichage de toutes les catégories si c'est activé
     if ($config->are_categories_displayed_on_index()) {
         $tpl->assign_block_vars('cat_list', array('L_CATS' => $LANG['wiki_cats_list']));
         $i = 0;
         foreach (WikiCategoriesCache::load()->get_categories() as $id => $cat) {
             //Si c'est une catégorie mère
             if ($cat['id_parent'] == 0) {
                 $tpl->assign_block_vars('cat_list.list', array('CAT' => stripslashes($cat['title']), 'U_CAT' => url('wiki.php?title=' . $cat['encoded_title'], $cat['encoded_title'])));
                 $i++;
             }
         }
         if ($i == 0) {
             $tpl->put_all(array('L_NO_CAT' => $LANG['wiki_no_cat']));
         }
     }
     $tpl->put_all(array('TITLE' => $config->get_wiki_name() ? $config->get_wiki_name() : $LANG['wiki'], 'INDEX_TEXT' => $config->get_index_text() ? FormatingHelper::second_parse(wiki_no_rewrite($config->get_index_text())) : $LANG['wiki_empty_index'], 'L_EXPLORER' => $LANG['wiki_explorer'], 'U_EXPLORER' => url('explorer.php')));
     $page_type = 'index';
     include PATH_TO_ROOT . '/wiki/wiki_tools.php';
     $tpl->put('wiki_tools', $tools_tpl);
     return new StringTemplate($tpl->render());
 }
コード例 #13
0
 function display()
 {
     $template = $this->get_template_to_use();
     $tpl = new FileTemplate('news/NewsFormFieldSelectSources.tpl');
     $tpl->add_lang(LangLoader::get('common'));
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled()));
     $this->assign_common_template_variables($template);
     $i = 0;
     foreach ($this->get_value() as $name => $value) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'VALUE' => $value, 'NAME' => $name));
         $i++;
     }
     if ($i == 0) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'VALUE' => '', 'NAME' => ''));
     }
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input, 'NBR_FIELDS' => $i == 0 ? 1 : $i));
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #14
0
 function display()
 {
     $template = $this->get_template_to_use();
     $lang = LangLoader::get('common', 'contact');
     $config = ContactConfig::load();
     $tpl = new FileTemplate('contact/ContactFormFieldObjectPossibleValues.tpl');
     $tpl->add_lang($lang);
     $this->assign_common_template_variables($template);
     $fields = $config->get_fields();
     $recipients_field_id = $config->get_field_id_by_name('f_recipients');
     $recipients_field = new ContactField();
     $recipients_field->set_properties($fields[$recipients_field_id]);
     foreach ($recipients_field->get_possible_values() as $id => $options) {
         if (!empty($options)) {
             $tpl->assign_block_vars('recipients_list', array('ID' => $id, 'NAME' => stripslashes($options['title'])));
         }
     }
     $i = 0;
     foreach ($this->get_value() as $name => $options) {
         if (!empty($options)) {
             $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'NAME' => stripslashes($options['title']), 'IS_DEFAULT' => (int) $options['is_default']));
             foreach ($recipients_field->get_possible_values() as $id => $recipient_options) {
                 if (!empty($recipient_options)) {
                     $tpl->assign_block_vars('fieldelements.recipients_list', array('C_RECIPIENT_SELECTED' => $options['recipient'] == $id, 'ID' => $id, 'NAME' => stripslashes($recipient_options['title'])));
                 }
             }
             $i++;
         }
     }
     if ($i == 0) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'NAME' => '', 'IS_DEFAULT' => 0));
         foreach ($recipients_field->get_possible_values() as $id => $options) {
             if (!empty($options)) {
                 $tpl->assign_block_vars('fieldelements.recipients_list', array('ID' => $id, 'NAME' => stripslashes($options['title'])));
             }
         }
         $i++;
     }
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input, 'NBR_FIELDS' => $i));
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #15
0
 public function display()
 {
     $template = $this->get_template_to_use();
     $tpl = new FileTemplate('framework/builder/form/FormFieldMultipleAutocompleter.tpl');
     $this->assign_common_template_variables($template);
     if (empty($this->file)) {
         throw new Exception('Add file options containing file url');
     }
     $i = 0;
     foreach ($this->get_value() as $value) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'VALUE' => $value));
         $i++;
     }
     if ($i == 0) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'VALUE' => ''));
     }
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input, 'NBR_FIELDS' => $i == 0 ? 1 : $i, 'SIZE' => $this->size, 'METHOD' => $this->method, 'NAME_PARAMETER' => $this->name_parameter, 'FILE' => $this->file));
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #16
0
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('shoutbox/ShoutboxModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'shoutbox'));
     $config = ShoutboxConfig::load();
     $forbidden_tags = array_flip($config->get_forbidden_formatting_tags());
     if ($config->is_shout_bbcode_enabled()) {
         $smileys_cache = SmileysCache::load();
         $smileys_per_line = 5;
         //Smileys par ligne.
         $smileys_displayed_number = 0;
         foreach ($smileys_cache->get_smileys() as $code_smile => $infos) {
             $smileys_displayed_number++;
             $tpl->assign_block_vars('smileys', array('C_END_LINE' => $smileys_displayed_number % $smileys_per_line == 0, 'URL' => TPL_PATH_TO_ROOT . '/images/smileys/' . $infos['url_smiley'], 'CODE' => addslashes($code_smile)));
         }
     }
     $tpl->put_all(array('C_MEMBER' => AppContext::get_current_user()->check_level(User::MEMBER_LEVEL), 'C_DISPLAY_FORM' => ShoutboxAuthorizationsService::check_authorizations()->write() && !AppContext::get_current_user()->is_readonly(), 'C_VALIDATE_ONKEYPRESS_ENTER' => $config->is_validation_onkeypress_enter_enabled(), 'C_DISPLAY_SHOUT_BBCODE' => ModulesManager::is_module_installed('BBCode') && $config->is_shout_bbcode_enabled(), 'C_BOLD_DISABLED' => isset($forbidden_tags['b']), 'C_ITALIC_DISABLED' => isset($forbidden_tags['i']), 'C_UNDERLINE_DISABLED' => isset($forbidden_tags['u']), 'C_STRIKE_DISABLED' => isset($forbidden_tags['s']), 'C_AUTOMATIC_REFRESH_ENABLED' => $config->is_automatic_refresh_enabled(), 'SHOUTBOX_PSEUDO' => AppContext::get_current_user()->get_display_name(), 'SHOUT_REFRESH_DELAY' => $config->get_refresh_delay(), 'L_ALERT_LINK_FLOOD' => sprintf(LangLoader::get_message('e_l_flood', 'errors'), $config->get_max_links_number_per_message()), 'SHOUTBOX_MESSAGES' => ShoutboxAjaxRefreshMessagesController::get_view()));
     return $tpl->render();
 }
コード例 #17
0
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('faq/FaqModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'faq'));
     //Load module cache
     $faq_cache = FaqCache::load();
     //Get authorized categories for the current user
     $authorized_categories = FaqService::get_authorized_categories(Category::ROOT_CATEGORY);
     $categories = array_intersect($faq_cache->get_categories(), $authorized_categories);
     if (!empty($categories)) {
         $id_category = $categories[array_rand($categories)];
         $category_questions = $faq_cache->get_category_questions($id_category);
         $random_question = $category_questions[array_rand($category_questions)];
         if (!empty($random_question)) {
             $category = FaqService::get_categories_manager()->get_categories_cache()->get_category($id_category);
             $tpl->put_all(array('C_QUESTION' => true, 'QUESTION' => $random_question['question'], 'U_LINK' => FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $random_question['id'])->rel()));
         }
     }
     return $tpl->render();
 }
コード例 #18
0
 function display()
 {
     $template = $this->get_template_to_use();
     $lang = LangLoader::get('admin-user-common');
     $tpl = new FileTemplate('framework/builder/form/FormFieldPossibleValues.tpl');
     $tpl->add_lang($lang);
     $this->assign_common_template_variables($template);
     $i = 0;
     foreach ($this->get_value() as $name => $options) {
         if (!empty($options)) {
             $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'NAME' => $name, 'IS_DEFAULT' => (int) $options['is_default'], 'TITLE' => stripslashes($options['title'])));
             $i++;
         }
     }
     if ($i == 0) {
         $tpl->assign_block_vars('fieldelements', array('ID' => $i, 'NAME' => '', 'IS_DEFAULT' => 0, 'TITLE' => ''));
         $i++;
     }
     $tpl->put_all(array('NAME' => $this->get_html_id(), 'ID' => $this->get_id(), 'HTML_ID' => $this->get_html_id(), 'C_DISABLED' => $this->is_disabled(), 'MAX_INPUT' => $this->max_input, 'NBR_FIELDS' => $i));
     $template->assign_block_vars('fieldelements', array('ELEMENT' => $tpl->render()));
     return $template;
 }
コード例 #19
0
 public function get_menu_content()
 {
     $tpl = new FileTemplate('online/OnlineModuleMiniMenu.tpl');
     $lang = LangLoader::get('common', 'online');
     $tpl->add_lang($lang);
     $online_config = OnlineConfig::load();
     $condition = 'WHERE s.timestamp > :time ORDER BY ' . $online_config->get_display_order_request();
     $parameters = array('time' => time() - SessionsConfig::load()->get_active_session_duration());
     $users = OnlineService::get_online_users($condition, $parameters);
     foreach ($users as $user) {
         $this->incremente_level($user);
         if ($this->total_users <= $online_config->get_number_member_displayed()) {
             $group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
             if ($user->get_level() != User::VISITOR_LEVEL) {
                 $tpl->assign_block_vars('users', array('U_PROFILE' => UserUrlBuilder::profile($user->get_id())->rel(), 'PSEUDO' => TextHelper::wordwrap_html($user->get_display_name(), 19), 'LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'C_GROUP_COLOR' => !empty($group_color), 'GROUP_COLOR' => $group_color));
             }
         }
     }
     $main_lang = LangLoader::get('main');
     $tpl->put_all(array('C_MORE_USERS' => $this->total_users > $online_config->get_number_member_displayed(), 'L_VISITOR' => $this->number_visitor > 1 ? $main_lang['guest_s'] : $main_lang['guest'], 'L_MEMBER' => $this->number_member > 1 ? $main_lang['member_s'] : $main_lang['member'], 'L_MODO' => $this->number_moderator > 1 ? $main_lang['modo_s'] : $main_lang['modo'], 'L_ADMIN' => $this->number_administrator > 1 ? $main_lang['admin_s'] : $main_lang['admin'], 'L_USERS_ONLINE' => $this->total_users > 1 ? $lang['online_users'] : $lang['online_user'], 'L_TOTAL' => $main_lang['total'], 'TOTAL_USERS_CONNECTED' => $this->total_users, 'TOTAL_VISITOR_CONNECTED' => $this->number_visitor, 'TOTAL_MEMBER_CONNECTED' => $this->number_member, 'TOTAL_MODERATOR_CONNECTED' => $this->number_moderator, 'TOTAL_ADMINISTRATOR_CONNECTED' => $this->number_administrator));
     return $tpl->render();
 }
コード例 #20
0
 public function get_menu_content()
 {
     //Create file template
     $tpl = new FileTemplate('download/DownloadModuleMiniMenu.tpl');
     //Assign the lang file to the tpl
     $tpl->add_lang(LangLoader::get('common', 'download'));
     //Load module config
     $config = DownloadConfig::load();
     //Load module cache
     $download_cache = DownloadCache::load();
     //Load categories cache
     $categories_cache = DownloadService::get_categories_manager()->get_categories_cache();
     $downloadfiles = $download_cache->get_downloadfiles();
     $tpl->put_all(array('C_FILES' => !empty($downloadfiles), 'C_SORT_BY_DATE' => $config->is_sort_type_date(), 'C_SORT_BY_NOTATION' => $config->is_sort_type_notation(), 'C_SORT_BY_NUMBER_DOWNLOADS' => $config->is_sort_type_number_downloads()));
     $displayed_position = 1;
     foreach ($downloadfiles as $file) {
         $downloadfile = new DownloadFile();
         $downloadfile->set_properties($file);
         $tpl->assign_block_vars('downloadfiles', array_merge($downloadfile->get_array_tpl_vars(), array('DISPLAYED_POSITION' => $displayed_position)));
         $displayed_position++;
     }
     return $tpl->render();
 }
コード例 #21
0
 /**
  * @desc Displays the mini calendar. You must call the display method in the same order as the calendars are displayed, because it requires a javascript code loading.
  * @return string The code to write in the HTML page.
  */
 public function display()
 {
     //On crée le code selon le template
     $template = new FileTemplate('framework/util/mini_calendar.tpl');
     $template->put_all(array('DEFAULT_DATE' => !empty($this->date) ? $this->date->format(Date::FORMAT_ISO_DAY_MONTH_YEAR) : '', 'CALENDAR_ID' => $this->html_id, 'CALENDAR_NUMBER' => (string) $this->num_instance, 'DAY' => !empty($this->date) ? $this->date->get_day() : '', 'MONTH' => !empty($this->date) ? $this->date->get_month() : '', 'YEAR' => !empty($this->date) ? $this->date->get_year() : '', 'CALENDAR_STYLE' => $this->style, 'C_INCLUDE_JS' => !self::$js_inclusion_already_done));
     self::$js_inclusion_already_done = true;
     return $template->render();
 }
コード例 #22
0
 /**
  *  @desc Return the string to print the result
  *  @param &string[] $result_data the result's data
  *  @return string[] The string to print the result of a search element
  */
 public function parse_search_result($result_data)
 {
     global $LANG;
     load_module_lang('forum');
     //Chargement de la langue du module.
     $tpl = new FileTemplate('forum/forum_generic_results.tpl');
     $tpl->put_all(array('L_ON' => $LANG['on'], 'L_TOPIC' => $LANG['topic']));
     $rewrited_title = ServerEnvironmentConfig::load()->is_url_rewriting_enabled() ? '+' . Url::encode_rewrite($result_data['title']) : '';
     $tpl->put_all(array('USER_ONLINE' => '<i class="fa ' . (!empty($result_data['connect']) && $result_data['user_id'] !== -1 ? 'fa-online' : 'fa-offline') . '"></i>', 'U_USER_PROFILE' => !empty($result_data['user_id']) ? UserUrlBuilder::profile($result_data['user_id'])->rel() : '', 'USER_PSEUDO' => !empty($result_data['display_name']) ? TextHelper::wordwrap_html($result_data['display_name'], 13) : $LANG['guest'], 'U_TOPIC' => PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $result_data['topic_id'], '-' . $result_data['topic_id'] . $rewrited_title . '.php') . '#m' . $result_data['msg_id'], 'TITLE' => stripslashes($result_data['title']), 'DATE' => Date::to_format($result_data['date'], 'd/m/y'), 'CONTENTS' => FormatingHelper::second_parse(stripslashes($result_data['contents'])), 'USER_AVATAR' => '<img src="' . (UserAccountsConfig::load()->is_default_avatar_enabled() && !empty($result_data['avatar']) ? $result_data['avatar'] : PATH_TO_ROOT . '/templates/' . AppContext::get_current_user()->get_theme() . '/images/' . UserAccountsConfig::load()->get_default_avatar_name()) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" class="message-avatar"/>'));
     return $tpl->render();
 }
コード例 #23
0
ファイル: Feed.class.php プロジェクト: AroundPBT/PHPBoost
 /**
  * @static
  * @desc Generates the code which shows all the feeds formats.
  * @param string $feed_url Feed URL
  * @return string The HTML code to display.
  */
 public static function get_feed_menu($module_id, $id_cat = 0)
 {
     $feed_menu = new FileTemplate('framework/content/syndication/menu.tpl');
     $feed_menu->put_all(array('U_FEED_RSS' => SyndicationUrlBuilder::rss($module_id, $id_cat)->absolute(), 'U_FEED_ATOM' => SyndicationUrlBuilder::atom($module_id, $id_cat)->absolute()));
     return $feed_menu->render();
 }
コード例 #24
0
 public function get_menu_content()
 {
     global $LANG;
     $tpl = new FileTemplate('gallery/gallery_mini.tpl');
     //Chargement de la langue du module.
     load_module_lang('gallery');
     $config = GalleryConfig::load();
     $array_random_pics = GalleryMiniMenuCache::load()->get_pictures();
     $i = 0;
     //Affichage des miniatures disponibles
     $array_pics_mini = 'var array_pics_mini = new Array();' . "\n";
     list($nbr_pics, $sum_height, $sum_width, $scoll_mode, $height_max, $width_max) = array(0, 0, 0, 0, 142, 142);
     if (isset($array_random_pics) && $array_random_pics !== array()) {
         $gallery_mini = array();
         shuffle($array_random_pics);
         //On mélange les éléments du tableau.
         //Vérification des autorisations.
         $break = 0;
         foreach ($array_random_pics as $array_pics_info) {
             if (GalleryAuthorizationsService::check_authorizations($array_pics_info['idcat'])->read()) {
                 $gallery_mini[] = $array_pics_info;
                 $break++;
             }
             if ($break == $config->get_pics_number_in_mini()) {
                 break;
             }
         }
         //Aucune photo ne correspond, on fait une requête pour vérifier.
         if (count($gallery_mini) == 0) {
             $array_random_pics = array();
             $result = PersistenceContext::get_querier()->select("SELECT g.id, g.name, g.path, g.width, g.height, g.idcat, gc.auth\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . GallerySetup::$gallery_cats_table . " gc on gc.id = g.idcat\n\t\t\t\tWHERE g.aprob = 1 AND gc.aprob = 1\n\t\t\t\tORDER BY RAND()\n\t\t\t\tLIMIT " . $config->get_pics_number_in_mini());
             while ($row = $result->fetch()) {
                 $array_random_pics[] = $row;
             }
             //Vérification des autorisations.
             $break = 0;
             foreach ($array_random_pics as $key => $array_pics_info) {
                 if (GalleryAuthorizationsService::check_authorizations($array_pics_info['idcat'])->read()) {
                     $gallery_mini[] = $array_pics_info;
                     $break++;
                 }
                 if ($break == $config->get_pics_number_in_mini()) {
                     break;
                 }
             }
         }
         $tpl->put_all(array('C_FADE' => false, 'C_VERTICAL_SCROLL' => false, 'C_HORIZONTAL_SCROLL' => false, 'C_STATIC' => false));
         switch ($config->get_scroll_type()) {
             case GalleryConfig::STATIC_SCROLL:
                 $tpl->put('C_FADE', true);
                 break;
             case GalleryConfig::VERTICAL_DYNAMIC_SCROLL:
                 $tpl->put('C_VERTICAL_SCROLL', true);
                 break;
             case GalleryConfig::HORIZONTAL_DYNAMIC_SCROLL:
                 $tpl->put('C_HORIZONTAL_SCROLL', true);
                 break;
             case GalleryConfig::NO_SCROLL:
                 $tpl->put('C_STATIC', true);
                 break;
         }
         $Gallery = new Gallery();
         foreach ($gallery_mini as $key => $row) {
             //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
             if (!is_file(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                 $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
             }
             //Redimensionnement + création miniature
             // On recupère la hauteur et la largeur de l'image.
             if ($row['width'] == 0 || $row['height'] == 0) {
                 list($row['width'], $row['height']) = @getimagesize(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path']);
             }
             if ($row['width'] == 0 || $row['height'] == 0) {
                 list($row['width'], $row['height']) = array(142, 142);
             }
             $tpl->assign_block_vars('pics_mini', array('ID' => $row['id'], 'PICS' => TPL_PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'NAME' => TextHelper::strprotect($row['name'], TextHelper::HTML_PROTECT, TextHelper::ADDSLASHES_FORCE), 'HEIGHT' => $row['height'], 'WIDTH' => $row['width'], 'U_PICS' => TPL_PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php')));
             $sum_height += $row['height'] + 5;
             $sum_width += $row['width'] + 5;
             if ($config->get_scroll_type() == GalleryConfig::NO_SCROLL) {
                 break;
             }
             $i++;
         }
     }
     $tpl->put_all(array('ARRAY_PICS' => $array_pics_mini, 'HEIGHT_DIV' => $config->get_mini_max_height(), 'SUM_HEIGHT' => $sum_height + 10, 'HIDDEN_HEIGHT' => $config->get_mini_max_height() + 10, 'WIDTH_DIV' => $config->get_mini_max_width(), 'SUM_WIDTH' => $sum_width + 30, 'HIDDEN_WIDTH' => $config->get_mini_max_width() * 3 + 30, 'SCROLL_DELAY' => $config->get_mini_pics_speed() * 1000, 'L_NO_RANDOM_PICS' => $i == 0 ? '<br /><span class="smaller"><em>' . $LANG['no_random_img'] . '</em></span><br />' : '', 'L_GALLERY' => $LANG['gallery']));
     return $tpl->render();
 }
コード例 #25
0
 /**
  * @desc This function required object Notation containing the module_name, id_in_module, user_id, note and notation_scale.
  * @param object $notation Notation
  */
 public static function display_active_image(Notation $notation)
 {
     $note_post = AppContext::get_request()->get_int('note', 0);
     $id_post = AppContext::get_request()->get_int('id', 0);
     if (!empty($note_post) && !empty($id_post)) {
         $notation->set_id_in_module($id_post);
         $notation->set_note($note_post);
         self::register_notation($notation);
     } else {
         $template = new FileTemplate('framework/content/notation/notation.tpl');
         $average_notes = $notation->get_average_notes();
         $int = intval($average_notes);
         $decimal = floatval('0.' . substr($average_notes, strpos($average_notes, '.') + 1));
         for ($i = 1; $i <= $notation->get_notation_scale(); $i++) {
             $star_full = false;
             $star_half = false;
             $star_empty = false;
             if ($int >= $i || $int + 1 == $i && $decimal >= 0.75) {
                 $star_full = true;
             } else {
                 if ($int + 1 == $i && $decimal > 0.25 && $decimal < 0.75) {
                     $star_half = true;
                 } else {
                     $star_empty = true;
                 }
             }
             $template->assign_block_vars('star', array('I' => $i, 'STAR_EMPTY' => $star_empty, 'STAR_HALF' => $star_half, 'STAR_FULL' => $star_full));
         }
         $count_notes = $notation->get_number_notes();
         $template->put_all(array('C_JS_NOT_ALREADY_INCLUDED' => !self::$js_already_included, 'C_NOTES' => $count_notes > 0 ? true : false, 'C_MORE_1_NOTES' => $count_notes > 1 ? true : false, 'CURRENT_URL' => REWRITED_SCRIPT, 'ID_IN_MODULE' => $notation->get_id_in_module(), 'NOTATION_SCALE' => $notation->get_notation_scale(), 'NUMBER_NOTES' => $count_notes, 'AVERAGE_NOTES' => $average_notes, 'ALREADY_NOTE' => $notation->user_already_noted(), 'L_NO_NOTE' => LangLoader::get_message('no_note', 'common'), 'L_AUTH_ERROR' => LangLoader::get_message('error.auth', 'status-messages-common'), 'L_ALREADY_NOTE' => self::$lang['already_vote'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_VALID_NOTE' => LangLoader::get_message('add_note', 'common')));
         self::$js_already_included = true;
         return $template->render();
     }
 }
コード例 #26
0
 /**
  * @desc Generate a multiple select field for the form which create authorization for ranks, groups and members.
  * @param int $auth_bit The bit emplacement used to set it.
  * @param array $array_auth Array of authorization, allow you to select value authorized for this bit.
  * @param array $array_ranks_default Array of ranks selected by default.
  * @param string $idselect Html id used for the select.
  * @param int $disabled Disabled all option for the select. Set to 1 for disable.
  * @param boolean $disabled_advanced_auth Disable advanced authorizations.
  * @return String The formated select.
  * @static
  */
 public static function generate_select($auth_bit, $array_auth = array(), $array_ranks_default = array(), $idselect = '', $disabled = '', $disabled_advanced_auth = false)
 {
     global $LANG, $array_ranks;
     //Récupération du tableau des rangs.
     $array_ranks = is_array($array_ranks) ? $array_ranks : array('-1' => $LANG['guest'], '0' => $LANG['member'], '1' => $LANG['modo'], '2' => $LANG['admin']);
     //Identifiant du select, par défaut la valeur du bit de l'autorisation.
     $idselect = (string) $idselect == '' ? $auth_bit : $idselect;
     $tpl = new FileTemplate('framework/groups_auth.tpl');
     $tpl->put_all(array('C_NO_ADVANCED_AUTH' => $disabled_advanced_auth ? true : false, 'C_ADVANCED_AUTH' => $disabled_advanced_auth ? false : true, 'IDSELECT' => $idselect, 'DISABLED_SELECT' => empty($disabled) ? 'if (disabled == 0)' : '', 'L_USERS' => $LANG['member_s'], 'L_ADD_USER' => $LANG['add_member'], 'L_REQUIRE_PSEUDO' => addslashes($LANG['require_pseudo']), 'L_RANKS' => $LANG['ranks'], 'L_GROUPS' => $LANG['groups'], 'L_GO' => $LANG['go'], 'L_ADVANCED_AUTHORIZATION' => $LANG['advanced_authorization'], 'L_SELECT_ALL' => $LANG['select_all'], 'L_SELECT_NONE' => $LANG['select_none'], 'L_EXPLAIN_SELECT_MULTIPLE' => $LANG['explain_select_multiple']));
     ##### Génération d'une liste à sélection multiple des rangs et membres #####
     //Liste des rangs
     $j = -1;
     foreach ($array_ranks as $idrank => $group_name) {
         //Si il s'agit de l'administrateur, il a automatiquement l'autorisation
         if ($idrank == 2) {
             $tpl->assign_block_vars('ranks_list', array('ID' => $j, 'IDRANK' => $idrank, 'RANK_NAME' => $group_name, 'DISABLED' => '', 'SELECTED' => ' selected="selected"'));
         } else {
             $selected = '';
             if (array_key_exists('r' . $idrank, $array_auth) && ((int) $array_auth['r' . $idrank] & (int) $auth_bit) !== 0 && empty($disabled)) {
                 $selected = ' selected="selected"';
             }
             $selected = isset($array_ranks_default[$idrank]) && $array_ranks_default[$idrank] === true && empty($disabled) ? 'selected="selected"' : $selected;
             $tpl->assign_block_vars('ranks_list', array('ID' => $j, 'IDRANK' => $idrank, 'RANK_NAME' => $group_name, 'DISABLED' => !empty($disabled) ? 'disabled = "disabled" ' : '', 'SELECTED' => $selected));
         }
         $j++;
     }
     //Liste des groupes.
     $groups_name = GroupsService::get_groups_names();
     foreach ($groups_name as $idgroup => $group_name) {
         $selected = '';
         if (array_key_exists($idgroup, $array_auth) && ((int) $array_auth[$idgroup] & (int) $auth_bit) !== 0 && empty($disabled)) {
             $selected = ' selected="selected"';
         }
         $tpl->assign_block_vars('groups_list', array('IDGROUP' => $idgroup, 'GROUP_NAME' => $group_name, 'DISABLED' => $disabled, 'SELECTED' => $selected));
     }
     ##### Génération du formulaire pour les autorisations membre par membre. #####
     //Recherche des membres autorisé.
     $array_auth_members = array();
     if (is_array($array_auth)) {
         foreach ($array_auth as $type => $auth) {
             if (substr($type, 0, 1) == 'm') {
                 if (array_key_exists($type, $array_auth) && ((int) $array_auth[$type] & (int) $auth_bit) !== 0) {
                     $array_auth_members[$type] = $auth;
                 }
             }
         }
     }
     $advanced_auth = count($array_auth_members) > 0;
     $tpl->put_all(array('ADVANCED_AUTH_STYLE' => $advanced_auth ? 'display:block;' : 'display:none;', 'C_ADVANCED_AUTH_OPEN' => $advanced_auth, 'C_NO_GROUP' => count($groups_name) == 0));
     //Listing des membres autorisés.
     if ($advanced_auth) {
         $result = PersistenceContext::get_querier()->select_rows(DB_TABLE_MEMBER, array('user_id, display_name'), 'WHERE user_id=:user_ids', array('user_ids' => str_replace('m', '', array_keys($array_auth_members))));
         while ($row = $result->fetch()) {
             $tpl->assign_block_vars('members_list', array('USER_ID' => $row['user_id'], 'LOGIN' => $row['display_name']));
         }
         $result->dispose();
     }
     return $tpl->render();
 }
コード例 #27
0
 public function get_menu_content()
 {
     global $LANG;
     $poll_config = PollConfig::load();
     $config_cookie_name = $poll_config->get_cookie_name();
     $polls = PollMiniMenuCache::load()->get_polls();
     //Chargement de la langue du module.
     load_module_lang('poll');
     $rand = array_rand($polls);
     $poll_mini = $polls[$rand];
     //Sondage aléatoire.
     $tpl = new FileTemplate('poll/poll_mini.tpl');
     #####################Résultats######################
     //Si le cookie existe, on redirige vers les resulats, sinon on prend en compte le vote (vérification par ip plus tard).
     $array_cookie = array();
     if (AppContext::get_request()->has_cookieparameter($config_cookie_name)) {
         $array_cookie = explode('/', AppContext::get_request()->get_cookie($config_cookie_name));
     }
     if (in_array($poll_mini['id'], $array_cookie)) {
         $tpl->put_all(array('L_VOTE' => $poll_mini['total'] > 1 ? $LANG['poll_vote_s'] : $LANG['poll_vote']));
         $tpl->assign_block_vars('result', array('QUESTION' => $poll_mini['question'], 'VOTES' => $poll_mini['total']));
         foreach ($poll_mini['votes'] as $answer => $width) {
             $tpl->assign_block_vars('result.answers', array('ANSWERS' => $answer, 'WIDTH' => NumberHelper::round($width, 0), 'PERCENT' => $width));
         }
     } else {
         #####################Questions######################
         $tpl->put_all(array('L_MINI_POLL' => $LANG['mini_poll'], 'L_VOTE' => $LANG['poll_vote'], 'L_POLL_RESULT' => $LANG['poll_result'], 'U_POLL_RESULT' => url('.php?id=' . $poll_mini['id'] . '&amp;r=1', '-' . $poll_mini['id'] . '-1.php')));
         $tpl->assign_block_vars('question', array('ID' => url('.php?id=' . $poll_mini['id'], '-' . $poll_mini['id'] . '.php'), 'QUESTION' => $poll_mini['question']));
         $z = 0;
         if ($poll_mini['type'] == '1') {
             if (is_array($poll_mini['votes'])) {
                 // FIXME should always be an array, needs to patch cache generation
                 foreach ($poll_mini['votes'] as $answer => $width) {
                     $tpl->assign_block_vars('question.radio', array('NAME' => $z, 'ANSWERS' => $answer));
                     $z++;
                 }
             }
         } elseif ($poll_mini['type'] == '0') {
             foreach ($poll_mini['votes'] as $answer => $width) {
                 $tpl->assign_block_vars('question.checkbox', array('NAME' => $z, 'ANSWERS' => $answer));
                 $z++;
             }
         }
     }
     return $tpl->render();
 }
コード例 #28
0
 /**
  * @desc Display the content menu.
  * @return a string of the parsed template ready to be displayed
  */
 public function display()
 {
     $tpl = new FileTemplate('framework/menus/content.tpl');
     $tpl->put_all(array('C_DISPLAY_TITLE' => $this->display_title, 'C_VERTICAL_BLOCK' => $this->get_block() == Menu::BLOCK_POSITION__LEFT || $this->get_block() == Menu::BLOCK_POSITION__RIGHT, 'TITLE' => $this->title, 'CONTENT' => FormatingHelper::second_parse($this->content), 'C_HIDDEN_WITH_SMALL_SCREENS' => $this->hidden_with_small_screens));
     return $tpl->render();
 }
コード例 #29
0
ファイル: explorer.php プロジェクト: AroundPBT/PHPBoost
$cat = retrieve(GET, 'cat', 0);
require_once '../kernel/header.php';
$template = new FileTemplate('wiki/explorer.tpl');
$module_data_path = $template->get_pictures_data_path();
//Contenu de la racine:
$root = '';
foreach (WikiCategoriesCache::load()->get_categories() as $key => $cat) {
    if ($cat['id_parent'] == 0) {
        $root .= '<li><a href="javascript:open_cat(' . $key . '); show_wiki_cat_contents(' . $cat['id_parent'] . ', 0);"><i class="fa fa-folder"></i>' . stripslashes($cat['title']) . '</a></li>';
    }
}
$result = PersistenceContext::get_querier()->select("SELECT title, id, encoded_title\n\tFROM " . PREFIX . "wiki_articles a\n\tWHERE id_cat = 0\n\tAND a.redirect = 0\n\tORDER BY is_cat DESC, title ASC");
while ($row = $result->fetch()) {
    $root .= '<li><a href="' . url('wiki.php?title=' . $row['encoded_title'], $row['encoded_title']) . '"><i class="fa fa-file"></i>' . stripslashes($row['title']) . '</a></li>';
}
$result->dispose();
$template->put_all(array('TITLE' => $LANG['wiki_explorer'], 'L_ROOT' => $LANG['wiki_root'], 'SELECTED_CAT' => $cat > 0 ? $cat : 0, 'ROOT_CONTENTS' => $root, 'L_CATS' => $LANG['wiki_cats_tree']));
$contents = '';
$result = PersistenceContext::get_querier()->select("SELECT c.id, a.title, a.encoded_title\nFROM " . PREFIX . "wiki_cats c\nLEFT JOIN " . PREFIX . "wiki_articles a ON a.id = c.article_id\nWHERE c.id_parent = 0\nORDER BY title ASC");
while ($row = $result->fetch()) {
    $sub_cats_number = PersistenceContext::get_querier()->count(PREFIX . "wiki_cats", 'WHERE id_parent = :id', array('id' => $row['id']));
    if ($sub_cats_number > 0) {
        $template->assign_block_vars('list', array('DIRECTORY' => '<li class="sub"><a class="parent" href="javascript:show_wiki_cat_contents(' . $row['id'] . ', 0);"><i class="fa fa-plus-square-o" id="img2_' . $row['id'] . '"></i><i class="fa fa-folder" id ="img_' . $row['id'] . '"></i></a><a id="class_' . $row['id'] . '" href="javascript:open_cat(' . $row['id'] . ');">' . stripslashes($row['title']) . '</a><span id="cat_' . $row['id'] . '"></span></li>'));
    } else {
        $template->assign_block_vars('list', array('DIRECTORY' => '<li class="sub"><a id="class_' . $row['id'] . '" href="javascript:open_cat(' . $row['id'] . ');"><i class="fa fa-folder"></i>' . stripslashes($row['title']) . '</a><span id="cat_' . $row['id'] . '"></span></li>'));
    }
}
$result->dispose();
$template->put_all(array('SELECTED_CAT' => 0, 'CAT_0' => 'selected', 'CAT_LIST' => '', 'CURRENT_CAT' => $LANG['wiki_no_selected_cat']));
echo $template->render();
require_once '../kernel/footer.php';
コード例 #30
0
ファイル: search.inc.php プロジェクト: AroundPBT/PHPBoost
/**
 *  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();
}