示例#1
0
文件: Rss.php 项目: forkcms/forkcms
 /**
  * Parse the data into the template
  */
 private function parse()
 {
     // get vars
     $title = isset($this->settings['rss_title_' . LANGUAGE]) ? $this->settings['rss_title_' . LANGUAGE] : $this->get('fork.settings')->get('Blog', 'rss_title_' . LANGUAGE, SITE_DEFAULT_TITLE);
     $link = SITE_URL . FrontendNavigation::getURLForBlock('Blog');
     $description = isset($this->settings['rss_description_' . LANGUAGE]) ? $this->settings['rss_description_' . 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_' . 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();
 }
示例#2
0
 /**
  * Get the value for a user-setting
  *    syntax {{ usersetting($setting, $userId) }}
  *
  * @param string $string  The string passed from the template.
  * @param string $setting The name of the setting you want.
  * @param int    $userId  The userId, if not set by $string.
  *
  * @return string
  * @throws Exception
  */
 public static function userSetting($string = null, $setting, $userId = null)
 {
     $userId = $string !== null ? (int) $string : (int) $userId;
     $setting = (string) $setting;
     // validate
     if ($userId === 0) {
         throw new Exception('Invalid user id');
     }
     // get user
     $user = User::getBackendUser($userId);
     // return
     return (string) $user->getSetting($setting);
 }