예제 #1
0
    /**
     * 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);
            }
        }
    }
예제 #2
0
 /**
  * Load the datagrid
  */
 private function loadDataGrid()
 {
     // create a new source-object
     $source = new SpoonDataGridSourceDB(FrontendModel::getDB(), array(FrontendMailmotorModel::QRY_DATAGRID_BROWSE_SENT, array('sent', FRONTEND_LANGUAGE)));
     // create datagrid
     $this->dataGrid = new SpoonDataGrid($source);
     $this->dataGrid->setCompileDirectory(FRONTEND_CACHE_PATH . '/compiled_templates');
     // set hidden columns
     $this->dataGrid->setColumnsHidden(array('id', 'status'));
     // set headers values
     $headers['name'] = SpoonFilter::ucfirst(FL::lbl('Name'));
     $headers['send_on'] = SpoonFilter::ucfirst(FL::lbl('Sent'));
     // set headers
     $this->dataGrid->setHeaderLabels($headers);
     // sorting columns
     $this->dataGrid->setSortingColumns(array('name', 'send_on'), 'name');
     $this->dataGrid->setSortParameter('desc');
     // set colum URLs
     $this->dataGrid->setColumnURL('name', FrontendNavigation::getURLForBlock('mailmotor', 'detail') . '/[id]');
     // set column functions
     $this->dataGrid->setColumnFunction(array('SpoonDate', 'getTimeAgo'), array('[send_on]'), 'send_on', true);
     // add styles
     $this->dataGrid->setColumnAttributes('name', array('class' => 'title'));
     // set paging limit
     $this->dataGrid->setPagingLimit(self::MAILINGS_PAGING_LIMIT);
 }
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = vsprintf(FL::msg('CommentsOn'), array($this->record['title']));
     $link = SITE_URL . FrontendNavigation::getURLForBlock('blog', 'article_comments_rss') . '/' . $this->record['url'];
     $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') . ' ' . $this->record['title'];
         $link = $detailLink . '/' . $this->record['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();
 }
예제 #4
0
 /**
  * Parse the data into the template
  *
  * @return	void
  */
 private function parse()
 {
     // get vars
     $title = isset($this->settings['rss_title_' . FRONTEND_LANGUAGE]) ? $this->settings['rss_title_' . FRONTEND_LANGUAGE] : FrontendModel::getModuleSetting('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 (FrontendModel::getModuleSetting('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>' . 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();
 }
예제 #5
0
 /**
  * Parse the data into the template
  *
  * @return	void
  */
 private function parse()
 {
     // get RSS-link
     $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE);
     if ($rssLink == '') {
         $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss');
     }
     // add RSS-feed
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // add into breadcrumb
     $this->breadcrumb->addElement(ucfirst(FL::lbl('Category')));
     $this->breadcrumb->addElement($this->category['label']);
     // set pageTitle
     $this->header->setPageTitle(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();
 }
예제 #6
0
 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);
     }
     // format data
     foreach ($this->items as &$item) {
         // full url is set?
         if (!isset($item['full_url'])) {
             continue;
         }
         // build utm array
         $utm['utm_source'] = SpoonFilter::urlise(FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE, SITE_DEFAULT_TITLE));
         $utm['utm_medium'] = 'fork-search';
         $utm['utm_term'] = $this->term;
         // get parameters in url already
         if (strpos($item['full_url'], '?') !== false) {
             $glue = '&';
         } else {
             $glue = '?';
         }
         // add utm to url
         $item['full_url'] .= $glue . http_build_query($utm, '', '&');
         // format description
         $item['text'] = !empty($item['text']) ? mb_strlen($item['text']) > $this->length ? mb_substr(strip_tags($item['text']), 0, $this->length, SPOON_CHARSET) . '…' : $item['text'] : '';
     }
     // output
     $this->output(self::OK, $this->items);
 }
예제 #7
0
 /**
  * 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)
 {
     // get files to process
     $tree = self::getTree(FRONTEND_PATH);
     $used = array();
     // loop files
     foreach ($tree as $file) {
         // grab content
         $content = SpoonFile::getContent($file);
         // process the file based on extension
         switch (SpoonFile::getExtension($file)) {
             // 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, $used[$type][$match]['files'])) {
                             $used[$type][$match]['files'][] = $file;
                         }
                     }
                 }
                 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, $used[$type][$match]['files'])) {
                             $used[$type][$match]['files'][] = $file;
                         }
                     }
                 }
                 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, $used[$type][$match]['files'])) {
                             $used[$type][$match]['files'][] = $file;
                         }
                     }
                 }
                 break;
         }
     }
     // init var
     $nonExisting = array();
     // set language
     FrontendLanguage::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) == '{$' . $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) == '{$' . $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) == '{$' . $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) == '{$' . $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;
 }
예제 #8
0
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get RSS-link
     $rssLink = FrontendModel::getModuleSetting('blog', 'feedburner_url_' . FRONTEND_LANGUAGE);
     if ($rssLink == '') {
         $rssLink = FrontendNavigation::getURLForBlock('blog', 'rss');
     }
     // add RSS-feed
     $this->header->addLink(array('rel' => 'alternate', 'type' => 'application/rss+xml', 'title' => FrontendModel::getModuleSetting('blog', 'rss_title_' . FRONTEND_LANGUAGE), 'href' => $rssLink), true);
     // 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);
     // parse the pagination
     $this->parsePagination();
 }
예제 #9
0
 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);
     }
     // 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, SPOON_CHARSET) . '…' : $item['text'] : '';
     }
     // output
     $this->output(self::OK, $this->items);
 }
예제 #10
0
 /**
  * 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')));
 }