コード例 #1
0
ファイル: detail.php プロジェクト: naujasdizainas/forkcms
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // load revision
     if ($this->URL->getParameter('revision', 'int') != 0) {
         // get data
         $this->record = FrontendBlogModel::getRevision($this->URL->getParameter(1), $this->URL->getParameter('revision', 'int'));
         // add no-index, so the draft won't get accidentally indexed
         $this->header->addMetaData(array('name' => 'robots', 'content' => 'noindex, nofollow'), true);
     } else {
         $this->record = FrontendBlogModel::get($this->URL->getParameter(1));
     }
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get comments
     $this->comments = FrontendBlogModel::getComments($this->record['id']);
     // get tags
     $this->record['tags'] = FrontendTagsModel::getForItem('blog', $this->record['id']);
     // get settings
     $this->settings = FrontendModel::getModuleSettings('blog');
     // overwrite URLs
     $this->record['category_full_url'] = FrontendNavigation::getURLForBlock('blog', 'category') . '/' . $this->record['category_url'];
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('blog', 'detail') . '/' . $this->record['url'];
     $this->record['allow_comments'] = $this->record['allow_comments'] == 'Y';
     $this->record['comments_count'] = count($this->comments);
     // reset allow comments
     if (!$this->settings['allow_comments']) {
         $this->record['allow_comments'] = false;
     }
 }
コード例 #2
0
ファイル: detail.php プロジェクト: naujasdizainas/forkcms
    /**
     * Load the data, don't forget to validate the incoming data
     */
    private function getData()
    {
        // validate incoming parameters
        if ($this->URL->getParameter(1) === null) {
            $this->redirect(FrontendNavigation::getURL(404));
        }
        // fetch record
        $this->record = FrontendTagsModel::get($this->URL->getParameter(1));
        // validate record
        if (empty($this->record)) {
            $this->redirect(FrontendNavigation::getURL(404));
        }
        // fetch modules
        $this->modules = FrontendTagsModel::getModulesForTag($this->record['id']);
        // loop modules
        foreach ($this->modules as $module) {
            // set module class
            $class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
            // get the ids of the items linked to the tag
            $otherIds = (array) FrontendModel::getDB()->getColumn('SELECT other_id
				 FROM modules_tags
				 WHERE module = ? AND tag_id = ?', array($module, $this->record['id']));
            // set module class
            $class = 'Frontend' . SpoonFilter::toCamelCase($module) . 'Model';
            // get the items that are linked to the tags
            $items = (array) FrontendTagsModel::callFromInterface($module, $class, 'getForTags', $otherIds);
            // add into results array
            if (!empty($items)) {
                $this->results[] = array('name' => $module, 'label' => FL::lbl(SpoonFilter::ucfirst($module)), 'items' => $items);
            }
        }
    }
コード例 #3
0
ファイル: detail.php プロジェクト: naujasdizainas/forkcms
 /**
  * Load the data, don't forget to validate the incoming data
  */
 private function getData()
 {
     // validate incoming parameters
     if ($this->URL->getParameter(1) === null) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // get by URL
     $this->record = FrontendFaqModel::get($this->URL->getParameter(1));
     // anything found?
     if (empty($this->record)) {
         $this->redirect(FrontendNavigation::getURL(404));
     }
     // overwrite URLs
     $this->record['category_full_url'] = FrontendNavigation::getURLForBlock('faq', 'category') . '/' . $this->record['category_url'];
     $this->record['full_url'] = FrontendNavigation::getURLForBlock('faq', 'detail') . '/' . $this->record['url'];
     // get tags
     $this->record['tags'] = FrontendTagsModel::getForItem('faq', $this->record['id']);
     // get settings
     $this->settings = FrontendModel::getModuleSettings('faq');
     // reset allow comments
     if (!$this->settings['allow_feedback']) {
         $this->record['allow_feedback'] = false;
     }
     // ge status
     $this->status = $this->URL->getParameter(2);
     if ($this->status == FL::getAction('Success')) {
         $this->status = 'success';
     }
     if ($this->status == FL::getAction('Spam')) {
         $this->status = 'spam';
     }
 }
コード例 #4
0
ファイル: tagcloud.php プロジェクト: netconstructor/forkcms
 /**
  * Parse
  *
  * @return	void
  */
 private function parse()
 {
     // get categories
     $tags = FrontendTagsModel::getAll();
     // we just need the 10 first items
     $tags = array_slice($tags, 0, 10);
     // build link
     $link = FrontendNavigation::getURLForBlock('tags', 'detail');
     // any tags?
     if (!empty($tags)) {
         // loop and reset url
         foreach ($tags as &$row) {
             $row['url'] = $link . '/' . $row['url'];
         }
     }
     // assign comments
     $this->tpl->assign('widgetTagsTagCloud', $tags);
 }
コード例 #5
0
ファイル: model.php プロジェクト: netconstructor/forkcms
    /**
     * Get related items based on tags
     *
     * @return	array
     * @param	int $id					The id of the item to get related items for.
     * @param	int[optional] $limit	The maximum number of items to retrieve.
     */
    public static function getRelated($id, $limit = 5)
    {
        // redefine
        $id = (int) $id;
        $limit = (int) $limit;
        // get the related IDs
        $relatedIDs = (array) FrontendTagsModel::getRelatedItemsByTags($id, 'blog', 'blog');
        // no items
        if (empty($relatedIDs)) {
            return array();
        }
        // get link
        $link = FrontendNavigation::getURLForBlock('blog', 'detail');
        // get items
        $items = (array) FrontendModel::getDB()->getRecords('SELECT i.id, i.title, m.url
																FROM blog_posts AS i
																INNER JOIN meta AS m ON i.meta_id = m.id
																WHERE i.status = ? AND i.language = ? AND i.hidden = ? AND i.publish_on <= ? AND i.id IN(' . implode(',', $relatedIDs) . ')
																ORDER BY i.publish_on DESC, i.id DESC
																LIMIT ?', array('active', FRONTEND_LANGUAGE, 'N', FrontendModel::getUTCDate('Y-m-d H:i') . ':00', $limit), 'id');
        // loop items
        foreach ($items as &$row) {
            $row['full_url'] = $link . '/' . $row['url'];
        }
        // return
        return $items;
    }
コード例 #6
0
ファイル: index.php プロジェクト: netconstructor/forkcms
 /**
  * Load the data from the database.
  *
  * @return	void
  */
 private function getData()
 {
     $this->tags = FrontendTagsModel::getAll();
 }
コード例 #7
0
ファイル: related.php プロジェクト: naujasdizainas/forkcms
 /**
  * Get tags for current "page"
  */
 private function getTags()
 {
     // get page id
     $pageId = FrontendPage::getCurrentPageId();
     // array of excluded records
     $this->exclude[] = array('module' => 'pages', 'other_id' => $pageId);
     // get tags for page
     $tags = (array) FrontendTagsModel::getForItem('pages', $pageId);
     foreach ($tags as $tag) {
         $this->tags = array_merge((array) $this->tags, (array) $tag['name']);
     }
     // get page record
     $record = (array) FrontendNavigation::getPageInfo($pageId);
     // loop blocks
     foreach ((array) $record['extra_blocks'] as $block) {
         // set module class
         $class = 'Frontend' . SpoonFilter::toCamelCase($block['module']) . 'Model';
         // get record for module
         $record = FrontendTagsModel::callFromInterface($block['module'], $class, 'getIdForTags', $this->URL);
         // check if record exists
         if (!$record) {
             continue;
         }
         // add to excluded records
         $this->exclude[] = array('module' => $block['module'], 'other_id' => $record['id']);
         // get record's tags
         $tags = (array) FrontendTagsModel::getForItem($block['module'], $record['id']);
         foreach ($tags as $tag) {
             $this->tags = array_merge((array) $this->tags, (array) $tag['name']);
         }
     }
 }
コード例 #8
0
ファイル: model.php プロジェクト: naujasdizainas/forkcms
    /**
     * Get related items based on tags
     *
     * @param int $id
     * @param int[optional] $limit
     * @return array
     */
    public static function getRelated($id, $limit = 5)
    {
        $relatedIDs = (array) FrontendTagsModel::getRelatedItemsByTags((int) $id, 'faq', 'faq');
        // there are no items, so return an empty array
        if (empty($relatedIDs)) {
            return array();
        }
        $link = FrontendNavigation::getURLForBlock('faq', 'detail');
        $items = (array) FrontendModel::getDB()->getRecords('SELECT i.id, i.question, m.url
			 FROM faq_questions AS i
			 INNER JOIN meta AS m ON i.meta_id = m.id
			 WHERE i.language = ? AND i.hidden = ? AND i.id IN(' . implode(',', $relatedIDs) . ')
			 ORDER BY i.question
			 LIMIT ?', array(FRONTEND_LANGUAGE, 'N', (int) $limit), 'id');
        foreach ($items as &$row) {
            $row['full_url'] = $link . '/' . $row['url'];
        }
        return $items;
    }