You've already forked joomla_test
first commit
This commit is contained in:
218
administrator/components/com_banners/helpers/banners.php
Normal file
218
administrator/components/com_banners/helpers/banners.php
Normal file
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Banners component helper.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
* @since 1.6
|
||||
*/
|
||||
class BannersHelper
|
||||
{
|
||||
/**
|
||||
* Configure the Linkbar.
|
||||
*
|
||||
* @param string The name of the active view.
|
||||
*
|
||||
* @return void
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function addSubmenu($vName)
|
||||
{
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_BANNERS_SUBMENU_BANNERS'),
|
||||
'index.php?option=com_banners&view=banners',
|
||||
$vName == 'banners'
|
||||
);
|
||||
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_BANNERS_SUBMENU_CATEGORIES'),
|
||||
'index.php?option=com_categories&extension=com_banners',
|
||||
$vName == 'categories'
|
||||
);
|
||||
if ($vName == 'categories')
|
||||
{
|
||||
JToolbarHelper::title(
|
||||
JText::sprintf('COM_CATEGORIES_CATEGORIES_TITLE', JText::_('com_banners')),
|
||||
'banners-categories');
|
||||
}
|
||||
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_BANNERS_SUBMENU_CLIENTS'),
|
||||
'index.php?option=com_banners&view=clients',
|
||||
$vName == 'clients'
|
||||
);
|
||||
|
||||
JHtmlSidebar::addEntry(
|
||||
JText::_('COM_BANNERS_SUBMENU_TRACKS'),
|
||||
'index.php?option=com_banners&view=tracks',
|
||||
$vName == 'tracks'
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a list of the actions that can be performed.
|
||||
*
|
||||
* @param integer The category ID.
|
||||
*
|
||||
* @return JObject
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function getActions($categoryId = 0)
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$result = new JObject;
|
||||
|
||||
if (empty($categoryId))
|
||||
{
|
||||
$assetName = 'com_banners';
|
||||
$level = 'component';
|
||||
}
|
||||
else
|
||||
{
|
||||
$assetName = 'com_banners.category.'.(int) $categoryId;
|
||||
$level = 'category';
|
||||
}
|
||||
|
||||
$actions = JAccess::getActions('com_banners', $level);
|
||||
|
||||
foreach ($actions as $action)
|
||||
{
|
||||
$result->set($action->name, $user->authorise($action->name, $assetName));
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function updateReset()
|
||||
{
|
||||
$user = JFactory::getUser();
|
||||
$db = JFactory::getDbo();
|
||||
$nullDate = $db->getNullDate();
|
||||
$now = JFactory::getDate();
|
||||
$query = $db->getQuery(true)
|
||||
->select('*')
|
||||
->from('#__banners')
|
||||
->where($db->quote($now) . ' >= ' . $db->quote('reset'))
|
||||
->where($db->quoteName('reset') . ' != ' . $db->quote($nullDate) . ' AND ' . $db->quoteName('reset') . '!=NULL')
|
||||
->where('(' . $db->quoteName('checked_out') . ' = 0 OR ' . $db->quoteName('checked_out') . ' = ' . (int) $db->quote($user->id) . ')');
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$rows = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
|
||||
JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables');
|
||||
|
||||
foreach ($rows as $row)
|
||||
{
|
||||
$purchase_type = $row->purchase_type;
|
||||
|
||||
if ($purchase_type < 0 && $row->cid)
|
||||
{
|
||||
$client = JTable::getInstance('Client', 'BannersTable');
|
||||
$client->load($row->cid);
|
||||
$purchase_type = $client->purchase_type;
|
||||
}
|
||||
|
||||
if ($purchase_type < 0)
|
||||
{
|
||||
$params = JComponentHelper::getParams('com_banners');
|
||||
$purchase_type = $params->get('purchase_type');
|
||||
}
|
||||
|
||||
switch($purchase_type)
|
||||
{
|
||||
case 1:
|
||||
$reset = $nullDate;
|
||||
break;
|
||||
case 2:
|
||||
$date = JFactory::getDate('+1 year '.date('Y-m-d', strtotime('now')));
|
||||
$reset = $db->quote($date->toSql());
|
||||
break;
|
||||
case 3:
|
||||
$date = JFactory::getDate('+1 month '.date('Y-m-d', strtotime('now')));
|
||||
$reset = $db->quote($date->toSql());
|
||||
break;
|
||||
case 4:
|
||||
$date = JFactory::getDate('+7 day '.date('Y-m-d', strtotime('now')));
|
||||
$reset = $db->quote($date->toSql());
|
||||
break;
|
||||
case 5:
|
||||
$date = JFactory::getDate('+1 day '.date('Y-m-d', strtotime('now')));
|
||||
$reset = $db->quote($date->toSql());
|
||||
break;
|
||||
}
|
||||
|
||||
// Update the row ordering field.
|
||||
$query->clear()
|
||||
->update($db->quoteName('#__banners'))
|
||||
->set($db->quoteName('reset') . ' = ' . $db->quote($reset))
|
||||
->set($db->quoteName('impmade') . ' = ' . $db->quote(0))
|
||||
->set($db->quoteName('clicks') . ' = ' . $db->quote(0))
|
||||
->where($db->quoteName('id') . ' = ' . $db->quote($row->id));
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$db->execute();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $db->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static function getClientOptions()
|
||||
{
|
||||
$options = array();
|
||||
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('id As value, name As text')
|
||||
->from('#__banner_clients AS a')
|
||||
->order('a.name');
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$options = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
// Merge any additional options in the XML definition.
|
||||
//$options = array_merge(parent::getOptions(), $options);
|
||||
|
||||
array_unshift($options, JHtml::_('select.option', '0', JText::_('COM_BANNERS_NO_CLIENT')));
|
||||
|
||||
return $options;
|
||||
}
|
||||
}
|
116
administrator/components/com_banners/helpers/html/banner.php
Normal file
116
administrator/components/com_banners/helpers/html/banner.php
Normal file
@ -0,0 +1,116 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
*
|
||||
* @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('JPATH_BASE') or die;
|
||||
|
||||
/**
|
||||
* Banner HTML class.
|
||||
*
|
||||
* @package Joomla.Administrator
|
||||
* @subpackage com_banners
|
||||
* @since 2.5
|
||||
*/
|
||||
abstract class JHtmlBanner
|
||||
{
|
||||
/**
|
||||
* Display a batch widget for the client selector.
|
||||
*
|
||||
* @return string The necessary HTML for the widget.
|
||||
*
|
||||
* @since 2.5
|
||||
*/
|
||||
public static function clients()
|
||||
{
|
||||
JHtml::_('bootstrap.tooltip');
|
||||
|
||||
// Create the batch selector to change the client on a selection list.
|
||||
$lines = array(
|
||||
'<label id="batch-client-lbl" for="batch-client" class="hasTooltip" title="' . JHtml::tooltipText('COM_BANNERS_BATCH_CLIENT_LABEL', 'COM_BANNERS_BATCH_CLIENT_LABEL_DESC') . '">',
|
||||
JText::_('COM_BANNERS_BATCH_CLIENT_LABEL'),
|
||||
'</label>',
|
||||
'<select name="batch[client_id]" class="inputbox" id="batch-client-id">',
|
||||
'<option value="">' . JText::_('COM_BANNERS_BATCH_CLIENT_NOCHANGE') . '</option>',
|
||||
'<option value="0">' . JText::_('COM_BANNERS_NO_CLIENT') . '</option>',
|
||||
JHtml::_('select.options', static::clientlist(), 'value', 'text'),
|
||||
'</select>'
|
||||
);
|
||||
|
||||
return implode("\n", $lines);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method to get the field options.
|
||||
*
|
||||
* @return array The field option objects.
|
||||
* @since 1.6
|
||||
*/
|
||||
public static function clientlist()
|
||||
{
|
||||
$db = JFactory::getDbo();
|
||||
$query = $db->getQuery(true)
|
||||
->select('id As value, name As text')
|
||||
->from('#__banner_clients AS a')
|
||||
->order('a.name');
|
||||
|
||||
// Get the options.
|
||||
$db->setQuery($query);
|
||||
|
||||
try
|
||||
{
|
||||
$options = $db->loadObjectList();
|
||||
}
|
||||
catch (RuntimeException $e)
|
||||
{
|
||||
JError::raiseWarning(500, $e->getMessage());
|
||||
}
|
||||
|
||||
return $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a pinned state on a grid
|
||||
*
|
||||
* @param integer $value The state value.
|
||||
* @param integer $i The row index
|
||||
* @param boolean $enabled An optional setting for access control on the action.
|
||||
* @param string $checkbox An optional prefix for checkboxes.
|
||||
*
|
||||
* @return string The Html code
|
||||
*
|
||||
* @see JHtmlJGrid::state
|
||||
*
|
||||
* @since 2.5.5
|
||||
*/
|
||||
public static function pinned($value, $i, $enabled = true, $checkbox = 'cb')
|
||||
{
|
||||
$states = array(
|
||||
1 => array(
|
||||
'sticky_unpublish',
|
||||
'COM_BANNERS_BANNERS_PINNED',
|
||||
'COM_BANNERS_BANNERS_HTML_PIN_BANNER',
|
||||
'COM_BANNERS_BANNERS_PINNED',
|
||||
true,
|
||||
'publish',
|
||||
'publish'
|
||||
),
|
||||
0 => array(
|
||||
'sticky_publish',
|
||||
'COM_BANNERS_BANNERS_UNPINNED',
|
||||
'COM_BANNERS_BANNERS_HTML_UNPIN_BANNER',
|
||||
'COM_BANNERS_BANNERS_UNPINNED',
|
||||
true,
|
||||
'unpublish',
|
||||
'unpublish'
|
||||
),
|
||||
);
|
||||
|
||||
return JHtml::_('jgrid.state', $states, $value, $i, 'banners.', $enabled, true, $checkbox);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
1
administrator/components/com_banners/helpers/index.html
Normal file
1
administrator/components/com_banners/helpers/index.html
Normal file
@ -0,0 +1 @@
|
||||
<!DOCTYPE html><title></title>
|
Reference in New Issue
Block a user