Example #1
0
 public function addItem($_link, $_title, $_desc, $_date)
 {
     // strip_tags(
     $_desc = \lib\utility\excerpt::extractRelevant($_desc, $_title, 500);
     $this->rssFeed .= "\n";
     $this->rssFeed .= '    <item>' . "\n";
     $this->rssFeed .= '      <title>' . $_title . '</title>' . "\n";
     $this->rssFeed .= '      <link>' . $this->siteurl . '/' . $_link . '</link>' . "\n";
     $this->rssFeed .= '      <description>' . $_desc . '</description>' . "\n";
     $this->rssFeed .= '      <pubDate>' . date("D, d M Y H:i:s O", strtotime($_date)) . '</pubDate>' . "\n";
     $this->rssFeed .= '    </item>' . "\n";
 }
Example #2
0
 /**
  * [view_posts description]
  * @return [type] [description]
  */
 function view_posts()
 {
     $this->data->post = array();
     $tmp_result = $this->model()->get_posts();
     $tmp_fields = array('id' => 'id', 'post_language' => 'language', 'post_title' => 'title', 'post_slug' => 'slug', 'post_content' => 'content', 'post_meta' => 'meta', 'post_type' => 'type', 'post_url' => 'url', 'post_comment' => 'comment', 'post_count' => 'count', 'post_status' => 'status', 'post_parent' => 'parent', 'user_id' => 'user', 'post_publishdate' => 'publishdate', 'date_modified' => 'modified');
     foreach ($tmp_fields as $key => $value) {
         if (is_array($tmp_result[$key])) {
             $this->data->post[$value] = $tmp_result[$key];
         } else {
             $this->data->post[$value] = html_entity_decode(trim(html_entity_decode($tmp_result[$key])));
         }
     }
     // set page title
     $this->data->page['title'] = $this->data->post['title'];
     $this->data->page['desc'] = \lib\utility\excerpt::extractRelevant($this->data->post['content'], $this->data->page['title']);
     $this->set_title();
     $this->data->nav = $this->model()->sp_nav();
 }
Example #3
0
 /**
  * [twig_function_posts description]
  * @return [type] [description]
  */
 public function twig_function_posts()
 {
     return new \Twig_SimpleFunction('posts', function () {
         $posts = $this->model()->posts(...func_get_args());
         $html = array_column(func_get_args(), 'html');
         $desc = array_column(func_get_args(), 'desc');
         if ($html && count($html) === 1) {
             $html = $html[0];
         }
         if ($desc && count($desc) === 1) {
             $desc = $desc[0];
         }
         if ($html) {
             $counter = 0;
             $result = '';
             $content = '';
             foreach ($posts as $item) {
                 $result .= "\n    ";
                 $result .= "<article>";
                 if ($desc == 'all' || is_numeric($desc) && $desc > $counter) {
                     $result .= "<a href='/" . $item['url'] . "'>" . $item['title'] . "</a>";
                     if (isset($item['content'])) {
                         $content = \lib\utility\excerpt::get($item['content']);
                         if ($content) {
                             $result .= '<p>' . $content . '</p>';
                         }
                     }
                 } else {
                     $result .= "<a href='/" . $item['url'] . "'>" . $item['title'] . "</a>";
                 }
                 $result .= "</article>";
                 // increase counter
                 $counter++;
             }
             echo $result;
         } else {
             return $posts;
         }
     });
 }