diff --git a/administrator/components/com_content/config.xml b/administrator/components/com_content/config.xml index 41d2f1203edbf..a28a70046d995 100644 --- a/administrator/components/com_content/config.xml +++ b/administrator/components/com_content/config.xml @@ -122,6 +122,36 @@ hr="true" /> + + + + + + + + + + + + JNO + + + + + + get('view') : $view; $id = empty($id) ? $jinput->getInt('id') : $id; - if ($view == 'article') + if ($view == 'article' || $view == 'category' || $view == 'featured') { if ($id) { @@ -60,4 +60,66 @@ public static function getAssociations($id = 0, $view = null) return array(); } + + /** + * Method to display in frontend the associations for a given article + * + * @param integer $id Id of the article + * + * @return string The url of each associated article + * + * @since __DEPLOY_VERSION__ + */ + public static function displayAssociations($id) + { + $url_assoc = ''; + $associations = self::getAssociations($id); + + if (!empty($associations)) + { + jimport('joomla.application.component.helper'); + $params = JComponentHelper::getParams('com_content'); + $levels = JFactory::getUser()->getAuthorisedViewLevels(); + $languages = JLanguageHelper::getLanguages(); + + foreach ($associations as $key => $value) + { + foreach ($languages as $language) + { + // Do not display language without frontend UI + if (!array_key_exists($language->lang_code, JLanguageMultilang::getSiteLangs())) + { + $key == null; + } + // Do not display language without specific home menu + elseif (!array_key_exists($key, JLanguageMultilang::getSiteHomePages())) + { + $key == null; + } + // Do not display language without authorized access level + elseif (isset($language->access) && $language->access && !in_array($language->access, $levels)) + { + $key == null; + } + elseif (isset($key) && ($key == $language->lang_code)) + { + $class = 'label label-association label-' . $language->sef; + $url = ' ' . strtoupper($language->sef) . ' '; + + if ($params->get('flags', 1)) + { + $flag = JHtml::_('image', 'mod_languages/' . $language->image . '.gif', + $language->title_native, array('title' => $language->title_native), true + ); + $url = ' ' . $flag . ' '; + } + + $url_assoc .= $url; + } + } + } + } + + return $url_assoc; + } } diff --git a/components/com_content/views/article/tmpl/default.php b/components/com_content/views/article/tmpl/default.php index a6e6de972ad4c..2ccc940142192 100644 --- a/components/com_content/views/article/tmpl/default.php +++ b/components/com_content/views/article/tmpl/default.php @@ -18,7 +18,11 @@ $canEdit = $params->get('access-edit'); $user = JFactory::getUser(); $info = $params->get('info_block_position', 0); + +// Check if associations are implemented. If they are, define the parameter. +$assocParam = JLanguageAssociations::isEnabled() ? $params->get('show_associations') : ''; JHtml::_('behavior.caption'); + ?>
@@ -35,7 +39,7 @@ get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date') - || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') ); ?> + || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') || $assocParam); ?> print) : ?>
@@ -134,7 +138,7 @@ get('show_noauth') == true && $user->get('guest')) : ?> item); ?> - item->introtext); ?> + item->introtext); ?> get('show_readmore') && $this->item->fulltext != null) : ?> getMenu(); ?> diff --git a/components/com_content/views/article/tmpl/default.xml b/components/com_content/views/article/tmpl/default.xml index 4f4e9763c6428..d873a5d5c645d 100644 --- a/components/com_content/views/article/tmpl/default.xml +++ b/components/com_content/views/article/tmpl/default.xml @@ -131,6 +131,17 @@ + + + + + + JYES + + + + + + + - - + + item->params->get('access-edit'); $info = $params->get('info_block_position', 0); + +// Check if associations are implemented. If they are, define the parameter. +$assocParam = JLanguageAssociations::isEnabled() ? $params->get('show_associations') : ''; + ?> item->state == 0 || strtotime($this->item->publish_up) > strtotime(JFactory::getDate()) || ((strtotime($this->item->publish_down) < strtotime(JFactory::getDate())) && $this->item->publish_down != JFactory::getDbo()->getNullDate())) : ?> @@ -32,7 +36,7 @@ get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date') - || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') ); ?> + || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') || $assocParam); ?> $this->item, 'params' => $params, 'position' => 'above')); ?> diff --git a/components/com_content/views/category/tmpl/default.xml b/components/com_content/views/category/tmpl/default.xml index 6fe9f78f62caa..25875d3b64b8d 100644 --- a/components/com_content/views/category/tmpl/default.xml +++ b/components/com_content/views/category/tmpl/default.xml @@ -346,6 +346,17 @@ + + + + + + item->params; @@ -135,6 +136,9 @@ escape($article->title); ?> + params->get('show_associations')) : ?> + id); ?> + escape($article->title) . ' : '; @@ -147,6 +151,9 @@ + params->get('show_associations')) : ?> + id); ?> + state == 0) : ?> diff --git a/components/com_content/views/featured/tmpl/default.xml b/components/com_content/views/featured/tmpl/default.xml index b62b0c6fc2273..46bfa001c8d49 100644 --- a/components/com_content/views/featured/tmpl/default.xml +++ b/components/com_content/views/featured/tmpl/default.xml @@ -221,6 +221,17 @@ + + + + + + item->params->get('access-edit'); $info = $this->item->params->get('info_block_position', 0); +// Check if associations are implemented. If they are, define the parameter. +$assocParam = JLanguageAssociations::isEnabled() ? $params->get('show_associations') : ''; + ?> item->state == 0 || strtotime($this->item->publish_up) > strtotime(JFactory::getDate()) @@ -50,7 +53,7 @@ get('show_modify_date') || $params->get('show_publish_date') || $params->get('show_create_date') - || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') ); ?> + || $params->get('show_hits') || $params->get('show_category') || $params->get('show_parent_category') || $params->get('show_author') || $assocParam); ?> $this->item, 'params' => $params, 'position' => 'above')); ?> diff --git a/language/en-GB/en-GB.ini b/language/en-GB/en-GB.ini index 79f7aaedd4bce..05c3a632b2218 100644 --- a/language/en-GB/en-GB.ini +++ b/language/en-GB/en-GB.ini @@ -52,6 +52,7 @@ JALL="All" JALL_LANGUAGE="All" JAPPLY="Save" JARCHIVED="Archived" +JASSOCIATIONS="Also available:" JAUTHOR="Author" JCANCEL="Cancel" JCATEGORY="Category" diff --git a/layouts/joomla/content/info_block/associations.php b/layouts/joomla/content/info_block/associations.php new file mode 100644 index 0000000000000..b79229448cdfe --- /dev/null +++ b/layouts/joomla/content/info_block/associations.php @@ -0,0 +1,19 @@ +id; +?> + +
+ + +
+ diff --git a/layouts/joomla/content/info_block/block.php b/layouts/joomla/content/info_block/block.php index a82946972cf0e..67467188b7335 100644 --- a/layouts/joomla/content/info_block/block.php +++ b/layouts/joomla/content/info_block/block.php @@ -36,9 +36,14 @@ + get('show_associations')) : ?> + + + get('show_publish_date')) : ?> +