You've already forked joomla_test
first commit
This commit is contained in:
136
modules/mod_related_items/helper.php
Normal file
136
modules/mod_related_items/helper.php
Normal file
@ -0,0 +1,136 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_related_items
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
require_once JPATH_SITE . '/components/com_content/helpers/route.php';
|
||||
|
||||
/**
|
||||
* Helper for mod_related_items
|
||||
*
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_related_items
|
||||
* @since 1.5
|
||||
*/
|
||||
abstract class ModRelatedItemsHelper
|
||||
{
|
||||
public static function getList(&$params)
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$app = JFactory::getApplication();
|
||||
$user = JFactory::getUser();
|
||||
$groups = implode(',', $user->getAuthorisedViewLevels());
|
||||
$date = JFactory::getDate();
|
||||
$maximum = (int) $params->get('maximum', 5);
|
||||
|
||||
$option = $app->input->get('option');
|
||||
$view = $app->input->get('view');
|
||||
|
||||
$temp = $app->input->getString('id');
|
||||
$temp = explode(':', $temp);
|
||||
$id = $temp[0];
|
||||
|
||||
$nullDate = $db->getNullDate();
|
||||
$now = $date->toSql();
|
||||
$related = array();
|
||||
$query = $db->getQuery(true);
|
||||
|
||||
if ($option == 'com_content' && $view == 'article' && $id)
|
||||
{
|
||||
// select the meta keywords from the item
|
||||
|
||||
$query->select('metakey')
|
||||
->from('#__content')
|
||||
->where('id = ' . (int) $id);
|
||||
$db->setQuery($query);
|
||||
|
||||
if ($metakey = trim($db->loadResult()))
|
||||
{
|
||||
// explode the meta keys on a comma
|
||||
$keys = explode(',', $metakey);
|
||||
$likes = array();
|
||||
|
||||
// assemble any non-blank word(s)
|
||||
foreach ($keys as $key)
|
||||
{
|
||||
$key = trim($key);
|
||||
if ($key)
|
||||
{
|
||||
$likes[] = $db->escape($key);
|
||||
}
|
||||
}
|
||||
|
||||
if (count($likes))
|
||||
{
|
||||
// select other items based on the metakey field 'like' the keys found
|
||||
$query->clear()
|
||||
->select('a.id')
|
||||
->select('a.title')
|
||||
->select('DATE_FORMAT(a.created, "%Y-%m-%d") as created')
|
||||
->select('a.catid')
|
||||
->select('cc.access AS cat_access')
|
||||
->select('cc.published AS cat_state');
|
||||
|
||||
// Sqlsrv changes
|
||||
$case_when = ' CASE WHEN ';
|
||||
$case_when .= $query->charLength('a.alias', '!=', '0');
|
||||
$case_when .= ' THEN ';
|
||||
$a_id = $query->castAsChar('a.id');
|
||||
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
|
||||
$case_when .= ' ELSE ';
|
||||
$case_when .= $a_id . ' END as slug';
|
||||
$query->select($case_when);
|
||||
|
||||
$case_when = ' CASE WHEN ';
|
||||
$case_when .= $query->charLength('cc.alias', '!=', '0');
|
||||
$case_when .= ' THEN ';
|
||||
$c_id = $query->castAsChar('cc.id');
|
||||
$case_when .= $query->concatenate(array($c_id, 'cc.alias'), ':');
|
||||
$case_when .= ' ELSE ';
|
||||
$case_when .= $c_id . ' END as catslug';
|
||||
$query->select($case_when)
|
||||
->from('#__content AS a')
|
||||
->join('LEFT', '#__content_frontpage AS f ON f.content_id = a.id')
|
||||
->join('LEFT', '#__categories AS cc ON cc.id = a.catid')
|
||||
->where('a.id != ' . (int) $id)
|
||||
->where('a.state = 1')
|
||||
->where('a.access IN (' . $groups . ')');
|
||||
$concat_string = $query->concatenate(array('","', ' REPLACE(a.metakey, ", ", ",")', ' ","'));
|
||||
$query->where('(' . $concat_string . ' LIKE "%' . implode('%" OR ' . $concat_string . ' LIKE "%', $likes) . '%")') //remove single space after commas in keywords)
|
||||
->where('(a.publish_up = ' . $db->quote($nullDate) . ' OR a.publish_up <= ' . $db->quote($now) . ')')
|
||||
->where('(a.publish_down = ' . $db->quote($nullDate) . ' OR a.publish_down >= ' . $db->quote($now) . ')');
|
||||
|
||||
// Filter by language
|
||||
if (JLanguageMultilang::isEnabled())
|
||||
{
|
||||
$query->where('a.language in (' . $db->quote(JFactory::getLanguage()->getTag()) . ',' . $db->quote('*') . ')');
|
||||
}
|
||||
|
||||
$db->setQuery($query, 0, $maximum);
|
||||
$temp = $db->loadObjectList();
|
||||
|
||||
if (count($temp))
|
||||
{
|
||||
foreach ($temp as $row)
|
||||
{
|
||||
if ($row->cat_state == 1)
|
||||
{
|
||||
$row->route = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catslug));
|
||||
$related[] = $row;
|
||||
}
|
||||
}
|
||||
}
|
||||
unset ($temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $related;
|
||||
}
|
||||
}
|
1
modules/mod_related_items/index.html
Normal file
1
modules/mod_related_items/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
32
modules/mod_related_items/mod_related_items.php
Normal file
32
modules/mod_related_items/mod_related_items.php
Normal file
@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_related_items
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Include the syndicate functions only once
|
||||
require_once __DIR__ . '/helper.php';
|
||||
|
||||
$cacheparams = new stdClass;
|
||||
$cacheparams->cachemode = 'safeuri';
|
||||
$cacheparams->class = 'ModRelatedItemsHelper';
|
||||
$cacheparams->method = 'getList';
|
||||
$cacheparams->methodparams = $params;
|
||||
$cacheparams->modeparams = array('id' => 'int', 'Itemid' => 'int');
|
||||
|
||||
$list = JModuleHelper::moduleCache($module, $params, $cacheparams);
|
||||
|
||||
if (!count($list))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
$moduleclass_sfx = htmlspecialchars($params->get('moduleclass_sfx'));
|
||||
$showDate = $params->get('showDate', 0);
|
||||
|
||||
require JModuleHelper::getLayoutPath('mod_related_items', $params->get('layout', 'default'));
|
74
modules/mod_related_items/mod_related_items.xml
Normal file
74
modules/mod_related_items/mod_related_items.xml
Normal file
@ -0,0 +1,74 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension
|
||||
type="module"
|
||||
version="3.1"
|
||||
client="site"
|
||||
method="upgrade">
|
||||
<name>mod_related_items</name>
|
||||
<author>Joomla! Project</author>
|
||||
<creationDate>July 2004</creationDate>
|
||||
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
|
||||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
|
||||
<authorEmail>admin@joomla.org</authorEmail>
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>3.0.0</version>
|
||||
<description>MOD_RELATED_XML_DESCRIPTION</description>
|
||||
<files>
|
||||
<filename module="mod_related_items">mod_related_items.php</filename>
|
||||
<folder>tmpl</folder>
|
||||
<filename>helper.php</filename>
|
||||
<filename>index.html</filename> <filename>mod_related_items.xml</filename>
|
||||
</files>
|
||||
<languages>
|
||||
<language tag="en-GB">en-GB.mod_related_items.ini</language>
|
||||
<language tag="en-GB">en-GB.mod_related_items.sys.ini</language>
|
||||
</languages>
|
||||
<help key="JHELP_EXTENSIONS_MODULE_MANAGER_ARTICLES_RELATED" />
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field
|
||||
name="showDate"
|
||||
type="radio"
|
||||
class="btn-group"
|
||||
default="0"
|
||||
label="MOD_RELATED_FIELD_SHOWDATE_LABEL"
|
||||
description="MOD_RELATED_FIELD_SHOWDATE_DESC">
|
||||
<option
|
||||
value="0">JHIDE</option>
|
||||
<option
|
||||
value="1">JSHOW</option>
|
||||
</field>
|
||||
<field name="maximum"
|
||||
type="text"
|
||||
default="5"
|
||||
label="MOD_RELATED_FIELD_MAX_LABEL"
|
||||
description="MOD_RELATED_FIELD_MAX_DESC" />
|
||||
</fieldset>
|
||||
<fieldset
|
||||
name="advanced">
|
||||
<field
|
||||
name="layout"
|
||||
type="modulelayout"
|
||||
label="JFIELD_ALT_LAYOUT_LABEL"
|
||||
description="JFIELD_ALT_MODULE_LAYOUT_DESC" />
|
||||
<field
|
||||
name="moduleclass_sfx"
|
||||
type="textarea" rows="3"
|
||||
label="COM_MODULES_FIELD_MODULECLASS_SFX_LABEL"
|
||||
description="COM_MODULES_FIELD_MODULECLASS_SFX_DESC" />
|
||||
<field
|
||||
name="owncache"
|
||||
type="list"
|
||||
default="1"
|
||||
label="COM_MODULES_FIELD_CACHING_LABEL"
|
||||
description="COM_MODULES_FIELD_CACHING_DESC">
|
||||
<option
|
||||
value="1">JGLOBAL_USE_GLOBAL</option>
|
||||
<option
|
||||
value="0">COM_MODULES_FIELD_VALUE_NOCACHING</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
20
modules/mod_related_items/tmpl/default.php
Normal file
20
modules/mod_related_items/tmpl/default.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Site
|
||||
* @subpackage mod_related_items
|
||||
*
|
||||
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
?>
|
||||
<ul class="relateditems<?php echo $moduleclass_sfx; ?>">
|
||||
<?php foreach ($list as $item) : ?>
|
||||
<li>
|
||||
<a href="<?php echo $item->route; ?>">
|
||||
<?php if ($showDate) echo JHTML::_('date', $item->created, JText::_('DATE_FORMAT_LC4')). " - "; ?>
|
||||
<?php echo $item->title; ?></a>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
1
modules/mod_related_items/tmpl/index.html
Normal file
1
modules/mod_related_items/tmpl/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
Reference in New Issue
Block a user