Esempio n. 1
0
 public function store()
 {
     $page_name = $this->name;
     // cleanups to make directory transversal impossible
     // TODO proper cleanup of name!
     $page_name = str_replace('.', '_', $page_name);
     $page_name = str_replace('/', '_', $page_name);
     $page_name = str_replace('\\', '_', $page_name);
     $page_name = str_replace(' ', '_', $page_name);
     $dst_file = WikiConfig::getDiskPath() . '/' . $page_name;
     file_put_contents($dst_file, $this->text);
     return SqlObject::store($this, self::$tbl_name, 'name');
 }
 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;
 }
Esempio n. 4
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;
 }
Esempio n. 5
0
 if (!$group) {
     exit_error(_('Invalid Project'), _('Inexistent Project'));
 }
 if (!$group->usesPlugin($pluginname)) {
     //check if the group has the plugin active
     exit_error("Error", "First activate the {$pluginname} plugin through the Project's Admin Interface");
 }
 $userperm = $group->getPermission($user);
 //we'll check if the user belongs to the group
 if (!$userperm->IsMember()) {
     exit_error(_('Access Denied'), _('You are not a member of this project'));
 }
 //only project admin can access here
 if ($userperm->isAdmin()) {
     wiki_Project_Header(array('title' => "Configuration for your project's Wiki", 'pagename' => "{$pluginname}", 'sectionvals' => array(group_getname($id))));
     $wc = new WikiConfig($id);
     print "\n<h1>" . _("Configuration for your project's Wiki") . "</h1>\n";
     print "<table>\n";
     print "<tr>\n";
     print "<td>\n";
     print "<fieldset>\n";
     print "<legend>" . _('Wiki Configuration') . "</legend>\n";
     print "<form action=\"/plugins/wiki/wikiadmin.php\" method=\"post\">\n";
     print "<input type=\"hidden\" name=\"id\" value=\"{$id}\" />\n";
     print "<input type=\"hidden\" name=\"pluginname\" value=\"{$pluginname}\" />\n";
     print "<input type=\"hidden\" name=\"type\" value=\"admin_post\" />\n";
     print '<table class="listing">';
     print "\n<thead>\n<tr>\n<th>" . _("Parameter") . "</th>" . "<th>" . _("Value") . "</th>\n" . "</tr>\n</thead>\n";
     foreach ($wc->getWikiConfigNames() as $c) {
         $checked = $wc->getWikiConfig($c) ? ' checked="checked"' : '';
         $desc = $wc->getWikiConfigDescription($c);
Esempio n. 6
0
$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';
Esempio n. 7
0
*  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';
load_module_lang('wiki');
$config = WikiConfig::load();
include '../wiki/wiki_functions.php';
//Id de l'article à afficher en version imprimable
$article_id = retrieve(GET, 'id', 0);
//Requêtes préliminaires utiles par la suite
if ($article_id > 0) {
    $result = PersistenceContext::get_querier()->select("SELECT a.id, a.is_cat, a.hits, a.redirect, a.id_cat, a.title, a.encoded_title, a.is_cat, a.defined_status, com_topic.number_comments, f.id AS id_favorite, a.undefined_status, a.auth, c.menu, c.content\n\tFROM " . PREFIX . "wiki_articles a\n\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id_contents\n\tLEFT JOIN " . PREFIX . "wiki_favorites f ON f.id_article = a.id\n\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com_topic ON a.id = com_topic.id_in_module AND com_topic.module_id = 'wiki'\n\tWHERE a.id = :id\n\tGROUP BY a.id", array('id' => $article_id));
    $article_infos = $result->fetch();
    $result->dispose();
    if (!empty($article_infos['redirect'])) {
        $id_redirection = $article_infos['id'];
        $result = PersistenceContext::get_querier()->select("SELECT a.id, a.is_cat, a.hits, a.redirect, a.id_cat, a.title, a.encoded_title, a.is_cat, com_topic.number_comments, a.defined_status, f.id AS id_favorite, a.undefined_status, a.auth, c.menu, c.content\n\t\tFROM " . PREFIX . "wiki_articles a\n\t\tLEFT JOIN " . PREFIX . "wiki_contents c ON c.id_contents = a.id_contents\n\t\tLEFT JOIN " . PREFIX . "wiki_favorites f ON f.id_article = a.id\n\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com_topic ON a.id = com_topic.id_in_module AND com_topic.module_id = 'wiki'\n\t\tWHERE a.id = :id\n\t\tGROUP BY a.id", array('id' => $article_infos['redirect']));
        $article_infos = $result->fetch();
        $result->dispose();
    }
}