Esempio n. 1
0
 /**
  * Affichage d'un article d'actualités.
  *
  */
 public function newsItem($aMatches)
 {
     # module actuel
     $this->okt->page->module = 'news';
     $this->okt->page->action = 'item';
     # récupération de la page en fonction du slug
     if (!empty($aMatches[0])) {
         $sPostSlug = $aMatches[0];
     } else {
         $this->serve404();
     }
     # récupération de l'article
     $rsPost = $this->okt->news->getPost($sPostSlug, 1);
     if ($rsPost->isEmpty()) {
         $this->serve404();
     }
     # is default route ?
     $bIsDefaultRoute = $this->isDefaultRoute(__CLASS__, __FUNCTION__, $sPostSlug);
     # permission de lecture ?
     if (!$this->okt->news->isPublicAccessible() || !$rsPost->isReadable()) {
         if ($this->okt->user->is_guest) {
             http::redirect(html::escapeHTML(usersHelpers::getLoginUrl($rsPost->url)));
         } else {
             $this->serve404();
         }
     }
     # meta description
     if ($rsPost->meta_description != '') {
         $this->okt->page->meta_description = $rsPost->meta_description;
     } else {
         if ($this->okt->news->config->meta_description[$this->okt->user->language] != '') {
             $this->okt->page->meta_description = $this->okt->news->config->meta_description[$this->okt->user->language];
         } else {
             $this->okt->page->meta_description = util::getSiteMetaDesc();
         }
     }
     # meta keywords
     if ($rsPost->meta_keywords != '') {
         $this->okt->page->meta_keywords = $rsPost->meta_keywords;
     } else {
         if ($this->okt->news->config->meta_keywords[$this->okt->user->language] != '') {
             $this->okt->page->meta_keywords = $this->okt->news->config->meta_keywords[$this->okt->user->language];
         } else {
             $this->okt->page->meta_keywords = util::getSiteMetaKeywords();
         }
     }
     # title tag du module
     $this->okt->page->addTitleTag($this->okt->news->getTitle());
     # début du fil d'ariane
     if (!$bIsDefaultRoute) {
         $this->okt->page->breadcrumb->add($this->okt->news->getName(), $this->okt->news->config->url);
     }
     # si les rubriques sont activées
     if ($this->okt->news->config->categories['enable'] && $rsPost->category_id) {
         # title tag de la rubrique
         $this->okt->page->addTitleTag($rsPost->category_title);
         # ajout de la hiérarchie des rubriques au fil d'ariane
         if (!$bIsDefaultRoute) {
             $rsPath = $this->okt->news->categories->getPath($rsPost->category_id, true, $this->okt->user->language);
             while ($rsPath->fetch()) {
                 $this->okt->page->breadcrumb->add($rsPath->title, newsHelpers::getCategoryUrl($rsPath->slug));
             }
             unset($rsPath);
         }
     }
     # title tag de la page
     $this->okt->page->addTitleTag($rsPost->title_tag == '' ? $rsPost->title : $rsPost->title_tag);
     # titre de la page
     $this->okt->page->setTitle($rsPost->title);
     # titre SEO de la page
     $this->okt->page->setTitleSeo($rsPost->title_seo);
     # fil d'ariane de la page
     if (!$bIsDefaultRoute) {
         $this->okt->page->breadcrumb->add($rsPost->title, $rsPost->url);
     }
     # affichage du template
     echo $this->okt->tpl->render($this->okt->news->getItemTplPath($rsPost->tpl, $rsPost->category_items_tpl), array('rsPost' => $rsPost));
 }
Esempio n. 2
0
while ($rsCategories->fetch()) {
    if (!in_array($rsCategories->id, $aChildrens)) {
        $aAllowedParents[] = new formSelectOption(str_repeat('   ', $rsCategories->level - 1) . '• ' . html::escapeHTML($rsCategories->title), $rsCategories->id);
    }
}
# button set
$okt->page->setButtonset('newsCatsBtSt', array('id' => 'news-cats-buttonset', 'type' => '', 'buttons' => array(array('permission' => true, 'title' => __('c_c_action_Go_back'), 'url' => 'module.php?m=news&action=categories', 'ui-icon' => 'arrowreturnthick-1-w'))));
if ($iCategoryId) {
    # bouton add cat
    $okt->page->addButton('newsCatsBtSt', array('permission' => true, 'title' => __('m_news_cats_add_category'), 'url' => 'module.php?m=news&action=categories&do=add', 'ui-icon' => 'plusthick'));
    # bouton switch statut
    $okt->page->addButton('newsCatsBtSt', array('permission' => true, 'title' => $aCategoryData['active'] ? __('c_c_status_Online') : __('c_c_status_Offline'), 'url' => 'module.php?m=news&action=categories&do=edit&switch_status=1&category_id=' . $iCategoryId, 'ui-icon' => $aCategoryData['active'] ? 'volume-on' : 'volume-off', 'active' => $aCategoryData['active']));
    # bouton de suppression
    $okt->page->addButton('newsCatsBtSt', array('permission' => $iCategoryNumPosts == 0, 'title' => __('c_c_action_Delete'), 'url' => 'module.php?m=news&action=categories&delete=' . $iCategoryId, 'ui-icon' => 'closethick', 'onclick' => 'return window.confirm(\'' . html::escapeJS(__('m_news_cats_delete_confirm')) . '\')'));
    # bouton vers la catégorie côté public
    $okt->page->addButton('newsCatsBtSt', array('permission' => $aCategoryData['active'] ? true : false, 'title' => __('c_c_action_Show'), 'url' => newsHelpers::getCategoryUrl($aCategoryLocalesData[$okt->user->language]['slug']), 'ui-icon' => 'extlink'));
}
# Titre de la page
$okt->page->addGlobalTitle(__('m_news_cats_categories'), 'module.php?m=news&action=categories');
if ($iCategoryId) {
    $path = $okt->news->categories->getPath($iCategoryId, true, $okt->user->language);
    while ($path->fetch()) {
        $okt->page->addGlobalTitle($path->title, 'module.php?m=news&action=categories&do=edit&category_id=' . $path->id);
    }
} else {
    $okt->page->addGlobalTitle(__('m_news_cats_add_category'));
}
# Lockable
$okt->page->lockable();
# Tabs
$okt->page->tabs();
Esempio n. 3
0
 /**
  * Retourne l'URL publique d'une rubrique
  *
  * @param string $sLanguage
  * @return string
  */
 public function getCategoryUrl($sLanguage = null)
 {
     return newsHelpers::getCategoryUrl($this->category_slug, $sLanguage);
 }