/** * 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 = $this->get('fork.settings')->getForModule('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'; } }
/** * 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) { // get the ids of the items linked to the tag $otherIds = (array) $this->get('database')->getColumn('SELECT other_id FROM modules_tags WHERE module = ? AND tag_id = ?', array($module, $this->record['id'])); // set module class $class = 'Frontend\\Modules\\' . $module . '\\Engine\\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); } } }
/** * Parse */ 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); }
/** * Get tags for current "page" */ private function getTags() { // get page id $pageId = $this->getContainer()->get('page')->getId(); // 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\\Modules\\' . $block['module'] . '\\Engine\\Model'; if (is_callable(array($class, 'getIdForTags'))) { // 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']); } } } }
/** * Get related items based on tags * * @param int $id * @param int $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::getContainer()->get('database')->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(LANGUAGE, 'N', (int) $limit), 'id'); foreach ($items as &$row) { $row['full_url'] = $link . '/' . $row['url']; } return $items; }
/** * 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 { // get by URL $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 = $this->get('fork.settings')->getForModule('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; } }
/** * Get related items based on tags * * @param int $id The id of the item to get related items for. * @param int $limit The maximum number of items to retrieve. * @return array */ public static function getRelated($id, $limit = 5) { $id = (int) $id; $limit = (int) $limit; // get the related IDs $relatedIDs = (array) FrontendTagsModel::getRelatedItemsByTags($id, 'Blog', 'Blog', $limit); // no items if (empty($relatedIDs)) { return array(); } // get link $link = FrontendNavigation::getURLForBlock('Blog', 'Detail'); // get items $items = (array) FrontendModel::getContainer()->get('database')->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 $items; }
/** * Get the data */ private function getData() { // validate incoming parameters if ($this->URL->getParameter(1) === null) { $this->redirect(FrontendNavigation::getURL(404)); } // get information $this->record = FrontendCatalogModel::get($this->URL->getParameter(1)); $this->comments = FrontendCatalogModel::getComments($this->record['id']); $this->specifications = FrontendCatalogModel::getProductSpecifications($this->record['id']); $this->tags = FrontendTagsModel::getForItem('Catalog', $this->record['id']); $this->settings = $this->get('fork.settings')->getForModule('Catalog'); $this->files = FrontendCatalogModel::getFiles($this->record['id']); $this->videos = FrontendCatalogModel::getVideos($this->record['id']); $this->relatedProducts = FrontendCatalogModel::getRelatedProducts($this->record['id']); $this->brand = FrontendCatalogModel::getBrand($this->record['brand_id']); $this->record['allow_comments'] = $this->record['allow_comments'] == 'Y'; $this->record['brand'] = $this->brand; $this->record['image'] = FrontendMediaHelper::getFromModule('Catalog', $this->record['id'], 0, 1, 'product'); $this->record['images'] = FrontendMediaHelper::getFromModule('Catalog', $this->record['id'], 0, 0, 'product'); // reset allow comments if (!$this->settings['allow_comments']) { $this->record['allow_comments'] = false; } // check if record is not empty if (empty($this->record)) { $this->redirect(FrontendNavigation::getURL(404)); } //--Get all the categories $this->categoriesTree = FrontendCatalogModel::getCategoriesTree(0, $this->record['category_id']); }
/** * Load the data from the database. */ private function getData() { $this->tags = FrontendTagsModel::getAll(); }