/** * 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 the data into the template */ private function parse() { // get vars $title = \SpoonFilter::ucfirst(FL::msg('BlogAllComments')); $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog'); $detailLink = SITE_URL . FrontendNavigation::getURLForBlock('Blog', 'Detail'); $description = null; // create new rss instance $rss = new FrontendRSS($title, $link, $description); // loop articles foreach ($this->items as $item) { // init vars $title = $item['author'] . ' ' . FL::lbl('On') . ' ' . $item['post_title']; $link = $detailLink . '/' . $item['post_url'] . '/#comment-' . $item['id']; $description = $item['text']; // create new instance $rssItem = new FrontendRSSItem($title, $link, $description); // set item properties $rssItem->setPublicationDate($item['created_on']); $rssItem->setAuthor($item['author']); // add item $rss->addItem($rssItem); } $rss->parse(); }
/** * Parse the data into the template */ private function parse() { // get vars $title = isset($this->settings['rss_title_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_title_' . FRONTEND_LANGUAGE] : $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE); $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog'); $description = isset($this->settings['rss_description_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_description_' . FRONTEND_LANGUAGE] : null; // create new rss instance $rss = new FrontendRSS($title, $link, $description); // loop articles foreach ($this->items as $item) { // init vars $title = $item['title']; $link = $item['full_url']; $description = $item['introduction'] != '' ? $item['introduction'] : $item['text']; // meta is wanted if ($this->get('fork.settings')->get('Blog', 'rss_meta_' . FRONTEND_LANGUAGE, true)) { // append meta $description .= '<div class="meta">' . "\n"; $description .= ' <p><a href="' . $link . '" title="' . $title . '">' . $title . '</a> ' . sprintf(FL::msg('WrittenBy'), FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname')); $description .= ' ' . FL::lbl('In') . ' <a href="' . $item['category_full_url'] . '" title="' . $item['category_title'] . '">' . $item['category_title'] . '</a>.</p>' . "\n"; // any tags if (isset($item['tags'])) { // append tags-paragraph $description .= ' <p>' . \SpoonFilter::ucfirst(FL::lbl('Tags')) . ': '; $first = true; // loop tags foreach ($item['tags'] as $tag) { // prepend separator if (!$first) { $description .= ', '; } // add $description .= '<a href="' . $tag['full_url'] . '" rel="tag" title="' . $tag['name'] . '">' . $tag['name'] . '</a>'; // reset $first = false; } // end $description .= '.</p>' . "\n"; } // end HTML $description .= '</div>' . "\n"; } // create new instance $rssItem = new FrontendRSSItem($title, $link, $description); // set item properties $rssItem->setPublicationDate($item['publish_on']); $rssItem->addCategory($item['category_title']); $rssItem->setAuthor(FrontendUser::getBackendUser($item['user_id'])->getSetting('nickname')); // add item $rss->addItem($rssItem); } // output $rss->parse(); }
public function parse() { // more matches to be found than? if ($this->pagination['num_items'] > count($this->items)) { // remove last result (to add this reference) array_pop($this->items); // add reference to full search results page $this->items[] = array('title' => FL::lbl('More'), 'text' => FL::msg('MoreResults'), 'full_url' => FrontendNavigation::getURLForBlock('Search') . '?form=search&q=' . $this->term); } $charset = $this->getContainer()->getParameter('kernel.charset'); // format data foreach ($this->items as &$item) { // format description $item['text'] = !empty($item['text']) ? mb_strlen($item['text']) > $this->length ? mb_substr(strip_tags($item['text']), 0, $this->length, $charset) . '…' : $item['text'] : ''; } // output $this->output(self::OK, $this->items); }
/** * Get the locale that is used in the frontend but doesn't exists. * * @param string $language The language to check. * @return array */ public static function getNonExistingFrontendLocale($language) { $used = array(); $finder = new Finder(); $finder->notPath('cache')->name('*.php')->name('*.tpl')->name('*.js'); // loop files foreach ($finder->files()->in(FRONTEND_PATH) as $file) { /** @var $file \SplFileInfo */ // grab content $content = $file->getContents(); // process the file based on extension switch ($file->getExtension()) { // javascript file case 'js': $matches = array(); // get matches preg_match_all('/\\{\\$(act|err|lbl|msg)(.*)(\\|.*)?\\}/iU', $content, $matches); // any matches? if (isset($matches[2])) { // loop matches foreach ($matches[2] as $key => $match) { // set type $type = $matches[1][$key]; // init if needed if (!isset($used[$match])) { $used[$type][$match] = array('files' => array()); } // add file if (!in_array($file->getRealPath(), $used[$type][$match]['files'])) { $used[$type][$match]['files'][] = $file->getRealPath(); } } } break; // PHP file // PHP file case 'php': $matches = array(); // get matches preg_match_all('/(FrontendLanguage|FL)::(get(Action|Label|Error|Message)|act|lbl|err|msg)\\(\'(.*)\'\\)/iU', $content, $matches); // any matches? if (!empty($matches[4])) { // loop matches foreach ($matches[4] as $key => $match) { $type = 'lbl'; if ($matches[3][$key] == 'Action') { $type = 'act'; } if ($matches[2][$key] == 'act') { $type = 'act'; } if ($matches[3][$key] == 'Error') { $type = 'err'; } if ($matches[2][$key] == 'err') { $type = 'err'; } if ($matches[3][$key] == 'Message') { $type = 'msg'; } if ($matches[2][$key] == 'msg') { $type = 'msg'; } // init if needed if (!isset($used[$type][$match])) { $used[$type][$match] = array('files' => array()); } // add file if (!in_array($file->getRealPath(), $used[$type][$match]['files'])) { $used[$type][$match]['files'][] = $file->getRealPath(); } } } break; // template file // template file case 'tpl': $matches = array(); // get matches preg_match_all('/\\{\\$(act|err|lbl|msg)([a-z-_]*)(\\|.*)?\\}/iU', $content, $matches); // any matches? if (isset($matches[2])) { // loop matches foreach ($matches[2] as $key => $match) { // set type $type = $matches[1][$key]; // init if needed if (!isset($used[$type][$match])) { $used[$type][$match] = array('files' => array()); } // add file if (!in_array($file->getRealPath(), $used[$type][$match]['files'])) { $used[$type][$match]['files'][] = $file->getRealPath(); } } } break; } } // init var $nonExisting = array(); // set language FL::setLocale($language); // check if the locale is present in the current language foreach ($used as $type => $items) { // loop items foreach ($items as $key => $data) { // process based on type switch ($type) { case 'act': // if the action isn't available add it to the list if (FL::act($key, false) == '{$' . $type . $key . '}') { $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files'])); } break; case 'err': // if the error isn't available add it to the list if (FL::err($key, false) == '{$' . $type . $key . '}') { $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files'])); } break; case 'lbl': // if the label isn't available add it to the list if (FL::lbl($key, false) == '{$' . $type . $key . '}') { $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files'])); } break; case 'msg': // if the message isn't available add it to the list if (FL::msg($key, false) == '{$' . $type . $key . '}') { $nonExisting['Frontend' . $key . $type] = array('language' => $language, 'application' => 'Frontend', 'module' => 'Core', 'type' => $type, 'name' => $key, 'used_in' => serialize($data['files'])); } break; } } } ksort($nonExisting); return $nonExisting; }
/** * Parse the data into the template */ private function parse() { // get RSS-link $rssTitle = $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE); $rssLink = FrontendNavigation::getURLForBlock('Blog', 'Rss'); // add RSS-feed $this->header->addRssLink($rssTitle, $rssLink); // add into breadcrumb $this->breadcrumb->addElement(\SpoonFilter::ucfirst(FL::lbl('Archive'))); $this->breadcrumb->addElement($this->year); if ($this->month !== null) { $this->breadcrumb->addElement(\SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true)); } // set pageTitle $this->header->setPageTitle(\SpoonFilter::ucfirst(FL::lbl('Archive'))); $this->header->setPageTitle($this->year); if ($this->month !== null) { $this->header->setPageTitle(\SpoonDate::getDate('F', $this->startDate, FRONTEND_LANGUAGE, true)); } // assign category $this->tpl->assign('archive', array('start_date' => $this->startDate, 'end_date' => $this->endDate, 'year' => $this->year, 'month' => $this->month)); // assign items $this->tpl->assign('items', $this->items); // assign allowComments $this->tpl->assign('allowComments', $this->get('fork.settings')->get('Blog', 'allow_comments')); // parse the pagination $this->parsePagination(); }
/** * Parse the data into the template */ private function parse() { // get RSS-link $rssTitle = $this->get('fork.settings')->get('Blog', 'rss_title_' . FRONTEND_LANGUAGE); $rssLink = FrontendNavigation::getURLForBlock('Blog', 'Rss'); // add RSS-feed $this->header->addRssLink($rssTitle, $rssLink); // add into breadcrumb $this->breadcrumb->addElement(\SpoonFilter::ucfirst(FL::lbl('Category'))); $this->breadcrumb->addElement($this->category['label']); // set pageTitle $this->header->setPageTitle(\SpoonFilter::ucfirst(FL::lbl('Category'))); $this->header->setPageTitle($this->category['label']); // advanced SEO-attributes if (isset($this->category['meta_data']['seo_index'])) { $this->header->addMetaData(array('name' => 'robots', 'content' => $this->category['meta_data']['seo_index'])); } if (isset($this->category['meta_data']['seo_follow'])) { $this->header->addMetaData(array('name' => 'robots', 'content' => $this->category['meta_data']['seo_follow'])); } // assign category $this->tpl->assign('category', $this->category); // assign articles $this->tpl->assign('items', $this->items); // parse the pagination $this->parsePagination(); }
/** * Convert this string into a well formed label. * syntax: {{ var|tolabel }}. * * @param string $value The value to convert to a label. * * @return string */ public static function toLabel($value) { return \SpoonFilter::ucfirst(Language::lbl(\SpoonFilter::toCamelCase($value, '_', false))); }
/** * Load the form */ private function loadForm() { // create form $this->frm = new FrontendForm('commentsForm'); $this->frm->setAction($this->frm->getAction() . '#' . FL::act('Comment')); // init vars $author = Cookie::exists('comment_author') ? Cookie::get('comment_author') : null; $email = Cookie::exists('comment_email') && \SpoonFilter::isEmail(Cookie::get('comment_email')) ? Cookie::get('comment_email') : null; $website = Cookie::exists('comment_website') && \SpoonFilter::isURL(Cookie::get('comment_website')) ? Cookie::get('comment_website') : 'http://'; // create elements $this->frm->addText('author', $author)->setAttributes(array('required' => null)); $this->frm->addText('email', $email)->setAttributes(array('required' => null, 'type' => 'email')); $this->frm->addText('website', $website, null); $this->frm->addTextarea('message')->setAttributes(array('required' => null)); $this->frmContact = new FrontendForm('contact', null, 'post'); $this->frmContact->addText('name')->setAttribute('class', 'form-control'); $this->frmContact->addText('emailContact', null, 255, 'form-control'); //->setAttribute('class', 'form-control'); $this->frmContact->addText('phone')->setAttribute('class', 'form-control'); $this->frmContact->addTextarea('messageContact', Language::lbl('ProductMoreInfo') . ' ' . $this->record['title'])->setAttribute('class', 'form-control'); }
/** * Load the form */ private function loadForm() { $this->frm = new FrontendForm('feedback'); $this->frm->addHidden('question_id', $this->record['id']); $this->frm->addTextarea('message'); $this->frm->addRadiobutton('useful', array(array('label' => FL::lbl('Yes'), 'value' => 'Y'), array('label' => FL::lbl('No'), 'value' => 'N'))); }