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()); }
public function get_feed_data_struct($idcat = 0, $name = '') { $querier = PersistenceContext::get_querier(); global $LANG; load_module_lang('wiki'); $categories = WikiCategoriesCache::load()->get_categories(); $config = WikiConfig::load(); $parameters = array('limit' => 20); if ($idcat > 0 && array_key_exists($idcat, $categories)) { $desc = sprintf($LANG['wiki_rss_cat'], stripslashes($categories[$idcat]['title'])); $where = 'AND a.id_cat = :idcat'; $parameters['idcat'] = $idcat; } else { $desc = sprintf($LANG['wiki_rss_last_articles'], $config->get_wiki_name() ? $config->get_wiki_name() : $LANG['wiki']); $where = ''; } $data = new FeedData(); $data->set_title($config->get_wiki_name() ? $config->get_wiki_name() : $LANG['wiki']); $data->set_date(new Date()); $data->set_link(SyndicationUrlBuilder::rss('wiki', $idcat)); $data->set_host(HOST); $data->set_desc($desc); $data->set_lang($LANG['xml_lang']); // Last news $results = $querier->select('SELECT a.title, a.encoded_title, c.content, c.timestamp FROM ' . PREFIX . 'wiki_articles a LEFT JOIN ' . PREFIX . 'wiki_contents c ON c.id_contents = a.id_contents WHERE a.redirect = 0 ' . $where . ' ORDER BY c.timestamp DESC LIMIT :limit OFFSET 0', $parameters); // Generation of the feed's items foreach ($results as $row) { $item = new FeedItem(); $item->set_title($row['title']); $link = new Url('/wiki/' . url('wiki.php?title=' . $row['encoded_title'], $row['encoded_title'])); $item->set_link($link); $item->set_guid($link); $item->set_desc(FormatingHelper::second_parse($row['content'])); $item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE)); $data->add_item($item); } $results->dispose(); return $data; }
private function create_module_map_sections($id_cat, $auth_mode) { global $LANG; $categories_cache = WikiCategoriesCache::load(); $categories = $categories_cache->get_categories(); $this_category = new SitemapLink(stripslashes($categories[$id_cat]['title']), new Url('/wiki/' . url('wiki.php?title=' . $categories[$id_cat]['encoded_title'], $categories[$id_cat]['encoded_title']))); $category = new SitemapSection($this_category); $i = 0; $keys = array_keys($categories); $num_cats = $categories_cache->get_number_categories(); $properties = array(); for ($j = 0; $j < $num_cats; $j++) { $id = $keys[$j]; $properties = $categories[$id]; if ($id != 0 && $properties['id_parent'] == $id_cat) { $category->add($this->create_module_map_sections($id, $auth_mode)); $i++; } } if ($i == 0) { $category = $this_category; } return $category; }
$request = AppContext::get_request(); $update = $request->get_postvalue('update', false); $display_categories_on_index = $request->get_postvalue('display_categories_on_index', false); $hits_counter = $request->get_postvalue('hits_counter', false); $index_text = stripslashes(wiki_parse(retrieve(POST, 'contents', '', TSTRING_AS_RECEIVED))); if ($update) { $config->set_wiki_name(TextHelper::strprotect(retrieve(POST, 'wiki_name', $LANG['wiki'], TSTRING_AS_RECEIVED), TextHelper::HTML_PROTECT, TextHelper::ADDSLASHES_NONE)); $config->set_number_articles_on_index(retrieve(POST, 'number_articles_on_index', 0)); if ($display_categories_on_index) { $config->display_categories_on_index(); } else { $config->hide_categories_on_index(); } if ($hits_counter) { $config->enable_hits_counter(); } else { $config->disable_hits_counter(); } $config->set_index_text(stripslashes(wiki_parse(retrieve(POST, 'contents', '', TSTRING_AS_RECEIVED)))); WikiConfig::save(); //Régénération du cache WikiCategoriesCache::invalidate(); } $tpl = new FileTemplate('wiki/admin_wiki.tpl'); //On travaille uniquement en BBCode, on force le langage de l'éditeur $content_editor = AppContext::get_content_formatting_service()->get_default_factory(); $editor = $content_editor->get_editor(); $editor->set_identifier('contents'); $tpl->put_all(array('KERNEL_EDITOR' => $editor->display(), 'HITS_SELECTED' => $config->is_hits_counter_enabled() ? 'checked="checked"' : '', 'WIKI_NAME' => $config->get_wiki_name(), 'HIDE_CATEGORIES_ON_INDEX' => !$config->are_categories_displayed_on_index() ? 'checked="checked"' : '', 'DISPLAY_CATEGORIES_ON_INDEX' => $config->are_categories_displayed_on_index() ? 'checked="checked"' : '', 'NUMBER_ARTICLES_ON_INDEX' => $config->get_number_articles_on_index(), 'DESCRIPTION' => wiki_unparse($config->get_index_text()), 'L_UPDATE' => $LANG['update'], 'L_RESET' => $LANG['reset'], 'L_PREVIEW' => $LANG['preview'], 'L_WIKI_MANAGEMENT' => $LANG['wiki_management'], 'L_WIKI_GROUPS' => $LANG['wiki_groups_config'], 'L_CONFIG_WIKI' => $LANG['wiki_config'], 'L_WHOLE_WIKI' => $LANG['wiki_config_whole'], 'L_INDEX_WIKI' => $LANG['wiki_index'], 'L_HITS_COUNTER' => $LANG['wiki_count_hits'], 'L_WIKI_NAME' => $LANG['wiki_name'], 'L_DISPLAY_CATEGORIES_ON_INDEX' => $LANG['wiki_display_cats'], 'L_NOT_DISPLAY' => $LANG['wiki_no_display'], 'L_DISPLAY' => $LANG['wiki_display'], 'L_NUMBER_ARTICLES_ON_INDEX' => $LANG['wiki_last_articles'], 'L_NUMBER_ARTICLES_ON_INDEX_EXPLAIN' => $LANG['wiki_last_articles_explain'], 'L_DESCRIPTION' => $LANG['wiki_desc'])); $tpl->display(); require_once '../admin/admin_footer.php';
* 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; } require_once PATH_TO_ROOT . '/wiki/wiki_auth.php'; $config = WikiConfig::load(); $categories = WikiCategoriesCache::load()->get_categories(); switch ($bread_crumb_key) { case 'wiki': if (!empty($id_contents)) { $Bread_crumb->add($LANG['wiki_history'], ''); } if (!empty($article_infos['title'])) { if ($article_infos['is_cat'] == 0) { $Bread_crumb->add(stripslashes($article_infos['title']), url('wiki.php?title=' . $article_infos['encoded_title'], $article_infos['encoded_title'])); } $id_cat = (int) $article_infos['id_cat']; } if (!empty($id_cat) && is_array($categories)) { $id = $id_cat; //Premier id do {
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ require_once '../kernel/begin.php'; include_once '../wiki/wiki_functions.php'; load_module_lang('wiki'); define('TITLE', $LANG['wiki_explorer']); $bread_crumb_key = 'wiki_explorer'; require_once '../wiki/wiki_bread_crumb.php'; $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) {
function wiki_find_subcats(&$array, $id_cat) { //On parcourt les catégories et on détermine les catégories filles foreach (WikiCategoriesCache::load()->get_categories() as $key => $value) { if ($value['id_parent'] == $id_cat) { $array[] = $key; //On rappelle la fonction pour la catégorie fille wiki_find_subcats($array, $key); } } }