You've already forked joomla_test
first commit
This commit is contained in:
166
administrator/modules/mod_k2_stats/helper.php
Normal file
166
administrator/modules/mod_k2_stats/helper.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: helper.php 1813 2013-01-16 11:43:55Z lefteris.kavadas $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die ;
|
||||
|
||||
class modK2StatsHelper
|
||||
{
|
||||
public static function getLatestItems()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT i.*, v.name AS author FROM #__k2_items as i
|
||||
LEFT JOIN #__k2_categories AS c ON c.id = i.catid
|
||||
LEFT JOIN #__users AS v ON v.id = i.created_by
|
||||
WHERE i.trash = 0 AND c.trash = 0
|
||||
ORDER BY i.created DESC";
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
$query = JString::str_ireplace('#__groups', '#__viewlevels', $query);
|
||||
$query = JString::str_ireplace('g.name', 'g.title', $query);
|
||||
}
|
||||
$db->setQuery($query, 0, 10);
|
||||
$rows = $db->loadObjectList();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function getPopularItems()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT i.*, v.name AS author FROM #__k2_items as i
|
||||
LEFT JOIN #__k2_categories AS c ON c.id = i.catid
|
||||
LEFT JOIN #__users AS v ON v.id = i.created_by
|
||||
WHERE i.trash = 0 AND c.trash = 0
|
||||
ORDER BY i.hits DESC";
|
||||
$db->setQuery($query, 0, 10);
|
||||
$rows = $db->loadObjectList();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function getMostCommentedItems()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT i.*, v.name AS author, COUNT(comments.id) AS numOfComments FROM #__k2_items as i
|
||||
LEFT JOIN #__k2_categories AS c ON c.id = i.catid
|
||||
LEFT JOIN #__users AS v ON v.id = i.created_by
|
||||
RIGHT JOIN #__k2_comments comments ON comments.itemID = i.id
|
||||
WHERE i.trash = 0 AND c.trash = 0
|
||||
GROUP BY i.id
|
||||
ORDER BY numOfComments DESC";
|
||||
$db->setQuery($query, 0, 10);
|
||||
$rows = $db->loadObjectList();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function getLatestComments()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT * FROM #__k2_comments ORDER BY commentDate DESC";
|
||||
$db->setQuery($query, 0, 10);
|
||||
$rows = $db->loadObjectList();
|
||||
return $rows;
|
||||
}
|
||||
|
||||
public static function getStatistics()
|
||||
{
|
||||
$statistics = new stdClass;
|
||||
$statistics->numOfItems = self::countItems();
|
||||
$statistics->numOfTrashedItems = self::countTrashedItems();
|
||||
$statistics->numOfFeaturedItems = self::countFeaturedItems();
|
||||
$statistics->numOfComments = self::countComments();
|
||||
$statistics->numOfCategories = self::countCategories();
|
||||
$statistics->numOfTrashedCategories = self::countTrashedCategories();
|
||||
$statistics->numOfUsers = self::countUsers();
|
||||
$statistics->numOfUserGroups = self::countUserGroups();
|
||||
$statistics->numOfTags = self::countTags();
|
||||
return $statistics;
|
||||
}
|
||||
|
||||
public static function countItems()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_items";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countTrashedItems()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_items WHERE trash=1";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countFeaturedItems()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_items WHERE featured=1";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countComments()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_comments";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countCategories()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_categories";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countTrashedCategories()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_categories WHERE trash=1";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countUsers()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_users";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countUserGroups()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_user_groups";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
public static function countTags()
|
||||
{
|
||||
$db = JFactory::getDBO();
|
||||
$query = "SELECT COUNT(*) FROM #__k2_tags";
|
||||
$db->setQuery($query);
|
||||
$result = $db->loadResult();
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
52
administrator/modules/mod_k2_stats/mod_k2_stats.php
Normal file
52
administrator/modules/mod_k2_stats/mod_k2_stats.php
Normal file
@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: mod_k2_stats.php 1851 2013-02-06 17:55:26Z joomlaworks $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die ;
|
||||
|
||||
$user = JFactory::getUser();
|
||||
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
if (!$user->authorise('core.manage', 'com_k2'))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (K2_JVERSION != '15')
|
||||
{
|
||||
$language = JFactory::getLanguage();
|
||||
$language->load('mod_k2.j16', JPATH_ADMINISTRATOR);
|
||||
}
|
||||
|
||||
require_once (dirname(__FILE__).DS.'helper.php');
|
||||
|
||||
if ($params->get('latestItems', 1))
|
||||
{
|
||||
$latestItems = modK2StatsHelper::getLatestItems();
|
||||
}
|
||||
if ($params->get('popularItems', 1))
|
||||
{
|
||||
$popularItems = modK2StatsHelper::getPopularItems();
|
||||
}
|
||||
if ($params->get('mostCommentedItems', 1))
|
||||
{
|
||||
$mostCommentedItems = modK2StatsHelper::getMostCommentedItems();
|
||||
}
|
||||
if ($params->get('latestComments', 1))
|
||||
{
|
||||
$latestComments = modK2StatsHelper::getLatestComments();
|
||||
}
|
||||
if ($params->get('statistics', 1))
|
||||
{
|
||||
$statistics = modK2StatsHelper::getStatistics();
|
||||
}
|
||||
|
||||
require (JModuleHelper::getLayoutPath('mod_k2_stats'));
|
49
administrator/modules/mod_k2_stats/mod_k2_stats.xml
Normal file
49
administrator/modules/mod_k2_stats/mod_k2_stats.xml
Normal file
@ -0,0 +1,49 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<extension type="module" client="administrator" method="upgrade" version="2.5" position="icon">
|
||||
<name>K2 Stats (admin)</name>
|
||||
<author>JoomlaWorks</author>
|
||||
<creationDate>July 8th, 2013</creationDate>
|
||||
<copyright>Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.</copyright>
|
||||
<authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
|
||||
<authorUrl>www.joomlaworks.net</authorUrl>
|
||||
<version>2.6.7</version>
|
||||
<description>K2_STATS_FOR_USE_IN_THE_K2_DASHBOARD_PAGE</description>
|
||||
<files>
|
||||
<filename module="mod_k2_stats">mod_k2_stats.php</filename>
|
||||
<file>helper.php</file>
|
||||
<folder>tmpl</folder>
|
||||
</files>
|
||||
<config>
|
||||
<fields name="params">
|
||||
<fieldset name="basic">
|
||||
<field name="latestItems" type="radio" default="1" label="K2_LATEST_ITEMS_TAB">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="popularItems" type="radio" default="1" label="K2_POPULAR_ITEMS_TAB">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="mostCommentedItems" type="radio" default="1" label="K2_MOST_COMMENTED_ITEMS_TAB">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="latestComments" type="radio" default="1" label="K2_LATEST_COMMENTS_TAB">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
<field name="statistics" type="radio" default="1" label="K2_STATISTICS_TAB">
|
||||
<option value="0">K2_DISABLE</option>
|
||||
<option value="1">K2_ENABLE</option>
|
||||
</field>
|
||||
</fieldset>
|
||||
<fieldset name="advanced">
|
||||
<field name="cache" type="list" default="0" label="K2_CACHING" description="K2_SELECT_WHETHER_TO_CACHE_THE_CONTENT_OF_THIS_MODULE">
|
||||
<option value="0">K2_NO_CACHING</option>
|
||||
<option value="1">K2_USE_GLOBAL</option>
|
||||
</field>
|
||||
<field name="cache_time" type="text" default="900" label="K2_CACHE_TIME" description="K2_THE_TIME_IN_SECONDS_BEFORE_THE_MODULE_IS_RECACHED"/>
|
||||
</fieldset>
|
||||
</fields>
|
||||
</config>
|
||||
</extension>
|
188
administrator/modules/mod_k2_stats/tmpl/default.php
Normal file
188
administrator/modules/mod_k2_stats/tmpl/default.php
Normal file
@ -0,0 +1,188 @@
|
||||
<?php
|
||||
/**
|
||||
* @version $Id: default.php 1851 2013-02-06 17:55:26Z joomlaworks $
|
||||
* @package K2
|
||||
* @author JoomlaWorks http://www.joomlaworks.net
|
||||
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
|
||||
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
|
||||
*/
|
||||
|
||||
// no direct access
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
// Quick and dirty fix for Joomla! 3.0 missing CSS tabs when creating tabs using the API.
|
||||
// Should be removed when Joomla! fixes that...
|
||||
if (K2_JVERSION == '30')
|
||||
{
|
||||
$document = JFactory::getDocument();
|
||||
$document->addStyleDeclaration('
|
||||
dl.tabs {float:left;margin:10px 0 -1px 0;z-index:50;}
|
||||
dl.tabs dt {float:left;padding:4px 10px;border:1px solid #ccc;margin-left:3px;background:#e9e9e9;color:#666;}
|
||||
dl.tabs dt.open {background:#F9F9F9;border-bottom:1px solid #f9f9f9;z-index:100;color:#000;}
|
||||
div.current {clear:both;border:1px solid #ccc;padding:10px 10px;}
|
||||
dl.tabs h3 {font-size:12px;line-height:12px;margin:4px;}
|
||||
');
|
||||
}
|
||||
|
||||
// Import Joomla! tabs
|
||||
jimport('joomla.html.pane');
|
||||
|
||||
?>
|
||||
|
||||
<?php if(K2_JVERSION != '30') $pane = JPane::getInstance('Tabs'); ?>
|
||||
|
||||
<div class="clr"></div>
|
||||
|
||||
<?php echo (K2_JVERSION == '30') ? JHtml::_('tabs.start') : $pane->startPane('myPane'); ?>
|
||||
|
||||
<?php if($params->get('latestItems', 1)): ?>
|
||||
<?php echo (K2_JVERSION == '30') ? JHtml::_('tabs.panel', JText::_('K2_LATEST_ITEMS'), 'latestItemsTab') : $pane->startPanel(JText::_('K2_LATEST_ITEMS'), 'latestItemsTab'); ?>
|
||||
<!--[if lte IE 7]>
|
||||
<br class="ie7fix" />
|
||||
<![endif]-->
|
||||
<table class="adminlist table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="title"><?php echo JText::_('K2_TITLE'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_CREATED'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_AUTHOR'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($latestItems as $latest): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo JRoute::_('index.php?option=com_k2&view=item&cid='.$latest->id); ?>"><?php echo $latest->title; ?></a></td>
|
||||
<td><?php echo JHTML::_('date', $latest->created , JText::_('K2_DATE_FORMAT')); ?></td>
|
||||
<td><?php echo $latest->author; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if(K2_JVERSION != '30') echo $pane->endPanel(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($params->get('popularItems', 1)): ?>
|
||||
<?php echo (K2_JVERSION == '30') ? JHtml::_('tabs.panel', JText::_('K2_POPULAR_ITEMS'), 'popularItemsTab') : $pane->startPanel(JText::_('K2_POPULAR_ITEMS'), 'popularItemsTab'); ?>
|
||||
<!--[if lte IE 7]>
|
||||
<br class="ie7fix" />
|
||||
<![endif]-->
|
||||
<table class="adminlist table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="title"><?php echo JText::_('K2_TITLE'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_HITS'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_CREATED'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_AUTHOR'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($popularItems as $popular): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo JRoute::_('index.php?option=com_k2&view=item&cid='.$popular->id); ?>"><?php echo $popular->title; ?></a></td>
|
||||
<td><?php echo $popular->hits; ?></td>
|
||||
<td><?php echo JHTML::_('date', $popular->created , JText::_('K2_DATE_FORMAT')); ?></td>
|
||||
<td><?php echo $popular->author; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if(K2_JVERSION != '30') echo $pane->endPanel(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($params->get('mostCommentedItems', 1)): ?>
|
||||
<?php echo (K2_JVERSION == '30') ? JHtml::_('tabs.panel', JText::_('K2_MOST_COMMENTED_ITEMS'), 'mostCommentedItemsTab') : $pane->startPanel(JText::_('K2_MOST_COMMENTED_ITEMS'), 'mostCommentedItemsTab'); ?>
|
||||
<!--[if lte IE 7]>
|
||||
<br class="ie7fix" />
|
||||
<![endif]-->
|
||||
<table class="adminlist table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="title"><?php echo JText::_('K2_TITLE'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_COMMENTS'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_CREATED'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_AUTHOR'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($mostCommentedItems as $mostCommented): ?>
|
||||
<tr>
|
||||
<td><a href="<?php echo JRoute::_('index.php?option=com_k2&view=item&cid='.$mostCommented->id); ?>"><?php echo $mostCommented->title; ?></a></td>
|
||||
<td><?php echo $mostCommented->numOfComments; ?></td>
|
||||
<td><?php echo JHTML::_('date', $mostCommented->created , JText::_('K2_DATE_FORMAT')); ?></td>
|
||||
<td><?php echo $mostCommented->author; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if(K2_JVERSION != '30') echo $pane->endPanel(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($params->get('latestComments', 1)): ?>
|
||||
<?php echo (K2_JVERSION == '30') ? JHtml::_('tabs.panel', JText::_('K2_LATEST_COMMENTS'), 'latestCommentsTab') : $pane->startPanel(JText::_('K2_LATEST_COMMENTS'), 'latestCommentsTab'); ?>
|
||||
<!--[if lte IE 7]>
|
||||
<br class="ie7fix" />
|
||||
<![endif]-->
|
||||
<table class="adminlist table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="title"><?php echo JText::_('K2_COMMENT'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_ADDED_ON'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_POSTED_BY'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php foreach($latestComments as $latest): ?>
|
||||
<tr>
|
||||
<td><?php echo $latest->commentText; ?></td>
|
||||
<td><?php echo JHTML::_('date', $latest->commentDate , JText::_('K2_DATE_FORMAT')); ?></td>
|
||||
<td><?php echo $latest->userName; ?></td>
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if(K2_JVERSION != '30') echo $pane->endPanel(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if($params->get('statistics', 1)): ?>
|
||||
<?php echo (K2_JVERSION == '30') ? JHtml::_('tabs.panel', JText::_('K2_STATISTICS'), 'statsTab') : $pane->startPanel(JText::_('K2_STATISTICS'), 'statsTab'); ?>
|
||||
<!--[if lte IE 7]>
|
||||
<br class="ie7fix" />
|
||||
<![endif]-->
|
||||
<table class="adminlist table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<td class="title"><?php echo JText::_('K2_TYPE'); ?></td>
|
||||
<td class="title"><?php echo JText::_('K2_COUNT'); ?></td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><?php echo JText::_('K2_ITEMS'); ?></td>
|
||||
<td><?php echo $statistics->numOfItems; ?> (<?php echo $statistics->numOfFeaturedItems.' '.JText::_('K2_FEATURED').' - '.$statistics->numOfTrashedItems.' '.JText::_('K2_TRASHED'); ?>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo JText::_('K2_CATEGORIES'); ?></td>
|
||||
<td><?php echo $statistics->numOfCategories; ?> (<?php echo $statistics->numOfTrashedCategories.' '.JText::_('K2_TRASHED'); ?>)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo JText::_('K2_TAGS'); ?></td>
|
||||
<td><?php echo $statistics->numOfTags; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo JText::_('K2_COMMENTS'); ?></td>
|
||||
<td><?php echo $statistics->numOfComments; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo JText::_('K2_USERS'); ?></td>
|
||||
<td><?php echo $statistics->numOfUsers; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php echo JText::_('K2_USER_GROUPS'); ?></td>
|
||||
<td><?php echo $statistics->numOfUserGroups; ?></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<?php if(K2_JVERSION != '30') echo $pane->endPanel(); ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php echo K2_JVERSION != '30'? $pane->endPane() : JHtml::_('tabs.end'); ?>
|
Reference in New Issue
Block a user