e8611180 by root
2 parents aca123a8 b1d054fb
Showing 32 changed files with 2491 additions and 5 deletions
1 # AddHandler x-httpd-php5619 .php
2
3
4 Options +SymLinksIfOwnerMatch
5
6 Options -Indexes
7
8 RewriteEngine on
9
10
11 ## Begin - Rewrite rules to block out some common exploits.
12 # If you experience problems on your site then comment out the operations listed
13 # below by adding a # to the beginning of the line.
14 # This attempts to block the most common type of exploit `attempts` on Joomla!
15 #
16 # Block any script trying to base64_encode data within the URL.
17 RewriteCond %{QUERY_STRING} base64_encode[^(]*\([^)]*\) [OR]
18 # Block any script that includes a <script> tag in URL.
19 RewriteCond %{QUERY_STRING} (<|%3C)([^s]*s)+cript.*(>|%3E) [NC,OR]
20 # Block any script trying to set a PHP GLOBALS variable via URL.
21 RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
22 # Block any script trying to modify a _REQUEST variable via URL.
23 RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
24 # Return 403 Forbidden header and show the content of the root home page
25 RewriteRule .* index.php [F]
26 #
27 ## End - Rewrite rules to block out some common exploits.
28
29 ## Begin - Custom redirects
30 #
31 # If you need to redirect some pages, or set a canonical non-www to
32 # www redirect (or vice versa), place that code here. Ensure those
33 # redirects use the correct RewriteRule syntax and the [R=301,L] flags.
34 #
35 ## End - Custom redirects
36
37 ##
38 # Uncomment the following line if your webserver's URL
39 # is not directly related to physical file paths.
40 # Update Your Joomla! Directory (just / for root).
41 ##
42
43 # RewriteBase /
44
45 ## Begin - Joomla! core SEF Section.
46 #
47 RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
48 #
49 # If the requested path and file is not /index.php and the request
50 # has not already been internally rewritten to the index.php script
51 RewriteCond %{REQUEST_URI} !^/index\.php
52 # and the requested path and file doesn't directly match a physical file
53 RewriteCond %{REQUEST_FILENAME} !-f
54 # and the requested path and file doesn't directly match a physical folder
55 RewriteCond %{REQUEST_FILENAME} !-d
56 # internally rewrite the request to the index.php script
57 RewriteRule .* index.php [L]
58 #
59 ## End - Joomla! core SEF Section.
60
61
62 RewriteEngine On
63 # RewriteCond %{HTTPS} off
64 # RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
65
66 #20200122 - IPアクセスリダイレクトnozaki
67 RewriteBase /
68 RewriteCond %{HTTP_HOST} ^18\.178\.92\.128$ [NC]
69 RewriteRule .* https://www.nifs-k.ac.jp%{REQUEST_URI} [R=302,L]
70
71 # 20200809 gitignore アクセス禁止
72 RedirectMatch 404 /\.git
73
74 <IfModule mod_siteguard.c>
75 SiteGuard_User_ExcludeSig ip(202.95.45.168)
76 SiteGuard_User_ExcludeSig ip(202.24.160.0/21)
77 SiteGuard_User_ExcludeSig ip(210.137.6.192/26)
78 SiteGuard_User_ExcludeSig ip(210.237.39.72)
79 SiteGuard_User_ExcludeSig ip(210.237.36.185)
80 SiteGuard_User_ExcludeSig ip(18.178.92.128)
81 </IfModule>
......
1 <?php
2 echo "<p>カスタムアーカイブコンポーネントです。</p>";
3 echo "\n";
4 echo "<P>このページから設定する項目はありません。</P>";
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="utf-8"?>
2 <extension type="component" version="3.0" method="upgrade">
3 <name>COM_CONTENT_CUSTOM</name>
4 <author>T.Tokudome</author>
5 <creationDate>July 2020</creationDate>
6 <copyright></copyright>
7 <license></license>
8 <authorEmail>tokudome@lilli.co.jp</authorEmail>
9 <authorUrl></authorUrl>
10 <version>0.0.1</version>
11 <description>COM_CONTENT_CUSTOM_XML_DESCRIPTION</description>
12
13 <update>
14 <schemas>
15 <schemapath type="mysql">sql/updates/mysql</schemapath>
16 </schemas>
17 </update>
18
19 <files folder="site">
20 <filename>index.html</filename>
21 <filename>content_custom.php</filename>
22 <filename>controller.php</filename>
23 <folder>views</folder>
24 <folder>helpers</folder>
25 <folder>models</folder>
26 </files>
27 <languages folder="site">
28 <language tag="en-GB">language/en-GB.com_content_custom.ini</language>
29 <language tag="ja-JP">language/ja-JP.com_content_custom.ini</language>
30 </languages>
31 <administration>
32 <menu link='index.php?option=com_content_custom'>カスタムアーカイブ</menu>
33 <files folder="admin">
34 <filename>index.html</filename>
35 <filename>content_custom.php</filename>
36 <folder>sql</folder>
37 </files>
38 <languages folder="admin">
39 <language tag="en-GB">language/en-GB.com_content_custom.ini</language>
40 <language tag="ja-JP">language/ja-JP.com_content_custom.ini</language>
41 <language tag="en-GB">language/en-GB.com_content_custom.sys.ini</language>
42 <language tag="ja-JP">language/ja-JP.com_content_custom.sys.ini</language>
43 </languages>
44 </administration>
45
46 </extension>
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt
4 ; Note : All ini files need to be saved as UTF-8
5
6 COM_CONTENT_CUSTOM="archive_custom_component"
7 COM_CONTENT_CUSTOM_ATTRIBS_ARTICLE_SETTINGS_LABEL="Options"
8 COM_CONTENT_CUSTOM_FIELD_INFOBLOCK_POSITION_LABEL="Position of Article Info"
9 COM_CONTENT_CUSTOM_XML_DESCRIPTION="It is a component that narrows down articles posted in the past by category and displays a monthly archive."
10 COM_CONTENT_CUSTOM_FIELD_INFOBLOCK_POSITION_DESC="Puts the article information block above or below the text or splits it into two separate blocks, one above and the other below."
11 COM_CONTENT_CUSTOM_FIELD_VALUE_USE_ARTICLE_SETTINGS="Use Article Settings"
12 COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE="Above"
13 COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW="Below"
14 COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT="Split"
15 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE="Archived Articles"
16 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION="Default"
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt
4 ; Note : All ini files need to be saved as UTF-8
5
6 COM_CONTENT_CUSTOM="archive_custom_component"
7 COM_CONTENT_CUSTOM_XML_DESCRIPTION="It is a component that narrows down articles posted in the past by category and displays a monthly archive."
8 COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE="Above"
9 COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW="Below"
10 COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT="Split"
11 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE="Archived Articles"
12 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION="Default"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
4 ; Note : All ini files need to be saved as UTF-8
5
6 COM_CONTENT_CUSTOM="カスタムアーカイブ(コンポーネント)"
7 COM_CONTENT_CUSTOM_ATTRIBS_ARTICLE_SETTINGS_LABEL="オプション"
8 COM_CONTENT_CUSTOM_FIELD_INFOBLOCK_POSITION_LABEL="記事情報の位置"
9 COM_CONTENT_CUSTOM_XML_DESCRIPTION="過去に投稿された記事をカテゴリー別に絞り込み、月間アーカイブを表示するコンポーネントです。"
10 COM_CONTENT_CUSTOM_FIELD_INFOBLOCK_POSITION_DESC="記事情報のブロックをテキストの上か下に追加します。または1つは上、その他は下へ2つのブロックに分けます。"
11 COM_CONTENT_CUSTOM_FIELD_VALUE_USE_ARTICLE_SETTINGS="記事設定の使用"
12 COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE="上"
13 COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW="下"
14 COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT="分割"
15 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE="アーカイブ記事"
16 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION="標準"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
4 ; Note : All ini files need to be saved as UTF-8
5
6 COM_CONTENT_CUSTOM="カスタムアーカイブ(コンポーネント)"
7 COM_CONTENT_CUSTOM_XML_DESCRIPTION="過去に投稿された記事をカテゴリー別に絞り込み、月間アーカイブを表示するコンポーネントです。"
8 COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE="上"
9 COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW="下"
10 COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT="分割"
11 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE="アーカイブ記事"
12 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION="標準"
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 JLoader::register('ContentCustomHelperRoute', JPATH_SITE . '/components/com_content_custom/helpers/route.php');
13 JLoader::register('ContentCustomHelperQuery', JPATH_SITE . '/components/com_content_custom/helpers/query.php');
14
15 $input = JFactory::getApplication()->input;
16 $user = JFactory::getUser();
17
18 $controller = JControllerLegacy::getInstance('Content');
19
20 $controller->execute(JFactory::getApplication()->input->get('task'));
21 $controller->redirect();
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 use Joomla\CMS\Component\ComponentHelper;
13
14 /**
15 * Content Component Controller
16 *
17 * @since 1.5
18 */
19 class ContentController extends JControllerLegacy
20 {
21 /**
22 * Constructor.
23 *
24 * @param array $config An optional associative array of configuration settings.
25 * Recognized key values include 'name', 'default_task', 'model_path', and
26 * 'view_path' (this list is not meant to be comprehensive).
27 *
28 * @since 3.0.1
29 */
30 public function __construct($config = array())
31 {
32 $this->input = JFactory::getApplication()->input;
33
34 // Article frontpage Editor pagebreak proxying:
35 if ($this->input->get('view') === 'article' && $this->input->get('layout') === 'pagebreak')
36 {
37 $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
38 }
39 // Article frontpage Editor article proxying:
40 elseif ($this->input->get('view') === 'articles' && $this->input->get('layout') === 'modal')
41 {
42 JHtml::_('stylesheet', 'system/adminlist.css', array('version' => 'auto', 'relative' => true));
43 $config['base_path'] = JPATH_COMPONENT_ADMINISTRATOR;
44 }
45
46 parent::__construct($config);
47 }
48
49 /**
50 * Method to display a view.
51 *
52 * @param boolean $cachable If true, the view output will be cached.
53 * @param boolean $urlparams An array of safe URL parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
54 *
55 * @return JController This object to support chaining.
56 *
57 * @since 1.5
58 */
59 public function display($cachable = false, $urlparams = false)
60 {
61 $cachable = true;
62
63 /**
64 * Set the default view name and format from the Request.
65 * Note we are using a_id to avoid collisions with the router and the return page.
66 * Frontend is a bit messier than the backend.
67 */
68 $id = $this->input->getInt('a_id');
69 $vName = $this->input->getCmd('view', 'categories');
70 $this->input->set('view', $vName);
71 $user = JFactory::getUser();
72
73 if ($user->get('id')
74 || ($this->input->getMethod() === 'POST'
75 && (($vName === 'category' && $this->input->get('layout') !== 'blog') || $vName === 'archive' )))
76 {
77 $cachable = false;
78 }
79
80 $safeurlparams = array(
81 'catid' => 'INT',
82 'id' => 'INT',
83 'cid' => 'ARRAY',
84 'year' => 'INT',
85 'month' => 'INT',
86 'limit' => 'UINT',
87 'limitstart' => 'UINT',
88 'showall' => 'INT',
89 'return' => 'BASE64',
90 'filter' => 'STRING',
91 'filter_order' => 'CMD',
92 'filter_order_Dir' => 'CMD',
93 'filter-search' => 'STRING',
94 'print' => 'BOOLEAN',
95 'lang' => 'CMD',
96 'Itemid' => 'INT');
97
98 parent::display($cachable, $safeurlparams);
99
100 return $this;
101 }
102 }
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 /**
13 * Content Component Query Helper
14 *
15 * @since 1.5
16 */
17 class ContentCustomHelperQuery
18 {
19 /**
20 * Translate an order code to a field for secondary category ordering.
21 *
22 * @param string $orderby The ordering code.
23 * @param string $orderDate The ordering code for the date.
24 *
25 * @return string The SQL field(s) to order by.
26 *
27 * @since 1.5
28 */
29 public static function orderbySecondary($orderby, $orderDate = 'created')
30 {
31 $queryDate = self::getQueryDate($orderDate);
32
33 switch ($orderby)
34 {
35 case 'date' :
36 $orderby = $queryDate;
37 break;
38
39 case 'rdate' :
40 $orderby = $queryDate . ' DESC ';
41 break;
42
43 case 'alpha' :
44 $orderby = 'a.title';
45 break;
46
47 case 'ralpha' :
48 $orderby = 'a.title DESC';
49 break;
50
51 case 'hits' :
52 $orderby = 'a.hits DESC';
53 break;
54
55 case 'rhits' :
56 $orderby = 'a.hits';
57 break;
58
59 case 'order' :
60 $orderby = 'a.ordering';
61 break;
62
63 case 'rorder' :
64 $orderby = 'a.ordering DESC';
65 break;
66
67 case 'author' :
68 $orderby = 'author';
69 break;
70
71 case 'rauthor' :
72 $orderby = 'author DESC';
73 break;
74
75 case 'front' :
76 $orderby = 'a.featured DESC, fp.ordering, ' . $queryDate . ' DESC ';
77 break;
78
79 case 'random' :
80 $orderby = JFactory::getDbo()->getQuery(true)->Rand();
81 break;
82
83 case 'vote' :
84 $orderby = 'a.id DESC ';
85
86 if (JPluginHelper::isEnabled('content', 'vote'))
87 {
88 $orderby = 'rating_count DESC ';
89 }
90 break;
91
92 case 'rvote' :
93 $orderby = 'a.id ASC ';
94
95 if (JPluginHelper::isEnabled('content', 'vote'))
96 {
97 $orderby = 'rating_count ASC ';
98 }
99 break;
100
101 case 'rank' :
102 $orderby = 'a.id DESC ';
103
104 if (JPluginHelper::isEnabled('content', 'vote'))
105 {
106 $orderby = 'rating DESC ';
107 }
108 break;
109
110 case 'rrank' :
111 $orderby = 'a.id ASC ';
112
113 if (JPluginHelper::isEnabled('content', 'vote'))
114 {
115 $orderby = 'rating ASC ';
116 }
117 break;
118
119 default :
120 $orderby = 'a.ordering';
121 break;
122 }
123
124 return $orderby;
125 }
126
127 /**
128 * Translate an order code to a field for primary category ordering.
129 *
130 * @param string $orderDate The ordering code.
131 *
132 * @return string The SQL field(s) to order by.
133 *
134 * @since 1.6
135 */
136 public static function getQueryDate($orderDate)
137 {
138 $db = JFactory::getDbo();
139
140 switch ($orderDate)
141 {
142 case 'modified' :
143 $queryDate = ' CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END';
144 break;
145
146 // Use created if publish_up is not set
147 case 'published' :
148 $queryDate = ' CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END ';
149 break;
150
151 case 'unpublished' :
152 $queryDate = ' CASE WHEN a.publish_down = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_down END ';
153 break;
154 case 'created' :
155 default :
156 $queryDate = ' a.created ';
157 break;
158 }
159
160 return $queryDate;
161 }
162
163 }
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 /**
13 * Content Component Route Helper.
14 *
15 * @since 1.5
16 */
17 abstract class ContentCustomHelperRoute
18 {
19 /**
20 * Get the article route.
21 *
22 * @param integer $id The route of the content item.
23 * @param integer $catid The category ID.
24 * @param integer $language The language code.
25 * @param string $layout The layout value.
26 *
27 * @return string The article route.
28 *
29 * @since 1.5
30 */
31 public static function getArticleRoute($id, $catid = 0, $language = 0, $layout = null)
32 {
33 // Create the link
34 $link = 'index.php?option=com_content&view=article&id=' . $id;
35
36 if ((int) $catid > 1)
37 {
38 $link .= '&catid=' . $catid;
39 }
40
41 if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
42 {
43 $link .= '&lang=' . $language;
44 }
45
46 if ($layout)
47 {
48 $link .= '&layout=' . $layout;
49 }
50
51 return $link;
52 }
53
54 /**
55 * Get the category route.
56 *
57 * @param integer $catid The category ID.
58 * @param integer $language The language code.
59 * @param string $layout The layout value.
60 *
61 * @return string The article route.
62 *
63 * @since 1.5
64 */
65 public static function getCategoryRoute($catid, $language = 0, $layout = null)
66 {
67 if ($catid instanceof JCategoryNode)
68 {
69 $id = $catid->id;
70 }
71 else
72 {
73 $id = (int) $catid;
74 }
75
76 if ($id < 1)
77 {
78 return '';
79 }
80
81 $link = 'index.php?option=com_content&view=category&id=' . $id;
82
83 if ($language && $language !== '*' && JLanguageMultilang::isEnabled())
84 {
85 $link .= '&lang=' . $language;
86 }
87
88 if ($layout)
89 {
90 $link .= '&layout=' . $layout;
91 }
92
93 return $link;
94 }
95
96 }
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 use Joomla\Utilities\ArrayHelper;
13
14 JLoader::register('ContentModelArticles', __DIR__ . '/articles.php');
15
16 /**
17 * Content Component Archive Model
18 *
19 * @since 1.5
20 */
21 class ContentModelArchive extends ContentModelArticles
22 {
23 /**
24 * Model context string.
25 *
26 * @var string
27 */
28 public $_context = 'com_content_custom.archive';
29
30 /**
31 * Method to auto-populate the model state.
32 *
33 * Note. Calling getState in this method will result in recursion.
34 *
35 * @param string $ordering The field to order on.
36 * @param string $direction The direction to order on.
37 *
38 * @return void
39 *
40 * @since 1.6
41 */
42 protected function populateState($ordering = null, $direction = null)
43 {
44 parent::populateState();
45
46 $app = JFactory::getApplication();
47
48 // Add archive properties
49 $params = $this->state->params;
50
51 // Filter on archived articles
52 $this->setState('filter.published', 1);
53
54 // Filter on month, year
55 $this->setState('filter.month', $app->input->getInt('month'));
56 $this->setState('filter.year', $app->input->getInt('year'));
57
58 // Optional filter text
59 $this->setState('list.filter', $app->input->getString('filter-search'));
60
61 // Get list limit
62 $itemid = $app->input->get('Itemid', 0, 'int');
63 $limit = $app->getUserStateFromRequest('com_content_custom.archive.list' . $itemid . '.limit', 'limit', $params->get('display_num'), 'uint');
64 $this->setState('list.limit', $limit);
65
66 // Set the archive ordering
67 $articleOrderby = $params->get('orderby_sec', 'rdate');
68 $articleOrderDate = $params->get('order_date');
69
70 // No category ordering
71 $secondary = ContentCustomHelperQuery::orderbySecondary($articleOrderby, $articleOrderDate);
72
73 $this->setState('list.ordering', $secondary . ', a.created DESC');
74 $this->setState('list.direction', '');
75 }
76
77 /**
78 * Get the master query for retrieving a list of articles subject to the model state.
79 *
80 * @return JDatabaseQuery
81 *
82 * @since 1.6
83 */
84 protected function getListQuery()
85 {
86 $params = $this->state->params;
87 $app = JFactory::getApplication('site');
88 $catids = ArrayHelper::toInteger($app->input->get('catid', array(), 'array'));
89 $catids = array_values(array_diff($catids, array(0)));
90 $articleOrderDate = $params->get('order_date');
91
92 // Create a new query object.
93 $query = parent::getListQuery();
94
95 // Add routing for archive
96 // Sqlsrv changes
97 $case_when = ' CASE WHEN ';
98 $case_when .= $query->charLength('a.alias', '!=', '0');
99 $case_when .= ' THEN ';
100 $a_id = $query->castAsChar('a.id');
101 $case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
102 $case_when .= ' ELSE ';
103 $case_when .= $a_id . ' END as slug';
104
105 $query->select($case_when);
106
107 $case_when = ' CASE WHEN ';
108 $case_when .= $query->charLength('c.alias', '!=', '0');
109 $case_when .= ' THEN ';
110 $c_id = $query->castAsChar('c.id');
111 $case_when .= $query->concatenate(array($c_id, 'c.alias'), ':');
112 $case_when .= ' ELSE ';
113 $case_when .= $c_id . ' END as catslug';
114 $query->select($case_when);
115
116 // Filter on month, year
117 // First, get the date field
118 $queryDate = ContentCustomHelperQuery::getQueryDate($articleOrderDate);
119
120 if ($month = $this->getState('filter.month'))
121 {
122 $query->where($query->month($queryDate) . ' = ' . $month);
123 }
124
125 if ($year = $this->getState('filter.year'))
126 {
127 $query->where($query->year($queryDate) . ' = ' . $year);
128 }
129
130 if (count($catids) > 0)
131 {
132 $query->where('c.id IN (' . implode(', ', $catids) . ')');
133 }
134
135 return $query;
136 }
137
138 /**
139 * Method to get the archived article list
140 *
141 * @access public
142 * @return array
143 */
144 public function getData()
145 {
146 $app = JFactory::getApplication();
147
148 // Lets load the content if it doesn't already exist
149 if (empty($this->_data))
150 {
151 // Get the page/component configuration
152 $params = $app->getParams();
153
154 // Get the pagination request variables
155 $limit = $app->input->get('limit', $params->get('display_num', 20), 'uint');
156 $limitstart = $app->input->get('limitstart', 0, 'uint');
157
158 $query = $this->_buildQuery();
159
160 $this->_data = $this->_getList($query, $limitstart, $limit);
161 }
162
163 return $this->_data;
164 }
165
166 /**
167 * JModelLegacy override to add alternating value for $odd
168 *
169 * @param string $query The query.
170 * @param integer $limitstart Offset.
171 * @param integer $limit The number of records.
172 *
173 * @return array An array of results.
174 *
175 * @since 3.0.1
176 * @throws RuntimeException
177 */
178 protected function _getList($query, $limitstart=0, $limit=0)
179 {
180 $result = parent::_getList($query, $limitstart, $limit);
181
182 $odd = 1;
183
184 foreach ($result as $k => $row)
185 {
186 $result[$k]->odd = $odd;
187 $odd = 1 - $odd;
188 }
189
190 return $result;
191 }
192 }
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 use Joomla\Registry\Registry;
13 use Joomla\String\StringHelper;
14 use Joomla\Utilities\ArrayHelper;
15
16 /**
17 * This models supports retrieving lists of articles.
18 *
19 * @since 1.6
20 */
21 class ContentModelArticles extends JModelList
22 {
23 /**
24 * Constructor.
25 *
26 * @param array $config An optional associative array of configuration settings.
27 *
28 * @see JController
29 * @since 1.6
30 */
31 public function __construct($config = array())
32 {
33 if (empty($config['filter_fields']))
34 {
35 $config['filter_fields'] = array(
36 'id', 'a.id',
37 'title', 'a.title',
38 'alias', 'a.alias',
39 'checked_out', 'a.checked_out',
40 'checked_out_time', 'a.checked_out_time',
41 'catid', 'a.catid', 'category_title',
42 'state', 'a.state',
43 'access', 'a.access', 'access_level',
44 'created', 'a.created',
45 'created_by', 'a.created_by',
46 'ordering', 'a.ordering',
47 'featured', 'a.featured',
48 'language', 'a.language',
49 'hits', 'a.hits',
50 'publish_up', 'a.publish_up',
51 'publish_down', 'a.publish_down',
52 'images', 'a.images',
53 'urls', 'a.urls',
54 'filter_tag',
55 );
56 }
57
58 parent::__construct($config);
59 }
60
61 /**
62 * Method to auto-populate the model state.
63 *
64 * This method should only be called once per instantiation and is designed
65 * to be called on the first call to the getState() method unless the model
66 * configuration flag to ignore the request is set.
67 *
68 * Note. Calling getState in this method will result in recursion.
69 *
70 * @param string $ordering An optional ordering field.
71 * @param string $direction An optional direction (asc|desc).
72 *
73 * @return void
74 *
75 * @since 3.0.1
76 */
77 protected function populateState($ordering = 'ordering', $direction = 'ASC')
78 {
79 $app = JFactory::getApplication();
80
81 // List state information
82 $value = $app->input->get('limit', $app->get('list_limit', 0), 'uint');
83 $this->setState('list.limit', $value);
84
85 $value = $app->input->get('limitstart', 0, 'uint');
86 $this->setState('list.start', $value);
87
88 $value = $app->input->get('filter_tag', 0, 'uint');
89 $this->setState('filter.tag', $value);
90
91 $orderCol = $app->input->get('filter_order', 'a.ordering');
92
93 if (!in_array($orderCol, $this->filter_fields))
94 {
95 $orderCol = 'a.ordering';
96 }
97
98 $this->setState('list.ordering', $orderCol);
99
100 $listOrder = $app->input->get('filter_order_Dir', 'ASC');
101
102 if (!in_array(strtoupper($listOrder), array('ASC', 'DESC', '')))
103 {
104 $listOrder = 'ASC';
105 }
106
107 $this->setState('list.direction', $listOrder);
108
109 $params = $app->getParams();
110 $this->setState('params', $params);
111 $user = JFactory::getUser();
112
113 if ((!$user->authorise('core.edit.state', 'com_content_custom')) && (!$user->authorise('core.edit', 'com_content_custom')))
114 {
115 // Filter on published for those who do not have edit or edit.state rights.
116 $this->setState('filter.published', 1);
117 }
118
119 $this->setState('filter.language', JLanguageMultilang::isEnabled());
120
121 // Process show_noauth parameter
122 if ((!$params->get('show_noauth')) || (!JComponentHelper::getParams('com_content_custom')->get('show_noauth')))
123 {
124 $this->setState('filter.access', true);
125 }
126 else
127 {
128 $this->setState('filter.access', false);
129 }
130
131 $this->setState('layout', $app->input->getString('layout'));
132 }
133
134 /**
135 * Method to get a store id based on model configuration state.
136 *
137 * This is necessary because the model is used by the component and
138 * different modules that might need different sets of data or different
139 * ordering requirements.
140 *
141 * @param string $id A prefix for the store id.
142 *
143 * @return string A store id.
144 *
145 * @since 1.6
146 */
147 protected function getStoreId($id = '')
148 {
149 // Compile the store id.
150 $id .= ':' . serialize($this->getState('filter.published'));
151 $id .= ':' . $this->getState('filter.access');
152 $id .= ':' . $this->getState('filter.featured');
153 $id .= ':' . serialize($this->getState('filter.article_id'));
154 $id .= ':' . $this->getState('filter.article_id.include');
155 $id .= ':' . serialize($this->getState('filter.category_id'));
156 $id .= ':' . $this->getState('filter.category_id.include');
157 $id .= ':' . serialize($this->getState('filter.author_id'));
158 $id .= ':' . $this->getState('filter.author_id.include');
159 $id .= ':' . serialize($this->getState('filter.author_alias'));
160 $id .= ':' . $this->getState('filter.author_alias.include');
161 $id .= ':' . $this->getState('filter.date_filtering');
162 $id .= ':' . $this->getState('filter.date_field');
163 $id .= ':' . $this->getState('filter.start_date_range');
164 $id .= ':' . $this->getState('filter.end_date_range');
165 $id .= ':' . $this->getState('filter.relative_date');
166 $id .= ':' . serialize($this->getState('filter.tag'));
167
168 return parent::getStoreId($id);
169 }
170
171 /**
172 * Get the master query for retrieving a list of articles subject to the model state.
173 *
174 * @return JDatabaseQuery
175 *
176 * @since 1.6
177 */
178 protected function getListQuery()
179 {
180 // Get the current user for authorisation checks
181 $user = JFactory::getUser();
182
183 // Create a new query object.
184 $db = $this->getDbo();
185 $query = $db->getQuery(true);
186
187 // Select the required fields from the table.
188 $query->select(
189 $this->getState(
190 'list.select',
191 'a.id, a.title, a.alias, a.introtext, a.fulltext, ' .
192 'a.checked_out, a.checked_out_time, ' .
193 'a.catid, a.created, a.created_by, a.created_by_alias, ' .
194 // Published/archived article in archive category is treats as archive article
195 // If category is not published then force 0
196 'CASE WHEN c.published = 2 AND a.state > 0 THEN 2 WHEN c.published != 1 THEN 0 ELSE a.state END as state,' .
197 // Use created if modified is 0
198 'CASE WHEN a.modified = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.modified END as modified, ' .
199 'a.modified_by, uam.name as modified_by_name,' .
200 // Use created if publish_up is 0
201 'CASE WHEN a.publish_up = ' . $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END as publish_up,' .
202 'a.publish_down, a.images, a.urls, a.attribs, a.metadata, a.metakey, a.metadesc, a.access, ' .
203 'a.hits, a.xreference, a.featured, a.language, ' . ' ' . $query->length('a.fulltext') . ' AS readmore, a.ordering'
204 )
205 );
206
207 $query->from('#__content AS a');
208
209 $params = $this->getState('params');
210 $orderby_sec = $params->get('orderby_sec');
211
212 // Join over the frontpage articles if required.
213 if ($this->getState('filter.frontpage'))
214 {
215 if ($orderby_sec === 'front')
216 {
217 $query->select('fp.ordering');
218 $query->join('INNER', '#__content_frontpage AS fp ON fp.content_id = a.id');
219 }
220 else
221 {
222 $query->where('a.featured = 1');
223 }
224 }
225 elseif ($orderby_sec === 'front' || $this->getState('list.ordering') === 'fp.ordering')
226 {
227 $query->select('fp.ordering');
228 $query->join('LEFT', '#__content_frontpage AS fp ON fp.content_id = a.id');
229 }
230
231 // Join over the categories.
232 $query->select('c.title AS category_title, c.path AS category_route, c.access AS category_access, c.alias AS category_alias')
233 ->select('c.published, c.published AS parents_published, c.lft')
234 ->join('LEFT', '#__categories AS c ON c.id = a.catid');
235
236 // Join over the users for the author and modified_by names.
237 $query->select("CASE WHEN a.created_by_alias > ' ' THEN a.created_by_alias ELSE ua.name END AS author")
238 ->select('ua.email AS author_email')
239 ->join('LEFT', '#__users AS ua ON ua.id = a.created_by')
240 ->join('LEFT', '#__users AS uam ON uam.id = a.modified_by');
241
242 // Join over the categories to get parent category titles
243 $query->select('parent.title as parent_title, parent.id as parent_id, parent.path as parent_route, parent.alias as parent_alias')
244 ->join('LEFT', '#__categories as parent ON parent.id = c.parent_id');
245
246 if (JPluginHelper::isEnabled('content_custom', 'vote'))
247 {
248 // Join on voting table
249 $query->select('COALESCE(NULLIF(ROUND(v.rating_sum / v.rating_count, 0), 0), 0) AS rating,
250 COALESCE(NULLIF(v.rating_count, 0), 0) as rating_count')
251 ->join('LEFT', '#__content_rating AS v ON a.id = v.content_id');
252 }
253
254 // Filter by access level.
255 if ($this->getState('filter.access', true))
256 {
257 $groups = implode(',', $user->getAuthorisedViewLevels());
258 $query->where('a.access IN (' . $groups . ')')
259 ->where('c.access IN (' . $groups . ')');
260 }
261
262 // Filter by published state
263 $published = $this->getState('filter.published');
264
265 if (is_numeric($published) && $published == 2)
266 {
267 /**
268 * If category is archived then article has to be published or archived.
269 * Or categogy is published then article has to be archived.
270 */
271 $query->where('((c.published = 2 AND a.state > 0) OR (c.published = 1 AND a.state = 2))');
272 }
273 elseif (is_numeric($published))
274 {
275 // Category has to be published
276 $query->where('c.published = 1 AND a.state = ' . (int) $published);
277 }
278 elseif (is_array($published))
279 {
280 $published = ArrayHelper::toInteger($published);
281 $published = implode(',', $published);
282
283 // Category has to be published
284 $query->where('c.published = 1 AND a.state IN (' . $published . ')');
285 }
286
287 // Filter by featured state
288 $featured = $this->getState('filter.featured');
289
290 switch ($featured)
291 {
292 case 'hide':
293 $query->where('a.featured = 0');
294 break;
295
296 case 'only':
297 $query->where('a.featured = 1');
298 break;
299
300 case 'show':
301 default:
302 // Normally we do not discriminate between featured/unfeatured items.
303 break;
304 }
305
306 // Filter by a single or group of articles.
307 $articleId = $this->getState('filter.article_id');
308
309 if (is_numeric($articleId))
310 {
311 $type = $this->getState('filter.article_id.include', true) ? '= ' : '<> ';
312 $query->where('a.id ' . $type . (int) $articleId);
313 }
314 elseif (is_array($articleId))
315 {
316 $articleId = ArrayHelper::toInteger($articleId);
317 $articleId = implode(',', $articleId);
318 $type = $this->getState('filter.article_id.include', true) ? 'IN' : 'NOT IN';
319 $query->where('a.id ' . $type . ' (' . $articleId . ')');
320 }
321
322 // Filter by a single or group of categories
323 $categoryId = $this->getState('filter.category_id');
324
325 if (is_numeric($categoryId))
326 {
327 $type = $this->getState('filter.category_id.include', true) ? '= ' : '<> ';
328
329 // Add subcategory check
330 $includeSubcategories = $this->getState('filter.subcategories', false);
331 $categoryEquals = 'a.catid ' . $type . (int) $categoryId;
332
333 if ($includeSubcategories)
334 {
335 $levels = (int) $this->getState('filter.max_category_levels', '1');
336
337 // Create a subquery for the subcategory list
338 $subQuery = $db->getQuery(true)
339 ->select('sub.id')
340 ->from('#__categories as sub')
341 ->join('INNER', '#__categories as this ON sub.lft > this.lft AND sub.rgt < this.rgt')
342 ->where('this.id = ' . (int) $categoryId);
343
344 if ($levels >= 0)
345 {
346 $subQuery->where('sub.level <= this.level + ' . $levels);
347 }
348
349 // Add the subquery to the main query
350 $query->where('(' . $categoryEquals . ' OR a.catid IN (' . (string) $subQuery . '))');
351 }
352 else
353 {
354 $query->where($categoryEquals);
355 }
356 }
357 elseif (is_array($categoryId) && (count($categoryId) > 0))
358 {
359 $categoryId = ArrayHelper::toInteger($categoryId);
360 $categoryId = implode(',', $categoryId);
361
362 if (!empty($categoryId))
363 {
364 $type = $this->getState('filter.category_id.include', true) ? 'IN' : 'NOT IN';
365 $query->where('a.catid ' . $type . ' (' . $categoryId . ')');
366 }
367 }
368
369 // Filter by author
370 $authorId = $this->getState('filter.author_id');
371 $authorWhere = '';
372
373 if (is_numeric($authorId))
374 {
375 $type = $this->getState('filter.author_id.include', true) ? '= ' : '<> ';
376 $authorWhere = 'a.created_by ' . $type . (int) $authorId;
377 }
378 elseif (is_array($authorId))
379 {
380 $authorId = array_filter($authorId, 'is_numeric');
381
382 if ($authorId)
383 {
384 $authorId = implode(',', $authorId);
385 $type = $this->getState('filter.author_id.include', true) ? 'IN' : 'NOT IN';
386 $authorWhere = 'a.created_by ' . $type . ' (' . $authorId . ')';
387 }
388 }
389
390 // Filter by author alias
391 $authorAlias = $this->getState('filter.author_alias');
392 $authorAliasWhere = '';
393
394 if (is_string($authorAlias))
395 {
396 $type = $this->getState('filter.author_alias.include', true) ? '= ' : '<> ';
397 $authorAliasWhere = 'a.created_by_alias ' . $type . $db->quote($authorAlias);
398 }
399 elseif (is_array($authorAlias))
400 {
401 $first = current($authorAlias);
402
403 if (!empty($first))
404 {
405 foreach ($authorAlias as $key => $alias)
406 {
407 $authorAlias[$key] = $db->quote($alias);
408 }
409
410 $authorAlias = implode(',', $authorAlias);
411
412 if ($authorAlias)
413 {
414 $type = $this->getState('filter.author_alias.include', true) ? 'IN' : 'NOT IN';
415 $authorAliasWhere = 'a.created_by_alias ' . $type . ' (' . $authorAlias .
416 ')';
417 }
418 }
419 }
420
421 if (!empty($authorWhere) && !empty($authorAliasWhere))
422 {
423 $query->where('(' . $authorWhere . ' OR ' . $authorAliasWhere . ')');
424 }
425 elseif (empty($authorWhere) && empty($authorAliasWhere))
426 {
427 // If both are empty we don't want to add to the query
428 }
429 else
430 {
431 // One of these is empty, the other is not so we just add both
432 $query->where($authorWhere . $authorAliasWhere);
433 }
434
435 // Define null and now dates
436 $nullDate = $db->quote($db->getNullDate());
437 $nowDate = $db->quote(JFactory::getDate()->toSql());
438
439 // Filter by start and end dates.
440 if ((!$user->authorise('core.edit.state', 'com_content_custom')) && (!$user->authorise('core.edit', 'com_content_custom')))
441 {
442 $query->where('(a.publish_up = ' . $nullDate . ' OR a.publish_up <= ' . $nowDate . ')')
443 ->where('(a.publish_down = ' . $nullDate . ' OR a.publish_down >= ' . $nowDate . ')');
444 }
445
446 // Filter by Date Range or Relative Date
447 $dateFiltering = $this->getState('filter.date_filtering', 'off');
448 $dateField = $this->getState('filter.date_field', 'a.created');
449
450 switch ($dateFiltering)
451 {
452 case 'range':
453 $startDateRange = $db->quote($this->getState('filter.start_date_range', $nullDate));
454 $endDateRange = $db->quote($this->getState('filter.end_date_range', $nullDate));
455 $query->where(
456 '(' . $dateField . ' >= ' . $startDateRange . ' AND ' . $dateField .
457 ' <= ' . $endDateRange . ')'
458 );
459 break;
460
461 case 'relative':
462 $relativeDate = (int) $this->getState('filter.relative_date', 0);
463 $query->where(
464 $dateField . ' >= ' . $query->dateAdd($nowDate, -1 * $relativeDate, 'DAY')
465 );
466 break;
467
468 case 'off':
469 default:
470 break;
471 }
472
473 // Process the filter for list views with user-entered filters
474 if (is_object($params) && ($params->get('filter_field') !== 'hide') && ($filter = $this->getState('list.filter')))
475 {
476 // Clean filter variable
477 $filter = StringHelper::strtolower($filter);
478 $monthFilter = $filter;
479 $hitsFilter = (int) $filter;
480 $filter = $db->quote('%' . $db->escape($filter, true) . '%', false);
481
482 switch ($params->get('filter_field'))
483 {
484 case 'author':
485 $query->where(
486 'LOWER( CASE WHEN a.created_by_alias > ' . $db->quote(' ') .
487 ' THEN a.created_by_alias ELSE ua.name END ) LIKE ' . $filter . ' '
488 );
489 break;
490
491 case 'hits':
492 $query->where('a.hits >= ' . $hitsFilter . ' ');
493 break;
494
495 case 'month':
496 if ($monthFilter != '')
497 {
498 $query->where(
499 $db->quote(date("Y-m-d", strtotime($monthFilter)) . ' 00:00:00') . ' <= CASE WHEN a.publish_up = ' .
500 $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END'
501 );
502
503 $query->where(
504 $db->quote(date("Y-m-t", strtotime($monthFilter)) . ' 23:59:59') . ' >= CASE WHEN a.publish_up = ' .
505 $db->quote($db->getNullDate()) . ' THEN a.created ELSE a.publish_up END'
506 );
507 }
508 break;
509
510 case 'title':
511 default:
512 // Default to 'title' if parameter is not valid
513 $query->where('LOWER( a.title ) LIKE ' . $filter);
514 break;
515 }
516 }
517
518 // Filter by language
519 if ($this->getState('filter.language'))
520 {
521 $query->where('a.language IN (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
522 }
523
524 // Filter by a single or group of tags.
525 $tagId = $this->getState('filter.tag');
526
527 if (is_array($tagId) && count($tagId) === 1)
528 {
529 $tagId = current($tagId);
530 }
531
532 if (is_array($tagId))
533 {
534 $tagId = implode(',', ArrayHelper::toInteger($tagId));
535
536 if ($tagId)
537 {
538 $subQuery = $db->getQuery(true)
539 ->select('DISTINCT content_item_id')
540 ->from($db->quoteName('#__contentitem_tag_map'))
541 ->where('tag_id IN (' . $tagId . ')')
542 ->where('type_alias = ' . $db->quote('com_content_custom.article'));
543
544 $query->innerJoin('(' . (string) $subQuery . ') AS tagmap ON tagmap.content_item_id = a.id');
545 }
546 }
547 elseif ($tagId)
548 {
549 $query->innerJoin(
550 $db->quoteName('#__contentitem_tag_map', 'tagmap')
551 . ' ON tagmap.tag_id = ' . (int) $tagId
552 . ' AND tagmap.content_item_id = a.id'
553 . ' AND tagmap.type_alias = ' . $db->quote('com_content_custom.article')
554 );
555 }
556
557 // Add the list ordering clause.
558 $query->order($this->getState('list.ordering', 'a.ordering') . ' ' . $this->getState('list.direction', 'ASC'));
559
560 return $query;
561 }
562
563 /**
564 * Method to get a list of articles.
565 *
566 * Overriden to inject convert the attribs field into a JParameter object.
567 *
568 * @return mixed An array of objects on success, false on failure.
569 *
570 * @since 1.6
571 */
572 public function getItems()
573 {
574 $items = parent::getItems();
575 $user = JFactory::getUser();
576 $userId = $user->get('id');
577 $guest = $user->get('guest');
578 $groups = $user->getAuthorisedViewLevels();
579 $input = JFactory::getApplication()->input;
580
581 // Get the global params
582 $globalParams = JComponentHelper::getParams('com_content_custom', true);
583
584 // Convert the parameter fields into objects.
585 foreach ($items as &$item)
586 {
587 $articleParams = new Registry($item->attribs);
588
589 // Unpack readmore and layout params
590 $item->alternative_readmore = $articleParams->get('alternative_readmore');
591 $item->layout = $articleParams->get('layout');
592
593 $item->params = clone $this->getState('params');
594
595 /**
596 * For blogs, article params override menu item params only if menu param = 'use_article'
597 * Otherwise, menu item params control the layout
598 * If menu item is 'use_article' and there is no article param, use global
599 */
600 if (($input->getString('layout') === 'blog') || ($input->getString('view') === 'featured')
601 || ($this->getState('params')->get('layout_type') === 'blog'))
602 {
603 // Create an array of just the params set to 'use_article'
604 $menuParamsArray = $this->getState('params')->toArray();
605 $articleArray = array();
606
607 foreach ($menuParamsArray as $key => $value)
608 {
609 if ($value === 'use_article')
610 {
611 // If the article has a value, use it
612 if ($articleParams->get($key) != '')
613 {
614 // Get the value from the article
615 $articleArray[$key] = $articleParams->get($key);
616 }
617 else
618 {
619 // Otherwise, use the global value
620 $articleArray[$key] = $globalParams->get($key);
621 }
622 }
623 }
624
625 // Merge the selected article params
626 if (count($articleArray) > 0)
627 {
628 $articleParams = new Registry($articleArray);
629 $item->params->merge($articleParams);
630 }
631 }
632 else
633 {
634 // For non-blog layouts, merge all of the article params
635 $item->params->merge($articleParams);
636 }
637
638 // Get display date
639 switch ($item->params->get('list_show_date'))
640 {
641 case 'modified':
642 $item->displayDate = $item->modified;
643 break;
644
645 case 'published':
646 $item->displayDate = ($item->publish_up == 0) ? $item->created : $item->publish_up;
647 break;
648
649 default:
650 case 'created':
651 $item->displayDate = $item->created;
652 break;
653 }
654
655 /**
656 * Compute the asset access permissions.
657 * Technically guest could edit an article, but lets not check that to improve performance a little.
658 */
659 if (!$guest)
660 {
661 $asset = 'com_content_custom.article.' . $item->id;
662
663 // Check general edit permission first.
664 if ($user->authorise('core.edit', $asset))
665 {
666 $item->params->set('access-edit', true);
667 }
668
669 // Now check if edit.own is available.
670 elseif (!empty($userId) && $user->authorise('core.edit.own', $asset))
671 {
672 // Check for a valid user and that they are the owner.
673 if ($userId == $item->created_by)
674 {
675 $item->params->set('access-edit', true);
676 }
677 }
678 }
679
680 $access = $this->getState('filter.access');
681
682 if ($access)
683 {
684 // If the access filter has been set, we already have only the articles this user can view.
685 $item->params->set('access-view', true);
686 }
687 else
688 {
689 // If no access filter is set, the layout takes some responsibility for display of limited information.
690 if ($item->catid == 0 || $item->category_access === null)
691 {
692 $item->params->set('access-view', in_array($item->access, $groups));
693 }
694 else
695 {
696 $item->params->set('access-view', in_array($item->access, $groups) && in_array($item->category_access, $groups));
697 }
698 }
699
700 // Some contexts may not use tags data at all, so we allow callers to disable loading tag data
701 if ($this->getState('load_tags', $item->params->get('show_tags', '1')))
702 {
703 $item->tags = new JHelperTags;
704 $item->tags->getItemTags('com_content_custom.article', $item->id);
705 }
706
707 }
708
709 return $items;
710 }
711
712 /**
713 * Method to get the starting number of items for the data set.
714 *
715 * @return integer The starting number of items available in the data set.
716 *
717 * @since 3.0.1
718 */
719 public function getStart()
720 {
721 return $this->getState('list.start');
722 }
723
724 /**
725 * Count Items by Month
726 *
727 * @return mixed An array of objects on success, false on failure.
728 *
729 * @since 3.9.0
730 */
731 public function countItemsByMonth()
732 {
733 // Create a new query object.
734 $db = $this->getDbo();
735 $query = $db->getQuery(true);
736
737 $query
738 ->select('DATE(' .
739 $query->concatenate(
740 array(
741 $query->year($query->quoteName('publish_up')),
742 $query->quote('-'),
743 $query->month($query->quoteName('publish_up')),
744 $query->quote('-01')
745 )
746 ) . ') as d'
747 )
748 ->select('COUNT(*) as c')
749 ->from('(' . $this->getListQuery() . ') as b')
750 ->group($query->quoteName('d'))
751 ->order($query->quoteName('d') . ' desc');
752
753 return $db->setQuery($query)->loadObjectList();
754 }
755 }
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
13 JHtml::_('formbehavior.chosen', 'select');
14 JHtml::_('behavior.caption');
15 ?>
16 <div class="archive-custom<?php echo $this->pageclass_sfx; ?>">
17 <?php if ($this->params->get('show_page_heading')) : ?>
18 <div class="page-header">
19 <h1>
20 <?php echo $this->escape($this->params->get('page_heading')); ?>
21 </h1>
22 </div>
23 <?php endif; ?>
24 <?php echo $this->loadTemplate('items'); ?>
25 </div>
1 <?xml version="1.0" encoding="utf-8"?>
2 <metadata>
3 <layout title="COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE" option="COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION">
4 <help
5 key = "JHELP_MENUS_MENU_ITEM_ARTICLE_ARCHIVED"
6 />
7 <message>
8 <![CDATA[COM_CONTENT_CUSTOM_XML_DESCRIPTION]]>
9 </message>
10 </layout>
11
12 <!-- Add fields to the request variables for the layout. -->
13 <fields name="request">
14 <fieldset name="request"
15 addfieldpath="/administrator/components/com_categories/models/fields"
16 >
17 <field
18 name="catid"
19 type="category"
20 extension="com_content"
21 multiple="true"
22 size="5"
23 label="JCATEGORY"
24 description="JFIELD_CATEGORY_DESC"
25 >
26 <option value="">JOPTION_ALL_CATEGORIES</option>
27 </field>
28 </fieldset>
29 </fields>
30
31 <!-- Add fields to the parameters object for the layout. -->
32 <fields name="params">
33
34 <!-- Basic options. -->
35 <fieldset name="basic" label="JGLOBAL_ARCHIVE_OPTIONS"
36 >
37
38 <field
39 name="orderby_sec"
40 type="list"
41 label="JGLOBAL_ARTICLE_ORDER_LABEL"
42 description="JGLOBAL_ARTICLE_ORDER_DESC"
43 default="rdate"
44 >
45 <option value="date">JGLOBAL_OLDEST_FIRST</option>
46 <option value="rdate">JGLOBAL_MOST_RECENT_FIRST</option>
47 <option value="alpha">JGLOBAL_TITLE_ALPHABETICAL</option>
48 <option value="ralpha">JGLOBAL_TITLE_REVERSE_ALPHABETICAL</option>
49 <option value="author">JGLOBAL_AUTHOR_ALPHABETICAL</option>
50 <option value="rauthor">JGLOBAL_AUTHOR_REVERSE_ALPHABETICAL</option>
51 <option value="hits">JGLOBAL_MOST_HITS</option>
52 <option value="rhits">JGLOBAL_LEAST_HITS</option>
53 <option value="order">JGLOBAL_ARTICLE_MANAGER_ORDER</option>
54 <option value="vote" requires="vote">JGLOBAL_VOTES_DESC</option>
55 <option value="rvote" requires="vote">JGLOBAL_VOTES_ASC</option>
56 <option value="rank" requires="vote">JGLOBAL_RATINGS_DESC</option>
57 <option value="rrank" requires="vote">JGLOBAL_RATINGS_ASC</option>
58 </field>
59
60 <field
61 name="order_date"
62 type="list"
63 label="JGLOBAL_ORDERING_DATE_LABEL"
64 description="JGLOBAL_ORDERING_DATE_DESC"
65 default="published"
66 >
67 <option value="created">JGLOBAL_Created</option>
68 <option value="modified">JGLOBAL_Modified</option>
69 <option value="published">JPUBLISHED</option>
70 </field>
71
72 <field
73 name="display_num"
74 type="list"
75 label="JGLOBAL_NUMBER_ITEMS_LIST_LABEL"
76 description="JGLOBAL_NUMBER_ITEMS_LIST_DESC"
77 default="5"
78 >
79 <option value="5">J5</option>
80 <option value="10">J10</option>
81 <option value="15">J15</option>
82 <option value="20">J20</option>
83 <option value="25">J25</option>
84 <option value="30">J30</option>
85 <option value="50">J50</option>
86 <option value="100">J100</option>
87 <option value="0">JALL</option>
88 </field>
89
90 <field
91 name="filter_field"
92 type="list"
93 label="JGLOBAL_FILTER_FIELD_LABEL"
94 description="JGLOBAL_FILTER_FIELD_DESC"
95 default=""
96 useglobal="true"
97 >
98 <option value="hide">JHIDE</option>
99 <option value="1">JSHOW</option>
100 </field>
101
102 <field
103 name="introtext_limit"
104 type="number"
105 label="JGLOBAL_ARCHIVE_ARTICLES_FIELD_INTROTEXTLIMIT_LABEL"
106 description="JGLOBAL_ARCHIVE_ARTICLES_FIELD_INTROTEXTLIMIT_DESC"
107 default="1000"
108 />
109
110 </fieldset>
111
112 <!-- Articles options. -->
113 <fieldset name="articles"
114 label="COM_CONTENT_CUSTOM_ATTRIBS_ARTICLE_SETTINGS_LABEL"
115 >
116
117 <field
118 name="show_intro"
119 type="list"
120 label="JGLOBAL_SHOW_INTRO_LABEL"
121 description="JGLOBAL_SHOW_INTRO_DESC"
122 class="chzn-color"
123 default="1"
124 >
125 <option value="0">JHIDE</option>
126 <option value="1">JSHOW</option>
127 </field>
128
129 <field
130 name="info_block_position"
131 type="list"
132 label="COM_CONTENT_CUSTOM_FIELD_INFOBLOCK_POSITION_LABEL"
133 description="COM_CONTENT_CUSTOM_FIELD_INFOBLOCK_POSITION_DESC"
134 default=""
135 useglobal="true"
136 class="chzn-color"
137 >
138 <option value="use_article">COM_CONTENT_CUSTOM_FIELD_VALUE_USE_ARTICLE_SETTINGS</option>
139 <option value="0">COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE</option>
140 <option value="1">COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW</option>
141 <option value="2">COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT</option>
142 </field>
143
144 <field
145 name="show_category"
146 type="list"
147 label="JGLOBAL_SHOW_CATEGORY_LABEL"
148 description="JGLOBAL_SHOW_CATEGORY_DESC"
149 useglobal="true"
150 class="chzn-color"
151 >
152 <option value="0">JHIDE</option>
153 <option value="1">JSHOW</option>
154 </field>
155
156 <field
157 name="link_category"
158 type="list"
159 label="JGLOBAL_LINK_CATEGORY_LABEL"
160 description="JGLOBAL_LINK_CATEGORY_DESC"
161 useglobal="true"
162 class="chzn-color"
163 >
164 <option value="0">JNO</option>
165 <option value="1">JYES</option>
166 </field>
167
168 <field
169 name="show_parent_category"
170 type="list"
171 label="JGLOBAL_SHOW_PARENT_CATEGORY_LABEL"
172 description="JGLOBAL_SHOW_PARENT_CATEGORY_DESC"
173 useglobal="true"
174 >
175 <option value="0">JHIDE</option>
176 <option value="1">JSHOW</option>
177 </field>
178
179 <field
180 name="link_parent_category"
181 type="list"
182 label="JGLOBAL_LINK_PARENT_CATEGORY_LABEL"
183 description="JGLOBAL_LINK_PARENT_CATEGORY_DESC"
184 useglobal="true"
185 >
186 <option value="0">JNO</option>
187 <option value="1">JYES</option>
188 </field>
189
190 <field
191 name="link_titles"
192 type="list"
193 label="JGLOBAL_LINKED_TITLES_LABEL"
194 description="JGLOBAL_LINKED_TITLES_DESC"
195 class="chzn-color"
196 default="1"
197 >
198 <option value="0">JNO</option>
199 <option value="1">JYES</option>
200 </field>
201
202 <field
203 name="show_author"
204 type="list"
205 label="JGLOBAL_SHOW_AUTHOR_LABEL"
206 description="JGLOBAL_SHOW_AUTHOR_DESC"
207 useglobal="true"
208 class="chzn-color"
209 >
210 <option value="0">JHIDE</option>
211 <option value="1">JSHOW</option>
212 </field>
213
214 <field
215 name="link_author"
216 type="list"
217 label="JGLOBAL_LINK_AUTHOR_LABEL"
218 description="JGLOBAL_LINK_AUTHOR_DESC"
219 useglobal="true"
220 >
221 <option value="0">JNO</option>
222 <option value="1">JYES</option>
223 </field>
224
225 <field
226 name="show_create_date"
227 type="list"
228 label="JGLOBAL_SHOW_CREATE_DATE_LABEL"
229 description="JGLOBAL_SHOW_CREATE_DATE_DESC"
230 useglobal="true"
231 class="chzn-color"
232 >
233 <option value="0">JHIDE</option>
234 <option value="1">JSHOW</option>
235 </field>
236
237 <field
238 name="show_modify_date"
239 type="list"
240 label="JGLOBAL_SHOW_MODIFY_DATE_LABEL"
241 description="JGLOBAL_SHOW_MODIFY_DATE_DESC"
242 useglobal="true"
243 class="chzn-color"
244 >
245 <option value="0">JHIDE</option>
246 <option value="1">JSHOW</option>
247 </field>
248
249 <field
250 name="show_publish_date"
251 type="list"
252 label="JGLOBAL_SHOW_PUBLISH_DATE_LABEL"
253 description="JGLOBAL_SHOW_PUBLISH_DATE_DESC"
254 class="chzn-color"
255 default="1"
256 >
257 <option value="0">JHIDE</option>
258 <option value="1">JSHOW</option>
259 </field>
260
261 <field
262 name="show_hits"
263 type="list"
264 label="JGLOBAL_SHOW_HITS_LABEL"
265 description="JGLOBAL_SHOW_HITS_DESC"
266 useglobal="true"
267 class="chzn-color"
268 >
269 <option value="0">JHIDE</option>
270 <option value="1">JSHOW</option>
271 </field>
272 </fieldset>
273
274 </fields>
275 </metadata>
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_content_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 JHtml::addIncludePath(JPATH_COMPONENT . '/helpers');
13 $params = $this->params;
14 ?>
15
16 <div id="archive-items">
17 <?php foreach ($this->items as $i => $item) : ?>
18 <?php $info = $item->params->get('info_block_position', 0); ?>
19 <div class="row<?php echo $i % 2; ?>" itemscope itemtype="https://schema.org/Article">
20 <div class="page-header">
21 <h2 itemprop="headline">
22 <?php if ($params->get('link_titles')) : ?>
23 <?php
24 $url = JRoute::_(ContentCustomHelperRoute::getArticleRoute($item->slug, $item->catid, $item->language));
25 $url = "information/" . end(explode("/", $url));
26 ?>
27 <a href="<?php echo $url; ?>" itemprop="url">
28 <?php echo $this->escape($item->title); ?>
29 </a>
30 <?php else : ?>
31 <?php echo $this->escape($item->title); ?>
32 <?php endif; ?>
33 </h2>
34
35 <?php // Content is generated by content plugin event "onContentAfterTitle" ?>
36 <?php echo $item->event->afterDisplayTitle; ?>
37
38 <?php if ($params->get('show_author') && !empty($item->author )) : ?>
39 <div class="createdby" itemprop="author" itemscope itemtype="https://schema.org/Person">
40 <?php $author = $item->created_by_alias ?: $item->author; ?>
41 <?php $author = '<span itemprop="name">' . $author . '</span>'; ?>
42 <?php if (!empty($item->contact_link) && $params->get('link_author') == true) : ?>
43 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_WRITTEN_BY', JHtml::_('link', $this->item->contact_link, $author, array('itemprop' => 'url'))); ?>
44 <?php else : ?>
45 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_WRITTEN_BY', $author); ?>
46 <?php endif; ?>
47 </div>
48 <?php endif; ?>
49 </div>
50 <?php $useDefList = ($params->get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date')
51 || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category')); ?>
52 <?php if ($useDefList && ($info == 0 || $info == 2)) : ?>
53 <div class="article-info muted">
54 <dl class="article-info">
55 <dt class="article-info-term">
56 <?php echo JText::_('COM_CONTENT_CUSTOM_ARTICLE_INFO'); ?>
57 </dt>
58
59 <?php if ($params->get('show_parent_category') && !empty($item->parent_slug)) : ?>
60 <dd>
61 <div class="parent-category-name">
62 <?php $title = $this->escape($item->parent_title); ?>
63 <?php if ($params->get('link_parent_category') && !empty($item->parent_slug)) : ?>
64 <?php $url = '<a href="' . JRoute::_(ContentCustomHelperRoute::getCategoryRoute($item->parent_slug)) . '" itemprop="genre">' . $title . '</a>'; ?>
65 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_PARENT', $url); ?>
66 <?php else : ?>
67 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_PARENT', '<span itemprop="genre">' . $title . '</span>'); ?>
68 <?php endif; ?>
69 </div>
70 </dd>
71 <?php endif; ?>
72 <?php if ($params->get('show_category')) : ?>
73 <dd>
74 <div class="category-name">
75 <?php $title = $this->escape($item->category_title); ?>
76 <?php if ($params->get('link_category') && $item->catslug) : ?>
77 <?php $url = '<a href="' . JRoute::_(ContentCustomHelperRoute::getCategoryRoute($item->catslug)) . '" itemprop="genre">' . $title . '</a>'; ?>
78 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_CATEGORY', $url); ?>
79 <?php else : ?>
80 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_CATEGORY', '<span itemprop="genre">' . $title . '</span>'); ?>
81 <?php endif; ?>
82 </div>
83 </dd>
84 <?php endif; ?>
85
86 <?php if ($params->get('show_publish_date')) : ?>
87 <dd>
88 <div class="published">
89 <span class="icon-calendar" aria-hidden="true"></span>
90 <time datetime="<?php echo JHtml::_('date', $item->publish_up, 'c'); ?>" itemprop="datePublished">
91 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_PUBLISHED_DATE_ON', JHtml::_('date', $item->publish_up, JText::_('DATE_FORMAT_LC3'))); ?>
92 </time>
93 </div>
94 </dd>
95 <?php endif; ?>
96
97 <?php if ($info == 0) : ?>
98 <?php if ($params->get('show_modify_date')) : ?>
99 <dd>
100 <div class="modified">
101 <span class="icon-calendar" aria-hidden="true"></span>
102 <time datetime="<?php echo JHtml::_('date', $item->modified, 'c'); ?>" itemprop="dateModified">
103 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_LAST_UPDATED', JHtml::_('date', $item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
104 </time>
105 </div>
106 </dd>
107 <?php endif; ?>
108 <?php if ($params->get('show_create_date')) : ?>
109 <dd>
110 <div class="create">
111 <span class="icon-calendar" aria-hidden="true"></span>
112 <time datetime="<?php echo JHtml::_('date', $item->created, 'c'); ?>" itemprop="dateCreated">
113 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_CREATED_DATE_ON', JHtml::_('date', $item->created, JText::_('DATE_FORMAT_LC3'))); ?>
114 </time>
115 </div>
116 </dd>
117 <?php endif; ?>
118
119 <?php if ($params->get('show_hits')) : ?>
120 <dd>
121 <div class="hits">
122 <span class="icon-eye-open"></span>
123 <meta itemprop="interactionCount" content="UserPageVisits:<?php echo $item->hits; ?>" />
124 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_ARTICLE_HITS', $item->hits); ?>
125 </div>
126 </dd>
127 <?php endif; ?>
128 <?php endif; ?>
129 </dl>
130 </div>
131 <?php endif; ?>
132
133 <?php // Content is generated by content plugin event "onContentBeforeDisplay" ?>
134 <?php echo $item->event->beforeDisplayContent; ?>
135 <?php if ($params->get('show_intro')) : ?>
136 <div class="intro" itemprop="articleBody"> <?php echo JHtml::_('string.truncateComplex', $item->introtext, $params->get('introtext_limit')); ?> </div>
137 <?php endif; ?>
138
139 <?php if ($useDefList && ($info == 1 || $info == 2)) : ?>
140 <div class="article-info muted">
141 <dl class="article-info">
142 <dt class="article-info-term"><?php echo JText::_('COM_CONTENT_CUSTOM_ARTICLE_INFO'); ?></dt>
143
144 <?php if ($info == 1) : ?>
145 <?php if ($params->get('show_parent_category') && !empty($item->parent_slug)) : ?>
146 <dd>
147 <div class="parent-category-name">
148 <?php $title = $this->escape($item->parent_title); ?>
149 <?php if ($params->get('link_parent_category') && $item->parent_slug) : ?>
150 <?php $url = '<a href="' . JRoute::_(ContentCustomHelperRoute::getCategoryRoute($item->parent_slug)) . '" itemprop="genre">' . $title . '</a>'; ?>
151 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_PARENT', $url); ?>
152 <?php else : ?>
153 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_PARENT', '<span itemprop="genre">' . $title . '</span>'); ?>
154 <?php endif; ?>
155 </div>
156 </dd>
157 <?php endif; ?>
158 <?php if ($params->get('show_category')) : ?>
159 <dd>
160 <div class="category-name">
161 <?php $title = $this->escape($item->category_title); ?>
162 <?php if ($params->get('link_category') && $item->catslug) : ?>
163 <?php $url = '<a href="' . JRoute::_(ContentCustomHelperRoute::getCategoryRoute($item->catslug)) . '" itemprop="genre">' . $title . '</a>'; ?>
164 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_CATEGORY', $url); ?>
165 <?php else : ?>
166 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_CATEGORY', '<span itemprop="genre">' . $title . '</span>'); ?>
167 <?php endif; ?>
168 </div>
169 </dd>
170 <?php endif; ?>
171 <?php if ($params->get('show_publish_date')) : ?>
172 <dd>
173 <div class="published">
174 <span class="icon-calendar" aria-hidden="true"></span>
175 <time datetime="<?php echo JHtml::_('date', $item->publish_up, 'c'); ?>" itemprop="datePublished">
176 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_PUBLISHED_DATE_ON', JHtml::_('date', $item->publish_up, JText::_('DATE_FORMAT_LC3'))); ?>
177 </time>
178 </div>
179 </dd>
180 <?php endif; ?>
181 <?php endif; ?>
182
183 <?php if ($params->get('show_create_date')) : ?>
184 <dd>
185 <div class="create">
186 <span class="icon-calendar" aria-hidden="true"></span>
187 <time datetime="<?php echo JHtml::_('date', $item->created, 'c'); ?>" itemprop="dateCreated">
188 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_CREATED_DATE_ON', JHtml::_('date', $item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
189 </time>
190 </div>
191 </dd>
192 <?php endif; ?>
193 <?php if ($params->get('show_modify_date')) : ?>
194 <dd>
195 <div class="modified">
196 <span class="icon-calendar" aria-hidden="true"></span>
197 <time datetime="<?php echo JHtml::_('date', $item->modified, 'c'); ?>" itemprop="dateModified">
198 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_LAST_UPDATED', JHtml::_('date', $item->modified, JText::_('DATE_FORMAT_LC3'))); ?>
199 </time>
200 </div>
201 </dd>
202 <?php endif; ?>
203 <?php if ($params->get('show_hits')) : ?>
204 <dd>
205 <div class="hits">
206 <span class="icon-eye-open"></span>
207 <meta content="UserPageVisits:<?php echo $item->hits; ?>" itemprop="interactionCount" />
208 <?php echo JText::sprintf('COM_CONTENT_CUSTOM_ARTICLE_HITS', $item->hits); ?>
209 </div>
210 </dd>
211 <?php endif; ?>
212 </dl>
213 </div>
214 <?php endif; ?>
215 <?php // Content is generated by content plugin event "onContentAfterDisplay" ?>
216 <?php echo $item->event->afterDisplayContent; ?>
217 </div>
218 <?php endforeach; ?>
219 </div>
220 <div class="pagination">
221 <p class="counter pull-right"> <?php echo $this->pagination->getPagesCounter(); ?> </p>
222 <?php echo $this->pagination->getPagesLinks(); ?>
223 </div>
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage com_conten_custom
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 /**
13 * HTML View class for the Content component
14 *
15 * @since 1.5
16 */
17 class ContentViewArchive extends JViewLegacy
18 {
19 protected $state = null;
20
21 protected $item = null;
22
23 protected $items = null;
24
25 protected $pagination = null;
26
27 /**
28 * Execute and display a template script.
29 *
30 * @param string $tpl The name of the template file to parse; automatically searches through the template paths.
31 *
32 * @return mixed A string if successful, otherwise an Error object.
33 */
34 public function display($tpl = null)
35 {
36 $user = JFactory::getUser();
37 $state = $this->get('State');
38 $items = $this->get('Items');
39 $pagination = $this->get('Pagination');
40
41 // Flag indicates to not add limitstart=0 to URL
42 $pagination->hideEmptyLimitstart = true;
43
44 // Get the page/component configuration
45 $params = &$state->params;
46
47 JPluginHelper::importPlugin('content_custom');
48
49 foreach ($items as $item)
50 {
51 $item->catslug = $item->category_alias ? ($item->catid . ':' . $item->category_alias) : $item->catid;
52 $item->parent_slug = $item->parent_alias ? ($item->parent_id . ':' . $item->parent_alias) : $item->parent_id;
53
54 // No link for ROOT category
55 if ($item->parent_alias === 'root')
56 {
57 $item->parent_slug = null;
58 }
59
60 $item->event = new stdClass;
61
62 $dispatcher = JEventDispatcher::getInstance();
63
64 // Old plugins: Ensure that text property is available
65 if (!isset($item->text))
66 {
67 $item->text = $item->introtext;
68 }
69
70 $dispatcher->trigger('onContentPrepare', array ('com_content_custom.archive', &$item, &$item->params, 0));
71
72 // Old plugins: Use processed text as introtext
73 $item->introtext = $item->text;
74
75 $results = $dispatcher->trigger('onContentAfterTitle', array('com_content_custom.archive', &$item, &$item->params, 0));
76 $item->event->afterDisplayTitle = trim(implode("\n", $results));
77
78 $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_content_custom.archive', &$item, &$item->params, 0));
79 $item->event->beforeDisplayContent = trim(implode("\n", $results));
80
81 $results = $dispatcher->trigger('onContentAfterDisplay', array('com_content_custom.archive', &$item, &$item->params, 0));
82 $item->event->afterDisplayContent = trim(implode("\n", $results));
83 }
84
85 $this->filter = $state->get('list.filter');
86 $this->items = &$items;
87 $this->params = &$params;
88 $this->user = &$user;
89 $this->pagination = &$pagination;
90 $this->pagination->setAdditionalUrlParam('month', $state->get('filter.month'));
91 $this->pagination->setAdditionalUrlParam('year', $state->get('filter.year'));
92
93 $this->_prepareDocument();
94
95 parent::display($tpl);
96 }
97
98 /**
99 * Prepares the document
100 *
101 * @return void
102 */
103 protected function _prepareDocument()
104 {
105 $app = JFactory::getApplication();
106 $menus = $app->getMenu();
107 $title = null;
108
109 // Because the application sets a default page title,
110 // we need to get it from the menu item itself
111 $menu = $menus->getActive();
112
113 if ($menu)
114 {
115 $this->params->def('page_heading', $this->params->get('page_title', $menu->title));
116 }
117 else
118 {
119 $this->params->def('page_heading', JText::_('JGLOBAL_ARTICLES'));
120 }
121
122 $title = $this->params->get('page_title', '');
123
124 if (empty($title))
125 {
126 $title = $app->get('sitename');
127 }
128 elseif ($app->get('sitename_pagetitles', 0) == 1)
129 {
130 $title = JText::sprintf('JPAGETITLE', $app->get('sitename'), $title);
131 }
132 elseif ($app->get('sitename_pagetitles', 0) == 2)
133 {
134 $title = JText::sprintf('JPAGETITLE', $title, $app->get('sitename'));
135 }
136
137 $this->document->setTitle($title);
138
139 if ($this->params->get('menu-meta_description'))
140 {
141 $this->document->setDescription($this->params->get('menu-meta_description'));
142 }
143
144 if ($this->params->get('menu-meta_keywords'))
145 {
146 $this->document->setMetadata('keywords', $this->params->get('menu-meta_keywords'));
147 }
148
149 if ($this->params->get('robots'))
150 {
151 $this->document->setMetadata('robots', $this->params->get('robots'));
152 }
153 }
154 }
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt
4 ; Note : All ini files need to be saved as UTF-8
5
6 COM_CONTENT_CUSTOM_ARTICLE_HITS="Hits: %s"
7 COM_CONTENT_CUSTOM_ARTICLE_INFO="Details"
8 COM_CONTENT_CUSTOM_CATEGORY="Category: %s"
9 COM_CONTENT_CUSTOM_CREATED_DATE_ON="Created: %s"
10 COM_CONTENT_CUSTOM_LAST_UPDATED="Last Updated: %s"
11 COM_CONTENT_CUSTOM_MONTH="Month"
12 COM_CONTENT_CUSTOM_PARENT="Parent Category: %s"
13 COM_CONTENT_CUSTOM_PUBLISHED_DATE_ON="Published: %s"
14 COM_CONTENT_CUSTOM_WRITTEN_BY="Written by %s"
15 COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE="Above"
16 COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW="Below"
17 COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT="Split"
18 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE="Archived Articles"
19 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION="Default"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt
4 ; Note : All ini files need to be saved as UTF-8
5
6 MOD_ARTICLES_ARCHIVE_CUSTOM="Articles - Archived - custom"
7 MOD_ARTICLES_ARCHIVE_CUSTOM_FIELD_COUNT_LABEL="# of Months"
8 MOD_ARTICLES_ARCHIVE_CUSTOM_FIELD_COUNT_DESC="The number of months to display (the default is 10)."
9 MOD_ARTICLES_ARCHIVE_CUSTOM_XML_DESCRIPTION="Display a list of calendar months, including published articles. This list is automatically generated when you create a published article."
10 MOD_ARTICLES_ARCHIVE_CUSTOM_DATE="%1$s, %2$s"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2019 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt
4 ; Note : All ini files need to be saved as UTF-8
5
6 MOD_ARTICLES_ARCHIVE_CUSTOM="Articles - Archived - custom"
7 MOD_ARTICLES_ARCHIVE_CUSTOM_XML_DESCRIPTION="Display a list of calendar months, including published articles. This list is automatically generated when you create a published article."
8 MOD_ARTICLES_ARCHIVE_CUSTOM_LAYOUT_DEFAULT="Default"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
4 ; Note : All ini files need to be saved as UTF-8
5
6 COM_CONTENT_CUSTOM_ARTICLE_HITS="参照数: %s"
7 COM_CONTENT_CUSTOM_ARTICLE_INFO="詳細"
8 COM_CONTENT_CUSTOM_CATEGORY="カテゴリ: %s"
9 COM_CONTENT_CUSTOM_CREATED_DATE_ON="作成日:%s"
10 COM_CONTENT_CUSTOM_LAST_UPDATED="最終更新日:%s"
11 COM_CONTENT_CUSTOM_MONTH="月"
12 COM_CONTENT_CUSTOM_PARENT="親カテゴリ: %s"
13 COM_CONTENT_CUSTOM_PUBLISHED_DATE_ON="公開日:%s"
14 COM_CONTENT_CUSTOM_WRITTEN_BY="投稿者: %s"
15 COM_CONTENT_CUSTOM_FIELD_OPTION_ABOVE="上"
16 COM_CONTENT_CUSTOM_FIELD_OPTION_BELOW="下"
17 COM_CONTENT_CUSTOM_FIELD_OPTION_SPLIT="分割"
18 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_TITLE="アーカイブ記事"
19 COM_CONTENT_CUSTOM_ARCHIVE_VIEW_DEFAULT_OPTION="標準"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
4 ; Note : All ini files need to be saved as UTF-8
5
6 MOD_ARTICLES_ARCHIVE_CUSTOM="カスタムアーカイブ(モジュール)"
7 MOD_ARTICLES_ARCHIVE_CUSTOM_FIELD_COUNT_LABEL="表示月数"
8 MOD_ARTICLES_ARCHIVE_CUSTOM_FIELD_COUNT_DESC="表示する月数(標準は10)です。"
9 MOD_ARTICLES_ARCHIVE_CUSTOM_XML_DESCRIPTION="公開状態になっている記事を含むカレンダー月の一覧を表示します。公開状態になっている記事を作成すると、この一覧は自動的に生成されます。"
10 MOD_ARTICLES_ARCHIVE_CUSTOM_DATE="%1$s, %2$s"
...\ No newline at end of file ...\ No newline at end of file
1 ; Joomla! Project
2 ; Copyright (C) 2005 - 2017 Open Source Matters. All rights reserved.
3 ; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
4 ; Note : All ini files need to be saved as UTF-8
5
6 MOD_ARTICLES_ARCHIVE_CUSTOM="カスタムアーカイブ(モジュール)"
7 MOD_ARTICLES_ARCHIVE_CUSTOM_XML_DESCRIPTION="公開状態になっている記事を含むカレンダー月の一覧を表示します。公開状態になっている記事を作成すると、この一覧は自動的に生成されます。"
8 MOD_ARTICLES_ARCHIVE_CUSTOM_LAYOUT_DEFAULT="標準"
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage mod_articles_archive
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 /**
13 * Helper for mod_articles_archive
14 *
15 * @since 1.5
16 */
17 class ModArchiveHelper
18 {
19 /**
20 * Retrieve list of archived articles
21 *
22 * @param \Joomla\Registry\Registry &$params module parameters
23 *
24 * @return array
25 *
26 * @since 1.5
27 */
28 public static function getList(&$params)
29 {
30 // Get database
31 $db = JFactory::getDbo();
32 $query = $db->getQuery(true);
33 $query->select($query->month($db->quoteName('created')) . ' AS created_month')
34 ->select('MIN(' . $db->quoteName('created') . ') AS created')
35 ->select($query->year($db->quoteName('created')) . ' AS created_year')
36 ->from('#__content')
37 ->where('state = 1')
38 ->group($query->year($db->quoteName('created')) . ', ' . $query->month($db->quoteName('created')))
39 ->order($query->year($db->quoteName('created')) . ' DESC, ' . $query->month($db->quoteName('created')) . ' DESC');
40
41 // Filter by language
42 if (JFactory::getApplication()->getLanguageFilter())
43 {
44 $query->where('language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
45 }
46
47 $db->setQuery($query, 0, (int) $params->get('count'));
48
49 try
50 {
51 $rows = (array) $db->loadObjectList();
52 }
53 catch (RuntimeException $e)
54 {
55 JFactory::getApplication()->enqueueMessage(JText::_('JERROR_AN_ERROR_HAS_OCCURRED'), 'error');
56
57 return array();
58 }
59
60 $app = JFactory::getApplication();
61 $menu = $app->getMenu();
62 $item = $menu->getItems('link', 'index.php?option=com_content_custom&view=archive', true);
63 $itemid = (isset($item) && !empty($item->id)) ? '&Itemid=' . $item->id : '';
64
65 $i = 0;
66 $lists = array();
67
68 foreach ($rows as $row)
69 {
70 $date = JFactory::getDate($row->created);
71
72 $createdMonth = $date->format('n');
73 $createdYear = $date->format('Y');
74
75 $createdYearCal = JHtml::_('date', $row->created, 'Y') . "年";
76 $monthNameCal = JHtml::_('date', $row->created, 'F');
77 $createdDateCal = $createdYearCal . $monthNameCal;
78
79 $lists[$i] = new stdClass;
80
81 # $lists[$i]->link = JRoute::_('index.php?option=com_content_custom&view=archive&year=' . $createdYear . '&month=' . $createdMonth . $itemid);
82 $link = JRoute::_('index.php?option=com_content_custom&view=archive&year=' . $createdYear . '&month=' . $createdMonth . $itemid);
83 $link = str_replace("/component/content_custom/", "/information/info-archive.html", $link);
84
85 $lists[$i]->link = $link;
86 $lists[$i]->text = JText::sprintf($createdDateCal);
87
88 $i++;
89 }
90
91 return $lists;
92 }
93 }
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage mod_articles_archive
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11
12 // Include the archive functions only once
13 JLoader::register('ModArchiveHelper', __DIR__ . '/helper.php');
14
15 $params->def('count', 10);
16 $moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'), ENT_COMPAT, 'UTF-8');
17 $list = ModArchiveHelper::getList($params);
18
19 require JModuleHelper::getLayoutPath('mod_articles_archive_custom', $params->get('layout', 'default'));
...\ No newline at end of file ...\ No newline at end of file
1 <?xml version="1.0" encoding="utf-8"?>
2 <extension type="module" version="3.1" client="site" method="upgrade">
3 <name>MOD_ARTICLES_ARCHIVE_CUSTOM</name>
4 <author>T.Tokudome</author>
5 <creationDate>June 2020</creationDate>
6 <copyright></copyright>
7 <license></license>
8 <authorEmail>tokudome@lilli.co.jp</authorEmail>
9 <authorUrl></authorUrl>
10 <version>0.0.1</version>
11 <description>MOD_ARTICLES_ARCHIVE_CUSTOM_XML_DESCRIPTION</description>
12 <files>
13 <filename module="mod_articles_archive_custom">mod_articles_archive_custom.php</filename>
14 <folder>tmpl</folder>
15 <filename>helper.php</filename>
16 </files>
17 <languages>
18 <language tag="en-GB">en-GB.mod_articles_archive_custom.ini</language>
19 <language tag="en-GB">en-GB.mod_articles_archive_custom.sys.ini</language>
20 <language tag="ja-JP">ja-JP.mod_articles_archive_custom.ini</language>
21 <language tag="ja-JP">ja-JP.mod_articles_archive_custom.sys.ini</language>
22 </languages>
23 <help key="JHELP_EXTENSIONS_MODULE_MANAGER_ARTICLES_ARCHIVE" />
24 <config>
25 <fields name="params">
26 <fieldset name="basic">
27 <field
28 name="count"
29 type="number"
30 label="MOD_ARTICLES_ARCHIVE_CUSTOM_FIELD_COUNT_LABEL"
31 description="MOD_ARTICLES_ARCHIVE_CUSTOM_FIELD_COUNT_DESC"
32 default="120"
33 filter="integer"
34 />
35 </fieldset>
36
37 <fieldset name="advanced">
38 <field
39 name="layout"
40 type="modulelayout"
41 label="JFIELD_ALT_LAYOUT_LABEL"
42 description="JFIELD_ALT_MODULE_LAYOUT_DESC"
43 />
44
45 <field
46 name="moduleclass_sfx"
47 type="textarea"
48 label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
49 description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC"
50 rows="3"
51 />
52
53 <field
54 name="cache"
55 type="list"
56 label="COM_MODULES_FIELD_CACHING_LABEL"
57 description="COM_MODULES_FIELD_CACHING_DESC"
58 default="1"
59 filter="integer"
60 >
61 <option value="1">JGLOBAL_USE_GLOBAL</option>
62 <option value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
63 </field>
64
65 <field
66 name="cache_time"
67 type="number"
68 label="COM_MODULES_FIELD_CACHE_TIME_LABEL"
69 description="COM_MODULES_FIELD_CACHE_TIME_DESC"
70 default="900"
71 filter="integer"
72 />
73
74 <field
75 name="cachemode"
76 type="hidden"
77 default="static"
78 >
79 <option value="static"></option>
80 </field>
81 </fieldset>
82 </fields>
83 </config>
84 </extension>
...\ No newline at end of file ...\ No newline at end of file
1 <?php
2 /**
3 * @package Joomla.Site
4 * @subpackage mod_articles_archive
5 *
6 * @copyright Copyright (C) 2005 - 2019 Open Source Matters, Inc. All rights reserved.
7 * @license GNU General Public License version 2 or later; see LICENSE.txt
8 */
9
10 defined('_JEXEC') or die;
11 ?>
12 <?php if (!empty($list)) : ?>
13 <ul class="archive-module-custom<?php echo $moduleclass_sfx; ?> mod-list">
14 <?php foreach ($list as $item) : ?>
15 <li>
16 <a href="<?php echo $item->link; ?>">
17 <?php echo $item->text; ?>
18 </a>
19 </li>
20 <?php endforeach; ?>
21 </ul>
22 <?php endif; ?>
1 /* コロナ暫定対処 */ 1 /* コロナ暫定対処 */
2 .covid-19 .mod-articles-category-category { 2 .covid-19 .mod-articles-category-category,
3 .covid-19-news .mod-articles-category-category {
3 display: none; 4 display: none;
4 } 5 }
5 6
......
...@@ -45,7 +45,7 @@ JHtml::_('script', 'template.js', array('version' => 'auto', 'relative' => true) ...@@ -45,7 +45,7 @@ JHtml::_('script', 'template.js', array('version' => 'auto', 'relative' => true)
45 JHtml::_('script', 'jui/html5.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9')); 45 JHtml::_('script', 'jui/html5.js', array('version' => 'auto', 'relative' => true, 'conditional' => 'lt IE 9'));
46 46
47 // Add Stylesheets 47 // Add Stylesheets
48 JHtml::_('stylesheet', 'template.css', array('version' => '20200702001', 'relative' => true)); 48 JHtml::_('stylesheet', 'template.css', array('version' => '20200811002', 'relative' => true));
49 49
50 50
51 // Use of Google Font 51 // Use of Google Font
...@@ -212,7 +212,7 @@ if ($this->params->get('logoFile')) { ...@@ -212,7 +212,7 @@ if ($this->params->get('logoFile')) {
212 var cH = obj.height(); 212 var cH = obj.height();
213 var cwrapH = $("#c_wrap").height(); 213 var cwrapH = $("#c_wrap").height();
214 // 特定のページではスクロールしない 214 // 特定のページではスクロールしない
215 var excludedPages = [".record-page"]; 215 var excludedPages = [".record-page", ".infomation-all-page", ".information-page", ".info-record-page", ".info-exam-page", ."info-news-page", ".info-topix-page", ".info-media-page", ".infomation-all-page"];
216 var excludedPagesSelector = excludedPages.join(', '); 216 var excludedPagesSelector = excludedPages.join(', ');
217 var isExcluded = false; 217 var isExcluded = false;
218 if (document.querySelector(excludedPagesSelector)) { 218 if (document.querySelector(excludedPagesSelector)) {
...@@ -687,8 +687,8 @@ if ($this->params->get('logoFile')) { ...@@ -687,8 +687,8 @@ if ($this->params->get('logoFile')) {
687 <li><a href="/entrance/selective/pe/ao.html">総合型選抜(SS)入試</a></li> 687 <li><a href="/entrance/selective/pe/ao.html">総合型選抜(SS)入試</a></li>
688 <li><a href="/entrance/selective/pe/recommendation.html">学校推薦型選抜</a></li> 688 <li><a href="/entrance/selective/pe/recommendation.html">学校推薦型選抜</a></li>
689 <li><a href="/entrance/selective/pe/exam.html">一般選抜</a></li> 689 <li><a href="/entrance/selective/pe/exam.html">一般選抜</a></li>
690 <li><a href="/entrance/selective/pe/returnee.html">帰国子女入試</a></li> 690 <li><a href="/entrance/selective/pe/returnee.html">帰国生徒選抜</a></li>
691 <li><a href="/entrance/selective/pe/society.html">社会人入試</a></li> 691 <li><a href="/entrance/selective/pe/society.html">社会人選抜</a></li>
692 <li><a href="/entrance/selective/pe/foreign.html">私費外国人留学生入試</a></li> 692 <li><a href="/entrance/selective/pe/foreign.html">私費外国人留学生入試</a></li>
693 <li><a href="/entrance/selective/pe/transfer.html">第3年次編入学試験</a></li> 693 <li><a href="/entrance/selective/pe/transfer.html">第3年次編入学試験</a></li>
694 </ul> 694 </ul>
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!