private function build_form()
    {
        $form = new HTMLForm(__CLASS__);
        $fieldset = new FormFieldsetHTML('configuration', LangLoader::get_message('configuration', 'admin-common'));
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldTextEditor('title', $this->lang['admin.config.title'], $this->config->get_title(), array('maxlength' => 255, 'required' => true)));
        $fieldset->add_field(new FormFieldCheckbox('informations_enabled', $this->lang['admin.config.informations_enabled'], $this->config->are_informations_enabled(), array('description' => $this->lang['admin.config.informations.explain'], 'events' => array('click' => '
				if (HTMLForms.getField("informations_enabled").getValue()) {
					HTMLForms.getField("informations_position").enable();
					HTMLForms.getField("informations").enable();
				} else {
					HTMLForms.getField("informations_position").disable();
					HTMLForms.getField("informations").disable();
				}'))));
        $fieldset->add_field(new FormFieldSimpleSelectChoice('informations_position', $this->lang['admin.config.informations_position'], $this->config->get_informations_position(), array(new FormFieldSelectChoiceOption($this->lang['admin.config.informations.position_left'], ContactConfig::LEFT), new FormFieldSelectChoiceOption($this->lang['admin.config.informations.position_top'], ContactConfig::TOP), new FormFieldSelectChoiceOption($this->lang['admin.config.informations.position_right'], ContactConfig::RIGHT), new FormFieldSelectChoiceOption($this->lang['admin.config.informations.position_bottom'], ContactConfig::BOTTOM)), array('hidden' => !$this->config->are_informations_enabled())));
        $fieldset->add_field(new FormFieldRichTextEditor('informations', $this->lang['admin.config.informations_content'], FormatingHelper::unparse($this->config->get_informations()), array('rows' => 8, 'cols' => 47, 'hidden' => !$this->config->are_informations_enabled())));
        $fieldset->add_field(new FormFieldCheckbox('tracking_number_enabled', $this->lang['admin.config.tracking_number_enabled'], $this->config->is_tracking_number_enabled(), array('events' => array('click' => '
				if (HTMLForms.getField("tracking_number_enabled").getValue()) {
					HTMLForms.getField("date_in_tracking_number_enabled").enable();
				} else {
					HTMLForms.getField("date_in_tracking_number_enabled").disable();
				}'))));
        $fieldset->add_field(new FormFieldCheckbox('date_in_tracking_number_enabled', $this->lang['admin.config.date_in_date_in_tracking_number_enabled'], $this->config->is_date_in_tracking_number_enabled(), array('description' => $this->lang['admin.config.date_in_date_in_tracking_number_enabled.explain'], 'hidden' => !$this->config->is_tracking_number_enabled())));
        $fieldset->add_field(new FormFieldCheckbox('sender_acknowledgment_enabled', $this->lang['admin.config.sender_acknowledgment_enabled'], $this->config->is_sender_acknowledgment_enabled()));
        $fieldset_authorizations = new FormFieldsetHTML('authorizations', LangLoader::get_message('authorizations', 'common'));
        $form->add_fieldset($fieldset_authorizations);
        $auth_settings = new AuthorizationsSettings(array(new ActionAuthorization($this->lang['admin.authorizations.read'], ContactAuthorizationsService::READ_AUTHORIZATIONS)));
        $auth_settings->build_from_auth_array($this->config->get_authorizations());
        $fieldset_authorizations->add_field(new FormFieldAuthorizationsSetter('authorizations', $auth_settings));
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
 public function display_field_profile(MemberExtendedField $member_extended_field)
 {
     $fieldset = $member_extended_field->get_fieldset();
     $value = FormatingHelper::second_parse($member_extended_field->get_value());
     if ($value !== null) {
         $fieldset->add_field(new FormFieldFree($member_extended_field->get_field_name(), $member_extended_field->get_name(), $value));
     }
 }
 public function get_feed_data_struct($idcat = 0, $name = '')
 {
     $querier = PersistenceContext::get_querier();
     $lang = LangLoader::get('common', 'bugtracker');
     //Configuration load
     $config = BugtrackerConfig::load();
     $types = $config->get_types();
     $categories = $config->get_categories();
     $severities = $config->get_severities();
     $priorities = $config->get_priorities();
     $versions = $config->get_versions_detected();
     $site_name = GeneralConfig::load()->get_site_name();
     $feed_module_name = $idcat == 1 ? $lang['titles.solved'] : $lang['titles.unsolved'];
     $data = new FeedData();
     $data->set_title($feed_module_name . ' - ' . $site_name);
     $data->set_date(new Date());
     $data->set_link(SyndicationUrlBuilder::rss('bugtracker', $idcat));
     $data->set_host(HOST);
     $data->set_desc($feed_module_name . ' - ' . $site_name);
     $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
     $data->set_auth_bit(BugtrackerAuthorizationsService::READ_AUTHORIZATIONS);
     $results = $querier->select("SELECT bugtracker.*, author.*\r\n\t\tFROM " . BugtrackerSetup::$bugtracker_table . " bugtracker\r\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " author ON author.user_id = bugtracker.author_id\r\n\t\tWHERE " . ($idcat == 1 ? "(status = '" . Bug::FIXED . "' OR status = '" . Bug::REJECTED . "')" : "status <> '" . Bug::FIXED . "' AND status <> '" . Bug::REJECTED . "'") . "\r\n\t\tORDER BY " . ($idcat == 1 ? "fix_date" : "submit_date") . " DESC");
     foreach ($results as $row) {
         $bug = new Bug();
         $bug->set_properties($row);
         $link = BugtrackerUrlBuilder::detail($bug->get_id() . '-' . $bug->get_rewrited_title());
         $description = FormatingHelper::second_parse($bug->get_contents());
         $description .= '<br /><br />' . $lang['labels.fields.reproductible'] . ' : ' . ($bug->is_reproductible() ? LangLoader::get_message('yes', 'common') : LangLoader::get_message('no', 'common'));
         if ($bug->is_reproductible()) {
             $description .= '<br />' . FormatingHelper::second_parse($bug->get_reproduction_method()) . '<br />';
         }
         if ($types) {
             $description .= '<br />' . $lang['labels.fields.type'] . ' : ' . (isset($types[$bug->get_type()]) ? stripslashes($types[$bug->get_type()]) : $lang['notice.none']);
         }
         if ($categories) {
             $description .= '<br />' . $lang['labels.fields.category'] . ' : ' . (isset($categories[$bug->get_category()]) ? stripslashes($categories[$bug->get_category()]) : $lang['notice.none_e']);
         }
         if ($severities) {
             $description .= '<br />' . $lang['labels.fields.severity'] . ' : ' . (isset($severities[$bug->get_severity()]) ? stripslashes($severities[$bug->get_severity()]['name']) : $lang['notice.none']);
         }
         if ($priorities) {
             $description .= '<br />' . $lang['labels.fields.priority'] . ' : ' . (isset($priorities[$bug->get_priority()]) ? stripslashes($priorities[$bug->get_priority()]) : $lang['notice.none_e']);
         }
         if ($versions) {
             $description .= '<br />' . $lang['labels.fields.version'] . ' : ' . (isset($versions[$bug->get_detected_in()]) ? stripslashes($versions[$bug->get_detected_in()]['name']) : $lang['notice.not_defined']);
         }
         $item = new FeedItem();
         $item->set_title($bug->get_title());
         $item->set_link($link);
         $item->set_guid($link);
         $item->set_desc($description);
         $item->set_date($bug->get_submit_date());
         $item->set_auth(BugtrackerAuthorizationsService::READ_AUTHORIZATIONS);
         $data->add_item($item);
     }
     $results->dispose();
     return $data;
 }
 public function build_view()
 {
     $this->build_form();
     if ($this->submit_button->has_been_submited() && $this->form->validate()) {
         if ($this->send_mail()) {
             $this->view->put('MSG', MessageHelper::display($this->lang['message.success_mail'] . ($this->config->is_sender_acknowledgment_enabled() ? ' ' . $this->lang['message.acknowledgment'] : ''), MessageHelper::SUCCESS));
             $this->view->put('C_MAIL_SENT', true);
         } else {
             $this->view->put('MSG', MessageHelper::display($this->lang['message.error_mail'], MessageHelper::ERROR, 5));
         }
     }
     $this->view->put('FORM', $this->form->display());
     $this->view->put_all(array('C_INFORMATIONS_LEFT' => $this->config->are_informations_enabled() && $this->config->are_informations_left(), 'C_INFORMATIONS_TOP' => $this->config->are_informations_enabled() && $this->config->are_informations_top(), 'C_INFORMATIONS_RIGHT' => $this->config->are_informations_enabled() && $this->config->are_informations_right(), 'C_INFORMATIONS_BOTTOM' => $this->config->are_informations_enabled() && $this->config->are_informations_bottom(), 'C_INFORMATIONS_SIDE' => $this->config->are_informations_enabled() && ($this->config->are_informations_left() || $this->config->are_informations_right()), 'INFORMATIONS' => FormatingHelper::second_parse($this->config->get_informations())));
 }
 public function synchronize()
 {
     $this->messages = array();
     $items_number_per_page = GuestbookConfig::load()->get_items_per_page();
     $result = PersistenceContext::get_querier()->select("SELECT g.id, g.login, g.contents, g.timestamp, m.user_id, m.display_name, m.level, m.groups\r\n\t\tFROM " . GuestbookSetup::$guestbook_table . " g\r\n\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\r\n\t\tGROUP BY g.id\r\n\t\tORDER BY RAND()\r\n\t\tLIMIT 50");
     $page = $i = 1;
     foreach ($result as $msg) {
         if ($i > $page * $items_number_per_page) {
             $page++;
         }
         $this->messages[$msg['id']] = array('id' => $msg['id'], 'contents' => strip_tags(FormatingHelper::second_parse($msg['contents'])), 'user_id' => $msg['user_id'], 'login' => $msg['display_name'] ? $msg['display_name'] : $msg['login'], 'level' => $msg['level'], 'groups' => $msg['groups'], 'timestamp' => $msg['timestamp'], 'page' => $page);
         $i++;
     }
     $result->dispose();
 }
    public function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (CalendarService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $now = new Date();
            $lang = LangLoader::get('common', 'calendar');
            $querier = PersistenceContext::get_querier();
            $category = CalendarService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = $lang['calendar.feed.name'];
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('calendar', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = CalendarService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $result = $querier->select('SELECT *
			FROM ' . CalendarSetup::$calendar_events_table . ' event
			LEFT JOIN ' . CalendarSetup::$calendar_events_content_table . ' event_content ON event_content.id = event.content_id
			LEFT JOIN ' . DB_TABLE_MEMBER . ' member ON member.user_id = event_content.author_id
			LEFT JOIN ' . CalendarSetup::$calendar_cats_table . ' cat ON cat.id = event_content.id_category
			WHERE approved = 1
			AND id_category IN :cats_ids
			ORDER BY start_date DESC', array('cats_ids' => $ids_categories));
            while ($row = $result->fetch()) {
                $event = new CalendarEvent();
                $event->set_properties($row);
                $category = $categories[$event->get_content()->get_category_id()];
                $link = CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name() ? $category->get_rewrited_name() : 'root', $event->get_id(), $event->get_content()->get_rewrited_title());
                $item = new FeedItem();
                $item->set_title($event->get_content()->get_title());
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($event->get_content()->get_contents()) . ($event->get_content()->get_location() ? '<br />' . $lang['calendar.labels.location'] . ' : ' . $event->get_content()->get_location() . '<br />' : '') . '<br />' . $lang['calendar.labels.start_date'] . ' : ' . $event->get_start_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE) . '<br />' . $lang['calendar.labels.end_date'] . ' : ' . $event->get_end_date()->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE));
                $item->set_date($event->get_start_date());
                $item->set_auth(CalendarService::get_categories_manager()->get_heritated_authorizations($category->get_id(), Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $result->dispose();
            return $data;
        }
    }
    function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (MediaService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            require_once PATH_TO_ROOT . '/media/media_constant.php';
            $category = MediaService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = LangLoader::get_message('module_title', 'common', 'media');
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('media', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = MediaService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $results = PersistenceContext::get_querier()->select('SELECT media.*, cat.image
				FROM ' . MediaSetup::$media_table . ' media
				LEFT JOIN ' . MediaSetup::$media_cats_table . ' cat ON cat.id = media.idcat
				WHERE media.idcat IN :ids_categories
				AND infos = :status_approved
				ORDER BY timestamp DESC', array('ids_categories' => $ids_categories, 'status_approved' => MEDIA_STATUS_APROBED));
            foreach ($results as $row) {
                // Rewriting
                $link = new Url('/media/media' . url('.php?id=' . $row['id'], '-' . $row['id'] . '+' . Url::encode_rewrite($row['name']) . '.php'));
                $item = new FeedItem();
                $item->set_title($row['name']);
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($row['contents']));
                $item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE));
                $item->set_image_url($row['image']);
                $item->set_auth(MediaService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $enclosure = new FeedItemEnclosure();
                $enclosure->set_lenght(@filesize($row['url']));
                $enclosure->set_type($row['mime_type']);
                $enclosure->set_url($row['url']);
                $item->set_enclosure($enclosure);
                $data->add_item($item);
            }
            $results->dispose();
            return $data;
        }
    }
 private function build_children_view($template, $categories, $id_parent)
 {
     foreach ($categories as $id => $category) {
         if ($category->get_id_parent() == $id_parent && $id != Category::ROOT_CATEGORY) {
             $description = '';
             if (method_exists($category, 'get_description')) {
                 $description = FormatingHelper::second_parse($category->get_description());
                 $description = strlen($description) > 250 ? substr(@strip_tags($description, '<br><br/>'), 0, 250) . '...' : $description;
             }
             $description_exists = method_exists($category, 'get_description');
             $category_view = new FileTemplate('default/framework/content/categories/category.tpl');
             $category_view->add_lang($this->lang);
             $category_view->put_all(array('C_DESCRIPTION' => !empty($description), 'U_DISPLAY' => $this->get_display_category_url($category)->rel(), 'U_EDIT' => $this->get_edit_category_url($category)->rel(), 'U_DELETE' => $this->get_delete_category_url($category)->rel(), 'ID' => $id, 'NAME' => $category->get_name(), 'DESCRIPTION' => $description));
             $this->build_children_view($category_view, $categories, $id);
             $template->assign_block_vars('childrens', array('child' => $category_view->render()));
         }
     }
 }
 public function execute_add_comment_event()
 {
     //Load module lang
     $lang = LangLoader::get('common', 'bugtracker');
     //Load module configuration
     $config = BugtrackerConfig::load();
     //Get the content of the comment
     $comment = stripslashes(FormatingHelper::strparse(AppContext::get_request()->get_poststring('comments_message', '')));
     //Retrieve the id of the bug
     $bug_id = $this->comments_topic->get_id_in_module();
     $now = new Date();
     //New line in the bug history
     BugtrackerService::add_history(array('bug_id' => $bug_id, 'updater_id' => AppContext::get_current_user()->get_id(), 'update_date' => $now->get_timestamp(), 'change_comment' => $lang['notice.new_comment']));
     //Send a PM to the list of members who updated the bug if the send of PM is enabled
     if ($config->are_pm_enabled() && $config->are_pm_comment_enabled()) {
         BugtrackerPMService::send_PM_to_updaters('comment', $bug_id, $comment);
     }
     return true;
 }
 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 = '')
    {
        if (ArticlesService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $querier = PersistenceContext::get_querier();
            $category = ArticlesService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = LangLoader::get_message('articles.feed_name', 'common', 'articles');
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('articles', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = ArticlesService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $now = new Date();
            $results = $querier->select('SELECT articles.id, articles.id_category, articles.title, articles.rewrited_title, articles.picture_url, 
			articles.contents, articles.description, articles.date_created, cat.rewrited_name AS rewrited_name_cat
			FROM ' . ArticlesSetup::$articles_table . ' articles
			LEFT JOIN ' . ArticlesSetup::$articles_cats_table . ' cat ON cat.id = articles.id_category
			WHERE articles.id_category IN :cats_ids
			AND (published = 1 OR (published = 2 AND publishing_start_date < :timestamp_now AND (publishing_end_date > :timestamp_now OR publishing_end_date = 0)))
			ORDER BY articles.date_created DESC', array('cats_ids' => $ids_categories, 'timestamp_now' => $now->get_timestamp()));
            foreach ($results as $row) {
                $row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root';
                $link = ArticlesUrlBuilder::display_article($row['id_category'], $row['rewrited_name_cat'], $row['id'], $row['rewrited_title']);
                $item = new FeedItem();
                $item->set_title($row['title']);
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($row['contents']));
                $item->set_date(new Date($row['date_created'], Timezone::SERVER_TIMEZONE));
                $item->set_image_url($row['picture_url']);
                $item->set_auth(ArticlesService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $results->dispose();
            return $data;
        }
    }
Пример #12
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;
 }
Пример #13
0
    public function get_feed_data_struct($idcat = 0, $name = '')
    {
        if (FaqService::get_categories_manager()->get_categories_cache()->category_exists($idcat)) {
            $querier = PersistenceContext::get_querier();
            $category = FaqService::get_categories_manager()->get_categories_cache()->get_category($idcat);
            $site_name = GeneralConfig::load()->get_site_name();
            $site_name = $idcat != Category::ROOT_CATEGORY ? $site_name . ' : ' . $category->get_name() : $site_name;
            $feed_module_name = LangLoader::get_message('module_title', 'common', 'faq');
            $data = new FeedData();
            $data->set_title($feed_module_name . ' - ' . $site_name);
            $data->set_date(new Date());
            $data->set_link(SyndicationUrlBuilder::rss('faq', $idcat));
            $data->set_host(HOST);
            $data->set_desc($feed_module_name . ' - ' . $site_name);
            $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
            $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
            $categories = FaqService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
            $ids_categories = array_keys($categories);
            $results = $querier->select('SELECT faq.id, faq.id_category, faq.question, faq.answer, faq.creation_date, cat.rewrited_name AS rewrited_name_cat
				FROM ' . FaqSetup::$faq_table . ' faq
				LEFT JOIN ' . FaqSetup::$faq_cats_table . ' cat ON cat.id = faq.id_category
				WHERE approved = 1
				AND faq.id_category IN :ids_categories
				ORDER BY faq.creation_date DESC', array('ids_categories' => $ids_categories));
            foreach ($results as $row) {
                $row['rewrited_name_cat'] = !empty($row['id_category']) ? $row['rewrited_name_cat'] : 'root';
                $link = FaqUrlBuilder::display($row['id_category'], $row['rewrited_name_cat'], $row['id']);
                $item = new FeedItem();
                $item->set_title($row['question']);
                $item->set_link($link);
                $item->set_guid($link);
                $item->set_desc(FormatingHelper::second_parse($row['answer']));
                $item->set_date(new Date($row['creation_date'], Timezone::SERVER_TIMEZONE));
                $item->set_auth(FaqService::get_categories_manager()->get_heritated_authorizations($row['id_category'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
                $data->add_item($item);
            }
            $results->dispose();
            return $data;
        }
    }
Пример #14
0
    public function get_feed_data_struct($idcat = 0, $name = '')
    {
        $config = ForumConfig::load();
        $category = ForumService::get_categories_manager()->get_categories_cache()->get_category($idcat);
        $data = new FeedData();
        $data->set_title(LangLoader::get_message('xml_forum_desc', 'common', 'forum'));
        $data->set_date(new Date());
        $data->set_link(DispatchManager::get_url('/syndication', '/rss/forum/' . $idcat . '/'));
        $data->set_host(HOST);
        $data->set_desc(LangLoader::get_message('xml_forum_desc', 'common', 'forum'));
        $data->set_lang(LangLoader::get_message('xml_lang', 'main'));
        $data->set_auth_bit(Category::READ_AUTHORIZATIONS);
        $categories = ForumService::get_categories_manager()->get_childrens($idcat, new SearchCategoryChildrensOptions(), true);
        $ids_categories = array_keys($categories);
        $results = PersistenceContext::get_querier()->select('SELECT t.id, t.idcat, t.title, t.last_timestamp, t.last_msg_id, t.display_msg, t.nbr_msg AS t_nbr_msg, msg.id mid, msg.contents
			FROM ' . PREFIX . 'forum_topics t
			LEFT JOIN ' . PREFIX . 'forum_msg msg ON msg.id = t.last_msg_id
			WHERE t.idcat IN :ids_categories
			ORDER BY t.last_timestamp DESC LIMIT :limit OFFSET 0', array('ids_categories' => $ids_categories, 'limit' => 2 * $config->get_number_messages_per_page()));
        foreach ($results as $row) {
            $item = new FeedItem();
            //Link
            $last_page = ceil($row['t_nbr_msg'] / $config->get_number_messages_per_page());
            $last_page_rewrite = $last_page > 1 ? '-' . $last_page : '';
            $last_page = $last_page > 1 ? 'pt=' . $last_page . '&amp;' : '';
            $link = new Url('/forum/topic' . url('.php?' . $last_page . 'id=' . $row['id'], '-' . $row['id'] . $last_page_rewrite . '+' . Url::encode_rewrite($row['title']) . '.php') . '#m' . $row['last_msg_id']);
            $item->set_title(($config->is_message_before_topic_title_displayed() && !empty($row['display_msg']) ? TextHelper::html_entity_decode($config->get_message_before_topic_title(), ENT_NOQUOTES) . ' ' : '') . stripslashes($row['title']));
            $item->set_link($link);
            $item->set_guid($link);
            $item->set_desc(FormatingHelper::second_parse($row['contents']));
            $item->set_date(new Date($row['last_timestamp'], Timezone::SERVER_TIMEZONE));
            $item->set_auth(ForumService::get_categories_manager()->get_heritated_authorizations($row['idcat'], Category::READ_AUTHORIZATIONS, Authorizations::AUTH_PARENT_PRIORITY));
            $data->add_item($item);
        }
        $results->dispose();
        return $data;
    }
Пример #15
0
    function get_feed_data_struct($idcat = 0, $name = '')
    {
        global $LANG;
        $querier = PersistenceContext::get_querier();
        $pages_config = PagesConfig::load();
        if (!defined('READ_PAGE')) {
            require_once PATH_TO_ROOT . '/pages/pages_defines.php';
        }
        load_module_lang('pages');
        $data = new FeedData();
        $data->set_title($LANG['pages_rss_desc']);
        $data->set_date(new Date());
        $data->set_link(SyndicationUrlBuilder::rss('pages', $idcat));
        $data->set_host(HOST);
        $data->set_desc($LANG['pages_rss_desc']);
        $data->set_lang($LANG['xml_lang']);
        $data->set_auth_bit(READ_PAGE);
        $where_clause = !empty($idcat) ? ' WHERE p.id_cat = :idcat' : '';
        $results = $querier->select('SELECT p.*
			FROM ' . PREFIX . 'pages p ' . $where_clause . '
			ORDER BY p.timestamp DESC LIMIT :limit OFFSET 0', array('idcat' => $idcat, 'limit' => 10));
        // Generation of the feed's items
        foreach ($results as $row) {
            $item = new FeedItem();
            $link = new Url(PagesUrlBuilder::get_link_item($row['encoded_title']));
            $item->set_title(stripslashes($row['title']));
            $item->set_link($link);
            $item->set_guid($link);
            $item->set_desc(preg_replace('`\\[page\\](.+)\\[/page\\]`U', '<br /><strong>$1</strong><hr />', FormatingHelper::second_parse($row['contents'])));
            $item->set_date(new Date($row['timestamp'], Timezone::SERVER_TIMEZONE));
            $item->set_auth(empty($row['auth']) ? $pages_config->get_authorizations() : unserialize($row['auth']));
            $data->add_item($item);
        }
        $results->dispose();
        return $data;
    }
 public function execute(HTTPRequestCustom $request)
 {
     if ($this->check_authorizations()) {
         $pseudo = TextHelper::strprotect(utf8_decode($request->get_string('pseudo', '')));
         $contents = TextHelper::htmlentities($request->get_string('contents', ''), ENT_COMPAT, 'UTF-8');
         $contents = TextHelper::htmlspecialchars_decode(TextHelper::html_entity_decode($contents, ENT_COMPAT, 'windows-1252'));
         if ($pseudo && $contents) {
             //Mod anti-flood, autorisé aux membres qui bénificie de l'autorisation de flooder.
             $check_time = AppContext::get_current_user()->get_id() !== -1 && ContentManagementConfig::load()->is_anti_flood_enabled() ? PersistenceContext::get_querier()->get_column_value(PREFIX . "shoutbox", 'MAX(timestamp)', 'WHERE user_id = :id', array('id' => AppContext::get_current_user()->get_id())) : '';
             if (!empty($check_time) && !AppContext::get_current_user()->check_max_value(AUTH_FLOOD)) {
                 if ($check_time >= time() - ContentManagementConfig::load()->get_anti_flood_duration()) {
                     $code = -1;
                 }
             }
             //Vérifie que le message ne contient pas du flood de lien.
             $config_shoutbox = ShoutboxConfig::load();
             $contents = FormatingHelper::strparse($contents, $config_shoutbox->get_forbidden_formatting_tags());
             if (!TextHelper::check_nbr_links($contents, $config_shoutbox->get_max_links_number_per_message(), true)) {
                 //Nombre de liens max dans le message.
                 $code = -2;
             }
             $shoutbox_message = new ShoutboxMessage();
             $shoutbox_message->init_default_properties();
             $shoutbox_message->set_login($pseudo);
             $shoutbox_message->set_user_id(AppContext::get_current_user()->get_id());
             $shoutbox_message->set_contents($contents);
             $shoutbox_message->set_creation_date(new Date());
             $code = ShoutboxService::add($shoutbox_message);
         } else {
             $code = -3;
         }
     } else {
         $code = -4;
     }
     return new JSONResponse(array('code' => $code));
 }
Пример #17
0
        DispatchManager::redirect($error_controller);
    }
    $num_rows = !empty($page_infos['title']) ? 1 : 0;
    if ($page_infos['redirect'] > 0) {
        $redirect_title = stripslashes($page_infos['title']);
        $redirect_id = $page_infos['id'];
        try {
            $page_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . 'pages', array('id', 'title', 'auth', 'is_cat', 'id_cat', 'hits', 'count_hits', 'activ_com', 'redirect', 'contents'), 'WHERE id = :id', array('id' => $page_infos['redirect']));
        } catch (RowNotFoundException $e) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
    } else {
        $redirect_title = '';
    }
    //Autorisation particulière ?
    $special_auth = !empty($page_infos['auth']);
    $array_auth = unserialize($page_infos['auth']);
    //Vérification de l'autorisation de voir la page
    if ($special_auth && !AppContext::get_current_user()->check_auth($array_auth, READ_PAGE) || !$special_auth && !AppContext::get_current_user()->check_auth($pages_config->get_authorizations(), READ_PAGE)) {
        AppContext::get_response()->redirect(HOST . DIR . url('/pages/pages.php?error=e_auth'));
    }
}
if (empty($page_infos['id'])) {
    exit;
}
require_once PATH_TO_ROOT . '/kernel/header_no_display.php';
$template = new FileTemplate('framework/content/print.tpl');
$template->put_all(array('PAGE_TITLE' => stripslashes($page_infos['title']) . ' - ' . GeneralConfig::load()->get_site_name(), 'TITLE' => stripslashes($page_infos['title']), 'L_XML_LANGUAGE' => $LANG['xml_lang'], 'CONTENT' => FormatingHelper::second_parse($page_infos['contents'])));
$template->display();
require_once PATH_TO_ROOT . '/kernel/footer_no_display.php';
Пример #18
0
		WHERE user_id = :user_id', array('user_id' => $contribution->get_poster_id()))->fetch();
    $contributor_group_color = User::get_group_color($contributor['groups'], $contributor['level']);
    $template->put_all(array('C_WRITE_AUTH' => AppContext::get_current_user()->check_auth($contribution->get_auth(), Contribution::CONTRIBUTION_AUTH_BIT), 'C_UNPROCESSED_CONTRIBUTION' => $contribution->get_status() != Event::EVENT_STATUS_PROCESSED, 'C_CONTRIBUTOR_GROUP_COLOR' => !empty($contributor_group_color), 'ENTITLED' => $contribution->get_entitled(), 'DESCRIPTION' => FormatingHelper::second_parse($contribution->get_description()), 'STATUS' => $contribution->get_status_name(), 'CONTRIBUTOR' => $contributor['display_name'], 'CONTRIBUTOR_LEVEL_CLASS' => UserService::get_level_class($contributor['level']), 'CONTRIBUTOR_GROUP_COLOR' => $contributor_group_color, 'COMMENTS' => CommentsService::display($comments_topic)->render(), 'CREATION_DATE' => $contribution_creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'MODULE' => $contribution->get_module_name(), 'U_CONTRIBUTOR_PROFILE' => UserUrlBuilder::profile($contribution->get_poster_id())->rel(), 'FIXING_URL' => url(PATH_TO_ROOT . $contribution->get_fixing_url())));
    //Si la contribution a été traitée
    if ($contribution->get_status() == Event::EVENT_STATUS_PROCESSED) {
        $fixer = PersistenceContext::get_querier()->select('SELECT *
			FROM ' . DB_TABLE_MEMBER . ' member
			WHERE user_id = :user_id', array('user_id' => $contribution->get_fixer_id()))->fetch();
        $fixer_group_color = User::get_group_color($fixer['groups'], $fixer['level']);
        $template->put_all(array('C_CONTRIBUTION_FIXED' => true, 'C_FIXER_GROUP_COLOR' => !empty($fixer_group_color), 'FIXER' => $fixer['display_name'], 'FIXER_LEVEL_CLASS' => UserService::get_level_class($fixer['level']), 'FIXER_GROUP_COLOR' => $fixer_group_color, 'FIXING_DATE' => $contribution_fixing_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'U_FIXER_PROFILE' => UserUrlBuilder::profile($contribution->get_fixer_id())->rel()));
    }
    $template->put_all(array('L_CONTRIBUTION' => $LANG['contribution'], 'L_ENTITLED' => $LANG['contribution_entitled'], 'L_DESCRIPTION' => $LANG['contribution_description'], 'L_STATUS' => $LANG['contribution_status'], 'L_CONTRIBUTOR' => $LANG['contributor'], 'L_CREATION_DATE' => $LANG['contribution_creation_date'], 'L_FIXER' => $LANG['contribution_fixer'], 'L_FIXING_DATE' => $LANG['contribution_fixing_date'], 'L_MODULE' => $LANG['contribution_module'], 'L_PROCESS_CONTRIBUTION' => $LANG['process_contribution'], 'L_CONFIRM_DELETE_CONTRIBUTION' => $LANG['confirm_delete_contribution'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_UPDATE' => $LANG['update'], 'U_UPDATE' => url('contribution_panel.php?edit=' . $contribution_id), 'U_DELETE' => url('contribution_panel.php?del=' . $contribution_id . '&amp;token=' . AppContext::get_session()->get_token())));
} elseif ($id_update > 0) {
    $editor = AppContext::get_content_formatting_service()->get_default_editor();
    $editor->set_identifier('contents');
    $template->put_all(array('C_EDIT_CONTRIBUTION' => true, 'EDITOR' => $editor->display(), 'ENTITLED' => $contribution->get_entitled(), 'DESCRIPTION' => FormatingHelper::unparse($contribution->get_description()), 'CONTRIBUTION_ID' => $contribution->get_id(), 'EVENT_STATUS_UNREAD_SELECTED' => $contribution->get_status() == Event::EVENT_STATUS_UNREAD ? ' selected="selected"' : '', 'EVENT_STATUS_BEING_PROCESSED_SELECTED' => $contribution->get_status() == Event::EVENT_STATUS_BEING_PROCESSED ? ' selected="selected"' : '', 'EVENT_STATUS_PROCESSED_SELECTED' => $contribution->get_status() == Event::EVENT_STATUS_PROCESSED ? ' selected="selected"' : '', 'L_CONTRIBUTION_STATUS_UNREAD' => $LANG['contribution_status_unread'], 'L_CONTRIBUTION_STATUS_BEING_PROCESSED' => $LANG['contribution_status_being_processed'], 'L_CONTRIBUTION_STATUS_PROCESSED' => $LANG['contribution_status_processed'], 'L_CONTRIBUTION' => $LANG['contribution'], 'L_DESCRIPTION' => $LANG['contribution_description'], 'L_STATUS' => $LANG['contribution_status'], 'L_ENTITLED' => $LANG['contribution_entitled'], 'L_SUBMIT' => $LANG['submit'], 'L_PREVIEW' => $LANG['preview'], 'L_RESET' => $LANG['reset']));
} else {
    $template->put_all(array('C_CONTRIBUTION_LIST' => true));
    //Nombre de contributions
    $num_contributions = 1;
    define('CONTRIBUTIONS_PER_PAGE', 20);
    $page = AppContext::get_request()->get_getint('p', 1);
    //Gestion des critères de tri
    $criteria = retrieve(GET, 'criteria', 'current_status');
    $order = retrieve(GET, 'order', 'asc');
    if (!in_array($criteria, array('entitled', 'module', 'status', 'creation_date', 'fixing_date', 'poster_id', 'fixer_id'))) {
        $criteria = 'current_status';
    }
    $order = $order == 'desc' ? 'desc' : 'asc';
    //On liste les contributions
    foreach (ContributionService::get_all_contributions($criteria, $order) as $this_contribution) {
Пример #19
0
 }
 $user_accounts_config = UserAccountsConfig::load();
 //Avatar
 if (empty($row['user_avatar'])) {
     $user_avatar = $user_accounts_config->is_default_avatar_enabled() == '1' ? '<img src="../templates/' . AppContext::get_current_user()->get_theme() . '/images/' . $user_accounts_config->get_default_avatar_name() . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />' : '';
 } else {
     $user_avatar = '<img src="' . Url::to_rel($row['user_avatar']) . '" alt="' . LangLoader::get_message('avatar', 'user-common') . '" />';
 }
 //Affichage du nombre de message.
 if ($row['posted_msg'] >= 1) {
     $posted_msg = '<a href="' . UserUrlBuilder::messages($row['user_id'])->rel() . '" class="small">' . $LANG['message_s'] . '</a>: ' . $row['posted_msg'];
 } else {
     $posted_msg = !$is_guest ? '<a href="' . PATH_TO_ROOT . '/forum/membermsg' . url('.php?id=' . $row['user_id'], '') . '" class="small">' . $LANG['message'] . '</a>: 0' : $LANG['message'] . ': 0';
 }
 $user_sign_field = $extended_fields_cache->get_extended_field_by_field_name('user_sign');
 $tpl->assign_block_vars('list', array('C_GROUP_COLOR' => !empty($group_color), 'C_GUEST' => empty($row['display_name']), 'CONTENTS' => FormatingHelper::second_parse($row['contents']), 'DATE' => $LANG['on'] . ' ' . Date::to_format($row['timestamp'], Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'ID' => $row['id'], 'USER_RANK' => $row['warning_percentage'] < '100' || time() - $row['delay_banned'] < 0 ? $user_rank : LangLoader::get_message('banned', 'user-common'), 'USER_IMG_ASSOC' => $user_assoc_img, 'USER_AVATAR' => $user_avatar, 'USER_GROUP' => $user_groups, 'USER_DATE' => !$is_guest ? $LANG['registered_on'] . ': ' . Date::to_format($row['registered'], Date::FORMAT_DAY_MONTH_YEAR) : '', 'USER_MSG' => !$is_guest ? $posted_msg : '', 'USER_MAIL' => !empty($row['email']) && $row['show_email'] == '1' ? '<a href="mailto:' . $row['email'] . '" class="basic-button smaller">Mail</a>' : '', 'USER_SIGN' => !empty($row['user_sign']) && !empty($user_sign_field) && $user_sign_field['display'] ? '____________________<br />' . FormatingHelper::second_parse($row['user_sign']) : '', 'USER_WARNING' => $row['warning_percentage'], 'USER_PM' => !$is_guest && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL) ? '<a href="' . UserUrlBuilder::personnal_message($row['user_id'])->rel() . '" class="basic-button smaller">MP</a>' : '', 'USER_ONLINE' => '<i class="fa ' . (!empty($row['connect']) ? 'fa-online' : 'fa-offline') . '"></i>', 'USER_PSEUDO' => !empty($row['display_name']) ? wordwrap(TextHelper::html_entity_decode($row['display_name']), 13, '<br />', 1) : $LANG['guest'], 'LEVEL_CLASS' => UserService::get_level_class($row['level']), 'GROUP_COLOR' => $group_color, 'U_USER_PROFILE' => UserUrlBuilder::profile($row['user_id'])->rel(), 'U_VARS_ANCRE' => url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php'), 'U_FORUM_CAT' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/forum' . url('.php?id=' . $row['idcat'], '-' . $row['idcat'] . $rewrited_cat_title . '.php') . '">' . $row['name'] . '</a>', 'U_TITLE_T' => '<a class="forum-mbrmsg-links" href="' . PATH_TO_ROOT . '/forum/topic' . url('.php?id=' . $row['idtopic'], '-' . $row['idtopic'] . $rewrited_title . '.php') . '">' . stripslashes($row['title']) . '</a>'));
 foreach ($displayed_extended_fields as $field_type) {
     $field = $extended_fields_cache->get_extended_field_by_field_name($field_type);
     if (!empty($row[$field_type]) && !empty($field) && $field['display']) {
         $button = '';
         if ($field['regex'] == 4) {
             foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) {
                 if (strstr($row[$field_type], $id)) {
                     $button = '<a href="mailto:' . $row[$field_type] . '" class="basic-button smaller"><i class="fa ' . $parameters['picture'] . '"></i> ' . $parameters['title'] . '</a>';
                 }
             }
         } else {
             if ($field['regex'] == 5) {
                 $button = '<a href="' . $row[$field_type] . '" class="basic-button smaller">' . LangLoader::get_message('regex.website', 'admin-user-common') . '</a>';
                 foreach (MemberShortTextExtendedField::$brands_pictures_list as $id => $parameters) {
                     if (strstr($row[$field_type], $id)) {
Пример #20
0
 public function get_array_tpl_vars()
 {
     $category = $this->get_category();
     $contents = FormatingHelper::second_parse($this->contents);
     $description = $this->get_real_short_contents();
     $user = $this->get_author_user();
     $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
     $number_comments = CommentsService::get_number_comments('download', $this->id);
     return array('C_VISIBLE' => $this->is_visible(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_READ_MORE' => !$this->is_short_contents_enabled() && $description != $contents && strlen($description) >= DownloadConfig::NUMBER_CARACTERS_BEFORE_CUT, 'C_SIZE' => !empty($this->size), 'C_PICTURE' => $this->has_picture(), 'C_CUSTOM_AUTHOR_DISPLAY_NAME' => $this->is_author_display_name_enabled(), 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'C_UPDATED_DATE' => $this->has_updated_date(), 'ID' => $this->id, 'NAME' => $this->name, 'SIZE' => $this->formated_size, 'CONTENTS' => $contents, 'DESCRIPTION' => $description, 'DATE' => $this->creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'DATE_DAY' => $this->creation_date->get_day(), 'DATE_MONTH' => $this->creation_date->get_month(), 'DATE_YEAR' => $this->creation_date->get_year(), 'DATE_DAY_MONTH' => $this->creation_date->format(Date::FORMAT_DAY_MONTH), 'DATE_ISO8601' => $this->creation_date->format(Date::FORMAT_ISO8601), 'UPDATED_DATE' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_DAY_MONTH_YEAR) : '', 'UPDATED_DATE_ISO8601' => $this->updated_date !== null ? $this->updated_date->format(Date::FORMAT_ISO8601) : '', 'STATUS' => $this->get_status(), 'CUSTOM_AUTHOR_DISPLAY_NAME' => $this->author_display_name, 'C_AUTHOR_EXIST' => $user->get_id() !== User::VISITOR_LEVEL, 'PSEUDO' => $user->get_display_name(), 'USER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'USER_GROUP_COLOR' => $user_group_color, 'NUMBER_DOWNLOADS' => $this->number_downloads, 'L_DOWNLOADED_TIMES' => StringVars::replace_vars(LangLoader::get_message('downloaded_times', 'common', 'download'), array('number_downloads' => $this->number_downloads)), 'STATIC_NOTATION' => NotationService::display_static_image($this->get_notation()), 'NOTATION' => NotationService::display_active_image($this->get_notation()), 'C_COMMENTS' => !empty($number_comments), 'L_COMMENTS' => CommentsService::get_lang_comments('download', $this->id), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('download', $this->id), 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_DESCRIPTION' => $category->get_description(), 'CATEGORY_IMAGE' => $category->get_image()->rel(), 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? DownloadUrlBuilder::configuration()->rel() : DownloadUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('download', $this->id_category)->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($this->get_author_user()->get_id())->rel(), 'U_LINK' => DownloadUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel(), 'U_DOWNLOAD' => DownloadUrlBuilder::download($this->id)->rel(), 'U_DEADLINK' => DownloadUrlBuilder::dead_link($this->id)->rel(), 'U_CATEGORY' => DownloadUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())->rel(), 'U_EDIT' => DownloadUrlBuilder::edit($this->id)->rel(), 'U_DELETE' => DownloadUrlBuilder::delete($this->id)->rel(), 'U_PICTURE' => $this->get_picture()->rel(), 'U_COMMENTS' => DownloadUrlBuilder::display_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->rewrited_name)->rel());
 }
Пример #21
0
* 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();
    }
}
if (empty($article_infos['id'])) {
    exit;
}
require_once PATH_TO_ROOT . '/kernel/header_no_display.php';
$template = new FileTemplate('framework/content/print.tpl');
$template->put_all(array('PAGE_TITLE' => stripslashes($article_infos['title']) . ($config->get_wiki_name() ? $config->get_wiki_name() : $LANG['wiki']), 'TITLE' => stripslashes($article_infos['title']), 'L_XML_LANGUAGE' => $LANG['xml_lang'], 'CONTENT' => FormatingHelper::second_parse($article_infos['content'])));
$template->display();
require_once PATH_TO_ROOT . '/kernel/footer_no_display.php';
Пример #22
0
$error = '';
$tpl = new FileTemplate('wiki/post.tpl');
$captcha = AppContext::get_captcha_service()->get_default_factory();
if (!empty($contents)) {
    include_once '../wiki/wiki_functions.php';
    //On crée le menu des paragraphes et on enregistre le menu
    $menu = '';
    //Si on détecte la syntaxe des menus alors on lance les fonctions, sinon le menu sera vide et non affiché
    if (preg_match('`[\\-]{2,6}`isU', $contents)) {
        $menu_list = wiki_explode_menu($contents);
        //On éclate le menu en tableaux
        $menu = wiki_display_menu($menu_list);
        //On affiche le menu
    }
    if ($preview) {
        $tpl->assign_block_vars('preview', array('CONTENTS' => FormatingHelper::second_parse(wiki_no_rewrite(stripslashes($contents))), 'TITLE' => stripslashes($title)));
        if (!empty($menu)) {
            $tpl->assign_block_vars('preview.menu', array('MENU' => $menu));
        }
    } else {
        if ($id_edit > 0) {
            try {
                $article_infos = PersistenceContext::get_querier()->select_single_row(PREFIX . "wiki_articles", array('encoded_title', 'auth'), 'WHERE id = :id', array('id' => $id_edit));
            } catch (RowNotFoundException $e) {
                $error_controller = PHPBoostErrors::unexisting_page();
                DispatchManager::redirect($error_controller);
            }
            //Autorisations
            $general_auth = empty($article_infos['auth']) ? true : false;
            $article_auth = !empty($article_infos['auth']) ? unserialize($article_infos['auth']) : array();
            if (!((!$general_auth || AppContext::get_current_user()->check_auth($config->get_authorizations(), WIKI_EDIT)) && ($general_auth || AppContext::get_current_user()->check_auth($article_auth, WIKI_EDIT)))) {
    private function build_form()
    {
        $security_config = SecurityConfig::load();
        $form = new HTMLForm(__CLASS__);
        $this->member_extended_fields_service = new MemberExtendedFieldsService($form);
        $fieldset = new FormFieldsetHTML('registration', $this->lang['registration']);
        $form->add_fieldset($fieldset);
        $fieldset->add_field(new FormFieldHTML('validation_method', $this->get_accounts_validation_method_explain()));
        $fieldset->add_field(new FormFieldTextEditor('display_name', $this->lang['display_name'], '', array('maxlength' => 100, 'required' => true, 'description' => $this->lang['display_name.explain'], 'events' => array('blur' => '
				if (!HTMLForms.getField("login").getValue() && HTMLForms.getField("display_name").validate() == "") {
					HTMLForms.getField("login").setValue(HTMLForms.getField("display_name").getValue().replace(/\\s/g, \'\'));
					HTMLForms.getField("login").enableValidationMessage();
					HTMLForms.getField("login").liveValidate();
				}')), array(new FormFieldConstraintLengthRange(3, 100), new FormFieldConstraintDisplayNameExists())));
        $fieldset->add_field($email = new FormFieldMailEditor('email', $this->lang['email'], '', array('required' => true), array(new FormFieldConstraintMailExist())));
        $fieldset->add_field(new FormFieldCheckbox('user_hide_mail', $this->lang['email.hide'], FormFieldCheckbox::CHECKED));
        $fieldset->add_field(new FormFieldCheckbox('custom_login', $this->lang['login.custom'], false, array('description' => $this->lang['login.custom.explain'], 'events' => array('click' => '
				if (HTMLForms.getField("custom_login").getValue()) {
					HTMLForms.getField("login").enable();
				} else { 
					HTMLForms.getField("login").disable();
				}'))));
        $fieldset->add_field($login = new FormFieldTextEditor('login', $this->lang['login'], '', array('hidden' => true, 'maxlength' => 25), array(new FormFieldConstraintLengthRange(3, 25), new FormFieldConstraintPHPBoostAuthLoginExists())));
        $fieldset->add_field($password = new FormFieldPasswordEditor('password', $this->lang['password'], '', array('description' => StringVars::replace_vars($this->lang['password.explain'], array('number' => $security_config->get_internal_password_min_length())), 'required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $fieldset->add_field($password_bis = new FormFieldPasswordEditor('password_bis', $this->lang['password.confirm'], '', array('required' => true, 'maxlength' => 500), array(new FormFieldConstraintLengthMin($security_config->get_internal_password_min_length()), new FormFieldConstraintPasswordStrength())));
        $form->add_constraint(new FormConstraintFieldsEquality($password, $password_bis));
        if ($security_config->are_login_and_email_forbidden_in_password()) {
            $form->add_constraint(new FormConstraintFieldsInequality($email, $password));
            $form->add_constraint(new FormConstraintFieldsInequality($login, $password));
        }
        $options_fieldset = new FormFieldsetHTML('options', LangLoader::get_message('options', 'main'));
        $form->add_fieldset($options_fieldset);
        $options_fieldset->add_field(new FormFieldTimezone('timezone', $this->lang['timezone.choice'], GeneralConfig::load()->get_site_timezone(), array('description' => $this->lang['timezone.choice.explain'])));
        if (count(ThemesManager::get_activated_and_authorized_themes_map()) > 1) {
            $options_fieldset->add_field(new FormFieldThemesSelect('theme', $this->lang['theme'], $this->user_accounts_config->get_default_theme(), array('check_authorizations' => true, 'events' => array('change' => $this->build_javascript_picture_themes()))));
            $options_fieldset->add_field(new FormFieldFree('preview_theme', $this->lang['theme.preview'], '<img id="img_theme" src="' . $this->get_picture_theme() . '" title="' . $this->lang['theme.preview'] . '" alt="' . $this->lang['theme.preview'] . '" class="preview-img" />'));
        }
        $options_fieldset->add_field(new FormFieldEditors('text-editor', $this->lang['text-editor'], ContentFormattingConfig::load()->get_default_editor()));
        $options_fieldset->add_field(new FormFieldLangsSelect('lang', $this->lang['lang'], $this->user_accounts_config->get_default_lang(), array('check_authorizations' => true)));
        $this->member_extended_fields_service->display_form_fields();
        $agreement_text = FormatingHelper::second_parse($this->user_accounts_config->get_registration_agreement());
        if (!empty($agreement_text)) {
            $agreement_fieldset = new FormFieldsetHTML('agreement_fieldset', $this->lang['agreement']);
            $form->add_fieldset($agreement_fieldset);
            $agreement = new FormFieldHTML('agreement.required', $this->lang['agreement.agree.required'] . '<br /><br />');
            $agreement_fieldset->add_field($agreement);
            $agreement = new FormFieldHTML('agreement', '<div id="id-message-helper" class="notice user-agreement">' . $agreement_text . '</div>');
            $agreement_fieldset->add_field($agreement);
            $agreement_fieldset->add_field(new FormFieldCheckbox('agree', $this->lang['agreement.agree'], FormFieldCheckbox::UNCHECKED, array('required' => $this->lang['agreement.agree.required'])));
        }
        $this->submit_button = new FormButtonDefaultSubmit();
        $form->add_button($this->submit_button);
        $form->add_button(new FormButtonReset());
        $this->form = $form;
    }
Пример #24
0
 public function get_array_tpl_vars()
 {
     $category = $this->get_category();
     $user = $this->get_author_user();
     $user_group_color = User::get_group_color($user->get_groups(), $user->get_level(), true);
     return array('C_APPROVED' => $this->is_approved(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_USER_GROUP_COLOR' => !empty($user_group_color), 'ID' => $this->id, 'QUESTION' => $this->question, 'ANSWER' => FormatingHelper::second_parse($this->answer), 'DATE' => $this->creation_date->format(Date::FORMAT_DAY_MONTH_YEAR), 'DATE_ISO8601' => $this->creation_date->format(Date::FORMAT_ISO8601), 'C_AUTHOR_EXIST' => $user->get_id() !== User::VISITOR_LEVEL, 'PSEUDO' => $user->get_display_name(), 'USER_LEVEL_CLASS' => UserService::get_level_class($user->get_level()), 'USER_GROUP_COLOR' => $user_group_color, 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_DESCRIPTION' => $category->get_description(), 'CATEGORY_IMAGE' => $category->get_image()->rel(), 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? FaqUrlBuilder::configuration()->rel() : FaqUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('faq', $this->id_category)->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($this->get_author_user()->get_id())->rel(), 'U_LINK' => FaqUrlBuilder::display($category->get_id(), $category->get_rewrited_name(), $this->id)->rel(), 'U_CATEGORY' => FaqUrlBuilder::display_category($category->get_id(), $category->get_rewrited_name())->rel(), 'U_EDIT' => FaqUrlBuilder::edit($this->id)->rel(), 'U_DELETE' => FaqUrlBuilder::delete($this->id)->rel());
 }
    private function build_view()
    {
        global $LANG, $Bread_crumb;
        load_module_lang('gallery');
        $g_idpics = retrieve(GET, 'id', 0);
        $g_views = retrieve(GET, 'views', false);
        $g_notes = retrieve(GET, 'notes', false);
        $g_sort = retrieve(GET, 'sort', '');
        $g_sort = !empty($g_sort) ? 'sort=' . $g_sort : '';
        //Récupération du mode d'ordonnement.
        if (preg_match('`([a-z]+)_([a-z]+)`', $g_sort, $array_match)) {
            $g_type = $array_match[1];
            $g_mode = $array_match[2];
        } else {
            list($g_type, $g_mode) = array('date', 'desc');
        }
        $comments_topic = new GalleryCommentsTopic();
        $config = GalleryConfig::load();
        $category = $this->get_category();
        $categories = GalleryService::get_categories_manager()->get_categories_cache()->get_childrens($category->get_id());
        $authorized_categories = GalleryService::get_authorized_categories($category->get_id());
        $Gallery = new Gallery();
        $nbr_pics = $this->db_querier->count(GallerySetup::$gallery_table, 'WHERE idcat=:idcat AND aprob = 1', array('idcat' => $category->get_id()));
        $total_cat = count($categories);
        //On crée une pagination si le nombre de catégories est trop important.
        $page = AppContext::get_request()->get_getint('p', 1);
        $pagination = new ModulePagination($page, $total_cat, $config->get_categories_number_per_page());
        $pagination->set_url(new Url('/gallery/gallery.php?p=%d&amp;cat=' . $category->get_id() . '&amp;id=' . $g_idpics . '&amp;' . $g_sort));
        if ($pagination->current_page_is_empty() && $page > 1) {
            $error_controller = PHPBoostErrors::unexisting_page();
            DispatchManager::redirect($error_controller);
        }
        //Colonnes des catégories.
        $nbr_column_cats = $total_cat > $config->get_columns_number() ? $config->get_columns_number() : $total_cat;
        $nbr_column_cats = !empty($nbr_column_cats) ? $nbr_column_cats : 1;
        $column_width_cats = floor(100 / $nbr_column_cats);
        //Colonnes des images.
        $nbr_column_pics = $nbr_pics > $config->get_columns_number() ? $config->get_columns_number() : $nbr_pics;
        $nbr_column_pics = !empty($nbr_column_pics) ? $nbr_column_pics : 1;
        $column_width_pics = floor(100 / $nbr_column_pics);
        $is_admin = AppContext::get_current_user()->check_level(User::ADMIN_LEVEL);
        $is_modo = GalleryAuthorizationsService::check_authorizations($category->get_id())->moderation();
        $module_data_path = $this->tpl->get_pictures_data_path();
        $rewrite_title = Url::encode_rewrite($category->get_name());
        ##### Catégorie disponibles #####
        $nbr_cat_displayed = 0;
        if ($total_cat > 0 && empty($g_idpics)) {
            $this->tpl->put('C_GALLERY_CATS', true);
            $j = 0;
            $result = $this->db_querier->select('SELECT @id_cat:= gallery_cats.id, gallery_cats.*,
			(SELECT COUNT(*) FROM ' . GallerySetup::$gallery_table . '
				WHERE idcat IN (
					@id_cat,
					(SELECT GROUP_CONCAT(id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' WHERE id_parent = @id_cat), 
					(SELECT GROUP_CONCAT(childs.id SEPARATOR \',\') FROM ' . GallerySetup::$gallery_cats_table . ' parents
					INNER JOIN ' . GallerySetup::$gallery_cats_table . ' childs ON parents.id = childs.id_parent
					WHERE parents.id_parent = @id_cat)
				)
				AND aprob = 1
			) AS nbr_pics
			FROM ' . GallerySetup::$gallery_cats_table . ' gallery_cats
			WHERE id_parent = :id_category
			AND id IN :authorized_categories
			ORDER BY id_parent, c_order
			LIMIT :number_items_per_page OFFSET :display_from', array('id_category' => $category->get_id(), 'authorized_categories' => $authorized_categories, 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
            while ($row = $result->fetch()) {
                $category_image = new Url($row['image']);
                $this->tpl->assign_block_vars('sub_categories_list', array('C_CATEGORY_IMAGE' => !empty($row['image']), 'CATEGORY_NAME' => $row['name'], 'CATEGORY_IMAGE' => $category_image->rel(), 'PICTURES_NUMBER' => sprintf($LANG['nbr_pics_info'], $row['nbr_pics']), 'U_CATEGORY' => GalleryUrlBuilder::get_link_cat($row['id'], $row['name'])));
                $nbr_cat_displayed++;
            }
            $result->dispose();
        }
        $category_description = FormatingHelper::second_parse($category->get_description());
        $this->tpl->put_all(array('C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'C_CATEGORY_DESCRIPTION' => $category_description, 'C_SUB_CATEGORIES' => $nbr_cat_displayed > 0, 'C_SUBCATEGORIES_PAGINATION' => $pagination->has_several_pages(), 'SUBCATEGORIES_PAGINATION' => $pagination->display(), 'ARRAY_JS' => '', 'NBR_PICS' => 0, 'MAX_START' => 0, 'START_THUMB' => 0, 'END_THUMB' => 0, 'COLUMNS_NUMBER' => $nbr_column_pics, 'CATS_COLUMNS_WIDTH' => $column_width_cats, 'COLUMN_WIDTH_PICS' => $column_width_pics, 'CATEGORY_DESCRIPTION' => $category_description, 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? GalleryUrlBuilder::configuration()->rel() : GalleryUrlBuilder::edit_category($category->get_id())->rel(), 'CAT_ID' => $category->get_id(), 'DISPLAY_MODE' => $config->get_pics_enlargement_mode(), 'GALLERY' => $category->get_id() != Category::ROOT_CATEGORY ? $this->lang['module_title'] . ' - ' . $category->get_name() : $this->lang['module_title'], 'HEIGHT_MAX' => $config->get_mini_max_height(), 'WIDTH_MAX' => $column_width_pics, 'MODULE_DATA_PATH' => $module_data_path, 'L_APROB' => $LANG['aprob'], 'L_UNAPROB' => $LANG['unaprob'], 'L_FILE_FORBIDDEN_CHARS' => $LANG['file_forbidden_chars'], 'L_TOTAL_IMG' => $category->get_id() != Category::ROOT_CATEGORY ? sprintf($LANG['total_img_cat'], $nbr_pics) : '', 'L_ADD_IMG' => $LANG['add_pic'], 'L_GALLERY' => $this->lang['module_title'], 'L_CATEGORIES' => $category->get_id_parent() >= 0 ? $LANG['sub_album'] : $LANG['album'], 'L_NAME' => $LANG['name'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_MOVETO' => $LANG['moveto'], 'L_DELETE' => LangLoader::get_message('delete', 'common'), 'L_SUBMIT' => $LANG['submit'], 'L_ALREADY_VOTED' => $LANG['already_vote'], 'L_ORDER_BY' => LangLoader::get_message('sort_by', 'common') . (isset($LANG[$g_type]) ? ' ' . strtolower($LANG[$g_type]) : ''), 'L_DIRECTION' => $LANG['direction'], 'L_DISPLAY' => LangLoader::get_message('display', 'common'), 'U_INDEX' => url('.php'), 'U_BEST_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?views=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?views=1'), 'U_BEST_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?notes=1&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '.php?notes=1'), 'U_ASC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'asc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'asc'), 'U_DESC' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $category->get_id() . '&amp;sort=' . $g_type . '_' . 'desc', '-' . $category->get_id() . '.php?sort=' . $g_type . '_' . 'desc'), 'U_ORDER_BY_NAME' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=name_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=name_desc'), 'U_ORDER_BY_DATE' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=date_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=date_desc'), 'U_ORDER_BY_VIEWS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=views_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=views_desc'), 'U_ORDER_BY_NOTES' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=notes_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=notes_desc'), 'U_ORDER_BY_COM' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?sort=com_desc&amp;cat=' . $category->get_id(), '-' . $category->get_id() . '+' . $rewrite_title . '.php?sort=com_desc'), 'L_BEST_VIEWS' => $LANG['best_views'], 'L_BEST_NOTES' => $LANG['best_notes'], 'L_ASC' => $LANG['asc'], 'L_DESC' => $LANG['desc'], 'L_DATE' => LangLoader::get_message('date', 'date-common'), 'L_VIEWS' => $LANG['views'], 'L_NOTES' => LangLoader::get_message('notes', 'common'), 'L_COM' => $LANG['com_s']));
        ##### Affichage des photos #####
        if ($nbr_pics > 0) {
            switch ($g_type) {
                case 'name':
                    $sort_type = 'g.name';
                    break;
                case 'date':
                    $sort_type = 'g.timestamp';
                    break;
                case 'views':
                    $sort_type = 'g.views';
                    break;
                case 'notes':
                    $sort_type = 'notes.average_notes';
                    break;
                case 'com':
                    $sort_type = 'com.number_comments';
                    break;
                default:
                    $sort_type = 'g.timestamp';
            }
            switch ($g_mode) {
                case 'desc':
                    $sort_mode = 'DESC';
                    break;
                case 'asc':
                    $sort_mode = 'ASC';
                    break;
                default:
                    $sort_mode = 'DESC';
            }
            $g_sql_sort = ' ORDER BY ' . $sort_type . ' ' . $sort_mode;
            if ($g_views) {
                $g_sql_sort = ' ORDER BY g.views DESC';
            } elseif ($g_notes) {
                $g_sql_sort = ' ORDER BY notes.average_notes DESC';
            }
            $this->tpl->put('C_GALLERY_PICS', true);
            //Affichage d'une photo demandée.
            if (!empty($g_idpics)) {
                $info_pics = $this->db_querier->select_single_row_query("SELECT g.*, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.id = :id AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'id' => $g_idpics));
                if (!empty($info_pics['id'])) {
                    $Bread_crumb->add(stripslashes($info_pics['name']), PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $info_pics['idcat'] . '&amp;id=' . $info_pics['id'], '-' . $info_pics['idcat'] . '-' . $info_pics['id'] . '.php'));
                    //Affichage miniatures.
                    $id_previous = 0;
                    $id_next = 0;
                    $nbr_pics_display_before = floor(($nbr_column_pics - 1) / 2);
                    //Nombres de photos de chaque côté de la miniature de la photo affichée.
                    $nbr_pics_display_after = $nbr_column_pics - 1 - floor($nbr_pics_display_before);
                    list($i, $reach_pics_pos, $pos_pics, $thumbnails_before, $thumbnails_after, $start_thumbnails, $end_thumbnails) = array(0, false, 0, 0, 0, $nbr_pics_display_before, $nbr_pics_display_after);
                    $array_pics = array();
                    $array_js = 'var array_pics = new Array();';
                    $result = $this->db_querier->select("SELECT g.id, g.idcat, g.path\n\t\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t\t" . $g_sql_sort, array('idcat' => $category->get_id()));
                    while ($row = $result->fetch()) {
                        //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                        if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                            $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                        }
                        //Redimensionnement + création miniature
                        //Affichage de la liste des miniatures sous l'image.
                        $array_pics[] = '<td class="center" style="height:' . ($config->get_mini_max_height() + 16) . 'px"><span id="thumb' . $i . '"><a href="gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;sort=' . $g_sort, '-' . $row['idcat'] . '-' . $row['id'] . '.php?sort=' . $g_sort) . '#pics_max' . '"><img src="pics/thumbnails/' . $row['path'] . '" alt="' . $row['path'] . '" /></a></span></td>';
                        if ($row['id'] == $g_idpics) {
                            $reach_pics_pos = true;
                            $pos_pics = $i;
                        } else {
                            if (!$reach_pics_pos) {
                                $thumbnails_before++;
                                $id_previous = $row['id'];
                            } else {
                                $thumbnails_after++;
                                if (empty($id_next)) {
                                    $id_next = $row['id'];
                                }
                            }
                        }
                        $array_js .= 'array_pics[' . $i . '] = new Array();' . "\n";
                        $array_js .= 'array_pics[' . $i . '][\'link\'] = \'' . GalleryUrlBuilder::get_link_item($row['idcat'], $row['id']) . '#pics_max' . "';\n";
                        $array_js .= 'array_pics[' . $i . '][\'path\'] = \'' . $row['path'] . "';\n";
                        $i++;
                    }
                    $result->dispose();
                    $activ_note = $config->is_notation_enabled() && AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                    if ($activ_note) {
                        //Affichage notation.
                        $notation = new Notation();
                        $notation->set_module_name('gallery');
                        $notation->set_id_in_module($info_pics['id']);
                        $notation->set_notation_scale($config->get_notation_scale());
                        $notation->set_number_notes($info_pics['number_notes']);
                        $notation->set_average_notes($info_pics['average_notes']);
                        $notation->set_user_already_noted(!empty($info_pics['note']));
                    }
                    if ($thumbnails_before < $nbr_pics_display_before) {
                        $end_thumbnails += $nbr_pics_display_before - $thumbnails_before;
                    }
                    if ($thumbnails_after < $nbr_pics_display_after) {
                        $start_thumbnails += $nbr_pics_display_after - $thumbnails_after;
                    }
                    $html_protected_name = $info_pics['name'];
                    $comments_topic->set_id_in_module($info_pics['id']);
                    $comments_topic->set_url(new Url('/gallery/gallery.php?cat=' . $category->get_id() . '&id=' . $g_idpics . '&com=0'));
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($info_pics['id'] . 'cat', '', $info_pics['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $group_color = User::get_group_color($info_pics['groups'], $info_pics['level']);
                    //Affichage de l'image et de ses informations.
                    $this->tpl->put_all(array('C_GALLERY_PICS_MAX' => true, 'C_GALLERY_PICS_MODO' => $is_modo, 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_TITLE_ENABLED' => $config->is_title_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_NOTATION_ENABLED' => $config->is_notation_enabled(), 'ID' => $info_pics['id'], 'NAME' => '<span id="fi_' . $info_pics['id'] . '">' . stripslashes($info_pics['name']) . '</span> <span id="fi' . $info_pics['id'] . '"></span>', 'POSTOR' => '<a class="small ' . UserService::get_level_class($info_pics['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($info_pics['user_id'])->rel() . '">' . $info_pics['display_name'] . '</a>', 'DATE' => Date::to_format($info_pics['timestamp'], Date::FORMAT_DAY_MONTH_YEAR), 'VIEWS' => $info_pics['views'] + 1, 'DIMENSION' => $info_pics['width'] . ' x ' . $info_pics['height'], 'SIZE' => NumberHelper::round($info_pics['weight'] / 1024, 1), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $info_pics['id']), 'KERNEL_NOTATION' => $activ_note ? NotationService::display_active_image($notation) : '', 'COLSPAN' => $config->get_columns_number() + 2, 'CAT' => $cat_list, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'IMG_APROB' => $info_pics['aprob'] == 1 ? 'fa fa-eye-slash' : 'fa fa-eye', 'ARRAY_JS' => $array_js, 'NBR_PICS' => $i - 1, 'MAX_START' => $i - 1 - $nbr_column_pics, 'START_THUMB' => $pos_pics - $start_thumbnails > 0 ? $pos_pics - $start_thumbnails : 0, 'END_THUMB' => $pos_pics + $end_thumbnails, 'L_KB' => LangLoader::get_message('unit.kilobytes', 'common'), 'L_INFORMATIONS' => $LANG['informations'], 'L_NAME' => $LANG['name'], 'L_POSTOR' => $LANG['postor'], 'L_VIEWS' => $LANG['views'], 'L_ADD_ON' => $LANG['add_on'], 'L_DIMENSION' => $LANG['dimension'], 'L_SIZE' => $LANG['size'], 'L_NOTE' => LangLoader::get_message('note', 'common'), 'L_COM' => $LANG['com'], 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_APROB_IMG' => $info_pics['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'L_THUMBNAILS' => $LANG['thumbnails'], 'U_DEL' => url('gallery.php?del=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $info_pics['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_PREVIOUS' => $pos_pics > 0 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max"><i class="fa fa-arrow-left fa-2x"></i></a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_previous) . '#pics_max">' . $LANG['previous'] . '</a>' : '', 'U_NEXT' => $pos_pics < $i - 1 ? '<a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max">' . $LANG['next'] . '</a> <a href="' . GalleryUrlBuilder::get_link_item($category->get_id(), $id_next) . '#pics_max"><i class="fa fa-arrow-right fa-2x"></i></a>' : '', 'U_LEFT_THUMBNAILS' => $pos_pics - $start_thumbnails > 0 ? '<span id="display_left"><a href="javascript:display_thumbnails(\'left\')"><i class="fa fa-arrow-left fa-2x"></i></a></span>' : '<span id="display_left"></span>', 'U_RIGHT_THUMBNAILS' => $pos_pics - $start_thumbnails <= $i - 1 - $nbr_column_pics ? '<span id="display_right"><a href="javascript:display_thumbnails(\'right\')"><i class="fa fa-arrow-right fa-2x"></i></a></span>' : '<span id="display_right"></span>', 'U_COMMENTS' => GalleryUrlBuilder::get_link_item($info_pics['idcat'], $info_pics['id'], 0, $g_sort) . '#comments-list', 'U_IMG_MAX' => 'show_pics.php?id=' . $info_pics['id'] . '&amp;cat=' . $info_pics['idcat']));
                    //Affichage de la liste des miniatures sous l'image.
                    $i = 0;
                    foreach ($array_pics as $pics) {
                        if ($i >= $pos_pics - $start_thumbnails && $i <= $pos_pics + $end_thumbnails) {
                            $this->tpl->assign_block_vars('list_preview_pics', array('PICS' => $pics));
                        }
                        $i++;
                    }
                    //Commentaires
                    if (AppContext::get_request()->get_getint('com', 0) == 0 && $config->are_comments_enabled()) {
                        $this->tpl->put_all(array('COMMENTS' => CommentsService::display($comments_topic)->render()));
                    }
                }
            } else {
                $sort = retrieve(GET, 'sort', '');
                //On crée une pagination si le nombre de photos est trop important.
                $page = AppContext::get_request()->get_getint('pp', 1);
                $pagination = new ModulePagination($page, $nbr_pics, $config->get_pics_number_per_page());
                $pagination->set_url(new Url('/gallery/gallery.php?pp=%d' . (!empty($sort) ? '&amp;sort=' . $sort : '') . '&amp;cat=' . $category->get_id()));
                if ($pagination->current_page_is_empty() && $page > 1) {
                    $error_controller = PHPBoostErrors::unexisting_page();
                    DispatchManager::redirect($error_controller);
                }
                $this->tpl->put_all(array('C_GALLERY_MODO' => $is_modo, 'C_PICTURE_NAME_DISPLAYED' => $config->is_title_enabled(), 'C_AUTHOR_DISPLAYED' => $config->is_author_displayed(), 'C_VIEWS_COUNTER_ENABLED' => $config->is_views_counter_enabled(), 'C_COMMENTS_ENABLED' => $config->are_comments_enabled(), 'C_PAGINATION' => $pagination->has_several_pages(), 'PAGINATION' => $pagination->display(), 'L_EDIT' => LangLoader::get_message('edit', 'common'), 'L_VIEW' => $LANG['view'], 'L_VIEWS' => $LANG['views']));
                $is_connected = AppContext::get_current_user()->check_level(User::MEMBER_LEVEL);
                $j = 0;
                $result = $this->db_querier->select("SELECT g.id, g.idcat, g.name, g.path, g.timestamp, g.aprob, g.width, g.height, g.user_id, g.views, g.aprob, m.display_name, m.groups, m.level, notes.average_notes, notes.number_notes, note.note\n\t\t\t\tFROM " . GallerySetup::$gallery_table . " g\n\t\t\t\tLEFT JOIN " . DB_TABLE_MEMBER . " m ON m.user_id = g.user_id\n\t\t\t\tLEFT JOIN " . DB_TABLE_COMMENTS_TOPIC . " com ON com.id_in_module = g.id AND com.module_id = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_AVERAGE_NOTES . " notes ON notes.id_in_module = g.id AND notes.module_name = 'gallery'\n\t\t\t\tLEFT JOIN " . DB_TABLE_NOTE . " note ON note.id_in_module = g.id AND note.module_name = 'gallery' AND note.user_id = :user_id\n\t\t\t\tWHERE g.idcat = :idcat AND g.aprob = 1\n\t\t\t\t" . $g_sql_sort . "\n\t\t\t\tLIMIT :number_items_per_page OFFSET :display_from", array('user_id' => AppContext::get_current_user()->get_id(), 'idcat' => $category->get_id(), 'number_items_per_page' => $pagination->get_number_items_per_page(), 'display_from' => $pagination->get_display_from()));
                while ($row = $result->fetch()) {
                    //Si la miniature n'existe pas (cache vidé) on regénère la miniature à partir de l'image en taille réelle.
                    if (!file_exists(PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'])) {
                        $Gallery->Resize_pics(PATH_TO_ROOT . '/gallery/pics/' . $row['path']);
                    }
                    //Redimensionnement + création miniature
                    $onclick = '';
                    //Affichage de l'image en grand.
                    if ($config->get_pics_enlargement_mode() == GalleryConfig::FULL_SCREEN) {
                        $display_link = PATH_TO_ROOT . '/gallery/pics/' . $row['path'] . '" onmousedown="increment_view(' . $row['id'] . ');" title="' . str_replace('"', '', stripslashes($row['name']));
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::POPUP) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics_popup(\'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\', \'' . $row['width'] . '\', \'' . $row['height'] . '\');return false;';
                        $display_link = '';
                    } elseif ($config->get_pics_enlargement_mode() == GalleryConfig::RESIZE) {
                        $onclick = 'increment_view(' . $row['id'] . ');display_pics(' . $row['id'] . ', \'' . PATH_TO_ROOT . '/gallery/show_pics' . url('.php?id=' . $row['id'] . '&amp;cat=' . $row['idcat']) . '\');return false;';
                        $display_link = '';
                    } else {
                        $onclick = true;
                        $display_link = url('gallery.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], 'gallery-' . $row['idcat'] . '-' . $row['id'] . '.php') . '#pics_max';
                    }
                    //Liste des catégories.
                    $search_category_children_options = new SearchCategoryChildrensOptions();
                    $search_category_children_options->add_authorizations_bits(Category::READ_AUTHORIZATIONS);
                    $search_category_children_options->add_authorizations_bits(Category::WRITE_AUTHORIZATIONS);
                    $categories_tree = GalleryService::get_categories_manager()->get_select_categories_form_field($row['id'] . 'cat', '', $row['idcat'], $search_category_children_options);
                    $method = new ReflectionMethod('AbstractFormFieldChoice', 'get_options');
                    $method->setAccessible(true);
                    $categories_tree_options = $method->invoke($categories_tree);
                    $cat_list = '';
                    foreach ($categories_tree_options as $option) {
                        $cat_list .= $option->display()->render();
                    }
                    $notation = new Notation();
                    $notation->set_module_name('gallery');
                    $notation->set_notation_scale($config->get_notation_scale());
                    $notation->set_id_in_module($row['id']);
                    $notation->set_number_notes($row['number_notes']);
                    $notation->set_average_notes($row['average_notes']);
                    $notation->set_user_already_noted(!empty($row['note']));
                    $group_color = User::get_group_color($row['groups'], $row['level']);
                    $comments_topic->set_id_in_module($row['id']);
                    $html_protected_name = $row['name'];
                    $this->tpl->assign_block_vars('pics_list', array('C_IMG_APROB' => $row['aprob'] == 1, 'C_OPEN_TR' => is_int($j++ / $nbr_column_pics), 'C_CLOSE_TR' => is_int($j / $nbr_column_pics), 'ID' => $row['id'], 'APROB' => $row['aprob'], 'PATH' => $row['path'], 'NAME' => stripslashes($row['name']), 'SHORT_NAME' => TextHelper::wordwrap_html(stripslashes($row['name']), 22, ' '), 'POSTOR' => $LANG['by'] . (!empty($row['display_name']) ? ' <a class="small ' . UserService::get_level_class($row['level']) . '"' . (!empty($group_color) ? ' style="color:' . $group_color . '"' : '') . ' href="' . UserUrlBuilder::profile($row['user_id'])->rel() . '">' . $row['display_name'] . '</a>' : ' ' . $LANG['guest']), 'VIEWS' => $row['views'], 'L_VIEWS' => $row['views'] > 1 ? $LANG['views'] : $LANG['view'], 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('gallery', $row['id']), 'KERNEL_NOTATION' => $config->is_notation_enabled() && $is_connected ? NotationService::display_active_image($notation) : NotationService::display_static_image($notation), 'CAT' => $cat_list, 'ONCLICK' => $onclick, 'RENAME' => $html_protected_name, 'RENAME_CUT' => $html_protected_name, 'L_APROB_IMG' => $row['aprob'] == 1 ? $LANG['unaprob'] : $LANG['aprob'], 'U_PICTURE_LINK' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'], '-' . $row['idcat'] . '-' . $row['id'] . '.php'), 'U_PICTURE' => PATH_TO_ROOT . '/gallery/pics/thumbnails/' . $row['path'], 'U_DEL' => url('gallery.php?del=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;cat=' . $category->get_id()), 'U_MOVE' => url('gallery.php?id=' . $row['id'] . '&amp;token=' . AppContext::get_session()->get_token() . '&amp;move=\' + this.options[this.selectedIndex].value'), 'U_DISPLAY' => $display_link, 'U_COMMENTS' => PATH_TO_ROOT . '/gallery/gallery' . url('.php?cat=' . $row['idcat'] . '&amp;id=' . $row['id'] . '&amp;com=0', '-' . $row['idcat'] . '-' . $row['id'] . '.php?com=0') . '#comments-list'));
                }
                $result->dispose();
                //Création des cellules du tableau si besoin est.
                while (!is_int($j / $nbr_column_pics)) {
                    $this->tpl->assign_block_vars('end_table', array('TD_END' => '<td class="td-end" style="width:' . $column_width_pics . '%">&nbsp;</td>', 'TR_END' => is_int(++$j / $nbr_column_pics) ? '</tr>' : ''));
                }
            }
        }
    }
Пример #26
0
 public function get_array_tpl_vars()
 {
     $lang = LangLoader::get('common', 'calendar');
     $category = $this->content->get_category();
     $author = $this->content->get_author_user();
     $author_group_color = User::get_group_color($author->get_groups(), $author->get_level(), true);
     $missing_participants_number = $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() < $this->content->get_max_registered_members() ? $this->content->get_max_registered_members() - $this->get_registered_members_number() : 0;
     $registration_days_left = $this->content->get_last_registration_date() && time() < $this->content->get_last_registration_date()->get_timestamp() ? (int) (($this->content->get_last_registration_date()->get_timestamp() - time()) / 3600 / 24) : 0;
     return array('C_APPROVED' => $this->content->is_approved(), 'C_EDIT' => $this->is_authorized_to_edit(), 'C_DELETE' => $this->is_authorized_to_delete(), 'C_LOCATION' => $this->content->get_location(), 'C_BELONGS_TO_A_SERIE' => $this->belongs_to_a_serie(), 'C_PARTICIPATION_ENABLED' => $this->content->is_registration_authorized(), 'C_DISPLAY_PARTICIPANTS' => $this->content->is_authorized_to_display_registered_users(), 'C_PARTICIPANTS' => !empty($this->participants), 'C_PARTICIPATE' => $this->content->is_registration_authorized() && $this->content->is_authorized_to_register() && time() < $this->start_date->get_timestamp() && (!$this->content->get_max_registered_members() || $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() < $this->content->get_max_registered_members()) && (!$this->content->get_last_registration_date() || $this->content->is_last_registration_date_enabled() && time() < $this->content->get_last_registration_date()->get_timestamp()) && !in_array(AppContext::get_current_user()->get_id(), array_keys($this->participants)), 'C_IS_PARTICIPANT' => in_array(AppContext::get_current_user()->get_id(), array_keys($this->participants)), 'C_REGISTRATION_CLOSED' => $this->content->is_last_registration_date_enabled() && $this->content->get_last_registration_date() && time() > $this->content->get_last_registration_date()->get_timestamp(), 'C_MAX_PARTICIPANTS_REACHED' => $this->content->get_max_registered_members() > 0 && $this->get_registered_members_number() == $this->content->get_max_registered_members(), 'C_MISSING_PARTICIPANTS' => !empty($missing_participants_number) && $missing_participants_number <= 5, 'C_REGISTRATION_DAYS_LEFT' => !empty($registration_days_left) && $registration_days_left <= 5, 'C_AUTHOR_GROUP_COLOR' => !empty($author_group_color), 'C_AUTHOR_EXIST' => $author->get_id() !== User::VISITOR_LEVEL, 'ID' => $this->id, 'CONTENT_ID' => $this->content->get_id(), 'TITLE' => $this->content->get_title(), 'CONTENTS' => FormatingHelper::second_parse($this->content->get_contents()), 'LOCATION' => $this->content->get_location(), 'START_DATE' => $this->start_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'START_DATE_DAY' => $this->start_date->get_day(), 'START_DATE_MONTH' => $this->start_date->get_month(), 'START_DATE_YEAR' => $this->start_date->get_year(), 'START_DATE_HOUR' => $this->start_date->get_hours(), 'START_DATE_MINUTE' => $this->start_date->get_minutes(), 'START_DATE_ISO8601' => $this->start_date->format(Date::FORMAT_ISO8601), 'END_DATE' => $this->end_date->format(Date::FORMAT_DAY_MONTH_YEAR_HOUR_MINUTE), 'END_DATE_DAY' => $this->end_date->get_day(), 'END_DATE_MONTH' => $this->end_date->get_month(), 'END_DATE_YEAR' => $this->end_date->get_year(), 'END_DATE_HOUR' => $this->end_date->get_hours(), 'END_DATE_MINUTE' => $this->end_date->get_minutes(), 'END_DATE_ISO8601' => $this->end_date->format(Date::FORMAT_ISO8601), 'NUMBER_COMMENTS' => CommentsService::get_number_comments('calendar', $this->id), 'L_COMMENTS' => CommentsService::get_number_and_lang_comments('calendar', $this->id), 'REPEAT_NUMBER' => $this->content->get_repeat_number(), 'AUTHOR' => $author->get_display_name(), 'AUTHOR_LEVEL_CLASS' => UserService::get_level_class($author->get_level()), 'AUTHOR_GROUP_COLOR' => $author_group_color, 'L_MISSING_PARTICIPANTS' => $missing_participants_number > 1 ? StringVars::replace_vars($lang['calendar.labels.remaining_places'], array('missing_number' => $missing_participants_number)) : $lang['calendar.labels.remaining_place'], 'L_REGISTRATION_DAYS_LEFT' => $registration_days_left > 1 ? StringVars::replace_vars($lang['calendar.labels.remaining_days'], array('days_left' => $registration_days_left)) : $lang['calendar.labels.remaining_day'], 'C_ROOT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY, 'CATEGORY_ID' => $category->get_id(), 'CATEGORY_NAME' => $category->get_name(), 'CATEGORY_COLOR' => $category->get_id() != Category::ROOT_CATEGORY ? $category->get_color() : '', 'U_EDIT_CATEGORY' => $category->get_id() == Category::ROOT_CATEGORY ? CalendarUrlBuilder::configuration()->rel() : CalendarUrlBuilder::edit_category($category->get_id())->rel(), 'U_SYNDICATION' => SyndicationUrlBuilder::rss('calendar', $category->get_id())->rel(), 'U_AUTHOR_PROFILE' => UserUrlBuilder::profile($author->get_id())->rel(), 'U_LINK' => CalendarUrlBuilder::display_event($category->get_id(), $category->get_rewrited_name(), $this->id, $this->content->get_rewrited_title())->rel(), 'U_EDIT' => CalendarUrlBuilder::edit_event(!$this->parent_id ? $this->id : $this->parent_id)->rel(), 'U_DELETE' => CalendarUrlBuilder::delete_event($this->id)->rel(), 'U_SUSCRIBE' => CalendarUrlBuilder::suscribe_event($this->id)->rel(), 'U_UNSUSCRIBE' => CalendarUrlBuilder::unsuscribe_event($this->id)->rel(), 'U_COMMENTS' => CalendarUrlBuilder::display_event_comments($category->get_id(), $category->get_rewrited_name(), $this->id, $this->content->get_rewrited_title())->rel());
 }
 private function init_vars_template()
 {
     $this->view->put_all(array('C_REGISTRATION_ENABLED' => UserAccountsConfig::load()->is_registration_enabled(), 'C_USER_LOGIN' => $this->login_type == self::USER_LOGIN && !$this->maintain_config->is_under_maintenance(), 'C_ADMIN_LOGIN' => $this->login_type == self::ADMIN_LOGIN, 'C_HAS_ERROR' => $this->has_error, 'U_REGISTER' => UserUrlBuilder::registration()->rel(), 'U_FORGET_PASSWORD' => UserUrlBuilder::forget_password()->rel(), 'L_FORGET_PASSWORD' => $this->lang['forget-password'], 'LOGIN_FORM' => $this->form->display()));
     if ($this->maintain_config->is_under_maintenance()) {
         $this->init_maintain_delay();
         $this->view->put_all(array('C_MAINTAIN' => true, 'L_MAINTAIN' => FormatingHelper::second_parse($this->maintain_config->get_message())));
     }
 }
Пример #28
0
 function Update_msg($idtopic, $idmsg, $contents, $user_id_msg, $history = true)
 {
     $config = ForumConfig::load();
     //Marqueur d'édition du message?
     $edit_mark = !ForumAuthorizationsService::check_authorizations()->hide_edition_mark() ? ", timestamp_edit = '" . time() . "', user_id_edit = '" . AppContext::get_current_user()->get_id() . "'" : '';
     PersistenceContext::get_querier()->inject("UPDATE " . PREFIX . "forum_msg SET contents = '" . FormatingHelper::strparse($contents) . "'" . $edit_mark . " WHERE id = '" . $idmsg . "'");
     $nbr_msg_before = PersistenceContext::get_querier()->count(PREFIX . "forum_msg", 'WHERE idtopic = :idtopic AND id < :id', array('idtopic' => $idtopic, 'id' => $idmsg));
     //Calcul de la page sur laquelle se situe le message.
     $msg_page = ceil(($nbr_msg_before + 1) / $config->get_number_messages_per_page());
     $msg_page_rewrite = $msg_page > 1 ? '-' . $msg_page : '';
     $msg_page = $msg_page > 1 ? '&pt=' . $msg_page : '';
     //Insertion de l'action dans l'historique.
     if (AppContext::get_current_user()->get_id() != $user_id_msg && $history) {
         forum_history_collector(H_EDIT_MSG, $user_id_msg, 'topic' . url('.php?id=' . $idtopic . $msg_page, '-' . $idtopic . $msg_page_rewrite . '.php', '&') . '#m' . $idmsg);
     }
     return $nbr_msg_before;
 }
 public function parse_contents($contents)
 {
     return stripslashes(FormatingHelper::strparse($contents));
 }
 public function execute(HTTPRequestCustom $request)
 {
     $this->init();
     $this->view->put('WELCOME_MESSAGE', FormatingHelper::second_parse($this->lang['welcome_message']));
     return $this->generate_response();
 }