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());
 }
예제 #2
0
 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;
 }
예제 #3
0
 public function get_actions_tree_links()
 {
     global $LANG;
     load_module_lang('wiki');
     //Chargement de la langue du module.
     require_once PATH_TO_ROOT . '/wiki/wiki_auth.php';
     $id_cat = AppContext::get_request()->get_getstring('id_cat', 0);
     $current_user = AppContext::get_current_user();
     $config = WikiConfig::load();
     $tree = new ModuleTreeLinks();
     $tree->add_link(new AdminModuleLink(LangLoader::get_message('configuration', 'admin'), new Url('/wiki/admin_wiki.php')));
     $tree->add_link(new AdminModuleLink($LANG['authorizations'], new Url('/wiki/admin_wiki_groups.php')));
     $tree->add_link(new ModuleLink($LANG['wiki_create_article'], new Url('/wiki/post.php' . ($id_cat > 0 ? '?id_parent=' . $id_cat : '')), $current_user->check_auth($config->get_authorizations(), WIKI_CREATE_ARTICLE)));
     $tree->add_link(new ModuleLink($LANG['wiki_create_cat'], new Url('/wiki/post.php?type=cat' . ($id_cat > 0 ? '&amp;id_parent=' . $id_cat : '')), $current_user->check_auth($config->get_authorizations(), WIKI_CREATE_CAT)));
     if ($current_user->check_level(User::MEMBER_LEVEL)) {
         $tree->add_link(new ModuleLink($LANG['wiki_followed_articles'], new Url('/wiki/favorites.php')));
     }
     $tree->add_link(new ModuleLink($LANG['wiki_explorer_short'], new Url('/wiki/explorer.php')));
     return $tree;
 }
예제 #4
0
 * 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 '../admin/admin_begin.php';
load_module_lang('wiki');
define('TITLE', $LANG['administration']);
require_once '../admin/admin_header.php';
include_once '../wiki/wiki_functions.php';
$config = WikiConfig::load();
$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();