OSDN Git Service

初回コミット(v2.6.17.1)
[magic3/magic3.git] / templates / art41_sample1 / library / Artx / Content / SingleArticle.php
1 <?php
2 defined('_JEXEC') or die;
3
4 Artx::load("Artx_Content_Item");
5
6 class ArtxContentSingleArticle extends ArtxContentItem
7 {
8     public $print;
9
10     public $toc;
11
12     public $intro;
13
14     public $text;
15
16     public function __construct($component, $componentParams, $article, $articleParams, $properties)
17     {
18         parent::__construct($component, $componentParams, $article, $articleParams);
19         $this->print = isset($properties['print']) ? $properties['print'] : '';
20         $this->pageHeading = $this->_componentParams->get('show_page_heading', 1)
21                                ? $this->_componentParams->get('page_heading') : '';
22         $this->titleLink = $this->_articleParams->get('link_titles') && !empty($this->_article->readmore_link)
23                              ? $this->_article->readmore_link : '';
24         $this->emailIconVisible = $this->emailIconVisible && !$this->print;
25         $this->editIconVisible = $this->editIconVisible && !$this->print;
26         $this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug
27                                 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug))
28                                 : '';
29         $this->category = $this->_articleParams->get('show_category') ? $this->_article->category_title : '';
30         $this->categoryLink = $this->_articleParams->get('link_category') && $this->_article->catslug
31                                 ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->catslug))
32                                 : '';
33         $this->parentCategory = $this->_articleParams->get('show_parent_category') && $this->_article->parent_slug != '1:root'
34                                   ? $this->_article->parent_title : '';
35         $this->parentCategoryLink = $this->_articleParams->get('link_parent_category') && $this->_article->parent_slug
36                                       ? JRoute::_(ContentHelperRoute::getCategoryRoute($this->_article->parent_slug))
37                                       : '';
38         $this->author = $this->_articleParams->get('show_author') && !empty($this->_article->author)
39                           ? ($this->_article->created_by_alias ? $this->_article->created_by_alias : $this->_article->author)
40                           : '';
41         if (strlen($this->author) && $this->_articleParams->get('link_author')) {
42             $needle = 'index.php?option=com_contact&view=contact&id=' . $this->_article->contactid;
43             $menu = JFactory::getApplication()->getMenu();
44             $item = $menu->getItems('link', $needle, true);
45             $this->authorLink = !empty($item) ? $needle . '&Itemid=' . $item->id : $needle;
46         } else
47             $this->authorLink = '';
48         $this->toc = isset($this->_article->toc) ? $this->_article->toc : '';
49         $this->text = $this->_articleParams->get('access-view') ? $this->_article->text : '';
50         $user = JFactory::getUser();
51         $this->introVisible = !$this->_articleParams->get('access-view') && $params->get('show_noauth') && $user->get('guest');
52         $this->intro = $this->_article->introtext;
53         if (!$this->_articleParams->get('access-view') && $this->_articleParams->get('show_noauth') && $user->get('guest')
54             && $this->_articleParams->get('show_readmore') && $this->_article->fulltext != null)
55         {
56             $attribs = json_decode($this->_article->attribs);
57             if ($attribs->alternative_readmore == null)
58                 $this->readmore = JText::_('COM_CONTENT_REGISTER_TO_READ_MORE');
59             elseif ($this->readmore = $this->_article->alternative_readmore) {
60                 if ($this->_articleParams->get('show_readmore_title', 0) != 0)
61                     $this->readmore .= JHtml::_('string.truncate', ($this->_article->title), $this->_articleParams->get('readmore_limit'));
62             } elseif ($this->_articleParams->get('show_readmore_title', 0) == 0)
63                 $this->readmore = JText::sprintf('COM_CONTENT_READ_MORE_TITLE');
64             else
65                 $this->readmore = JText::_('COM_CONTENT_READ_MORE')
66                                     . JHtml::_('string.truncate', $this->_article->title,
67                                                $this->_articleParams->get('readmore_limit'));
68             $link = new JURI(JRoute::_('index.php?option=com_users&view=login'));
69             $this->readmoreLink = $link->__toString();
70         } else {
71             $this->readmore = '';
72             $this->readmoreLink = '';
73         }
74         $this->paginationPosition = (isset($this->_article->pagination) && $this->_article->pagination && isset($this->_article->paginationposition))
75             ? (($this->_article->paginationposition ? 'below' : 'above') . ' ' . ($this->_article->paginationrelative ? 'full article' : 'text'))
76             : '';
77         $this->showLinks = isset($this->_article->urls) && is_string($this->_article->urls) && !empty($this->_article->urls);
78     }
79
80     public function printIcon()
81     {
82         return JHTML::_($this->print ? 'icon.print_screen' : 'icon.print_popup', $this->_article, $this->_articleParams);
83     }
84
85     public function toc($toc)
86     {
87         return '<div class="art-article">' . $toc . '</div>';
88     }
89
90     public function intro($intro)
91     {
92         return '<div class="art-article">' . $intro . '</div>';
93     }
94
95     public function text($text)
96     {
97         return '<div class="art-article">' . $text . '</div>';
98     }
99
100     public function pagination() {
101         return $this->_article->pagination;
102     }
103 }