first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<access component="com_banners">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC" />
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC" />
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC" />
</section>
<section name="category">
<action name="core.create" title="JACTION_CREATE" description="COM_CATEGORIES_ACCESS_CREATE_DESC" />
<action name="core.delete" title="JACTION_DELETE" description="COM_CATEGORIES_ACCESS_DELETE_DESC" />
<action name="core.edit" title="JACTION_EDIT" description="COM_CATEGORIES_ACCESS_EDIT_DESC" />
<action name="core.edit.state" title="JACTION_EDITSTATE" description="COM_CATEGORIES_ACCESS_EDITSTATE_DESC" />
</section>
</access>

View File

@ -0,0 +1,20 @@
<?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;
if (!JFactory::getUser()->authorise('core.manage', 'com_banners'))
{
return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
}
// Execute the task.
$controller = JControllerLegacy::getInstance('Banners');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();

View File

@ -0,0 +1,68 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="3.1" method="upgrade">
<name>com_banners</name>
<author>Joomla! Project</author>
<creationDate>April 2006</creationDate>
<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>COM_BANNERS_XML_DESCRIPTION</description>
<install> <!-- Runs on install -->
<sql>
<file driver="mysql" charset="utf8">sql/install.mysql.utf8.sql</file>
</sql>
</install>
<uninstall> <!-- Runs on uninstall -->
<sql>
<file driver="mysql" charset="utf8">sql/uninstall.mysql.utf8.sql</file>
</sql>
</uninstall>
<files folder="site">
<filename>banners.php</filename>
<filename>controller.php</filename>
<filename>index.html</filename>
<filename>router.php</filename>
<folder>helpers</folder>
<folder>models</folder>
</files>
<administration>
<menu img="class:banners">com_banners</menu>
<submenu>
<!--
Note that all & must be escaped to &amp; for the file to be valid
XML and be parsed by the installer
-->
<menu link="option=com_banners" view="banners" img="class:banners"
alt="Banners/Banners">com_banners_banners</menu>
<menu link="option=com_categories&amp;extension=com_banners"
view="categories" img="class:banners-cat" alt="Banners/Categories">com_banners_categories</menu>
<menu link="option=com_banners&amp;view=clients" view="clients"
img="class:banners-clients" alt="Banners/Clients">com_banners_clients</menu>
<menu link="option=com_banners&amp;view=tracks" view="tracks"
img="class:banners-tracks" alt="Banners/Tracks">com_banners_tracks</menu>
</submenu>
<files folder="admin">
<filename>access.xml</filename>
<filename>banners.php</filename>
<filename>config.xml</filename>
<filename>controller.php</filename>
<filename>index.html</filename>
<folder>controllers</folder>
<folder>helpers</folder>
<folder>models</folder>
<folder>tables</folder>
<folder>views</folder>
</files>
<languages folder="admin">
<language tag="en-GB">language/en-GB.com_banners.ini</language>
<language tag="en-GB">language/en-GB.com_banners.sys.ini</language>
</languages>
</administration>
</extension>

View File

@ -0,0 +1,76 @@
<?xml version="1.0" encoding="utf-8"?>
<config>
<fieldset name="component"
label="COM_BANNERS_FIELDSET_CONFIG_CLIENT_OPTIONS_LABEL"
description="COM_BANNERS_FIELDSET_CONFIG_CLIENT_OPTIONS_DESC">
<field
id="purchase_type"
name="purchase_type"
type="list"
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL"
description="COM_BANNERS_FIELD_PURCHASETYPE_DESC"
default="0"
class="inputbox">
<option
value="1">COM_BANNERS_FIELD_VALUE_1</option>
<option
value="2">COM_BANNERS_FIELD_VALUE_2</option>
<option
value="3">COM_BANNERS_FIELD_VALUE_3</option>
<option
value="4">COM_BANNERS_FIELD_VALUE_4</option>
<option
value="5">COM_BANNERS_FIELD_VALUE_5</option>
</field>
<field
name="track_impressions"
type="radio"
class="btn-group"
default="0"
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
description="COM_BANNERS_FIELD_TRACKIMPRESSION_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="track_clicks"
type="radio"
class="btn-group"
default="0"
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL"
description="COM_BANNERS_FIELD_TRACKCLICK_DESC">
<option
value="0">JNO</option>
<option
value="1">JYES</option>
</field>
<field
name="metakey_prefix"
type="text"
label="COM_BANNERS_FIELD_METAKEYWORDPREFIX_LABEL"
description="COM_BANNERS_FIELD_METAKEYWORDPREFIX_DESC" />
</fieldset>
<fieldset
name="permissions"
label="JCONFIG_PERMISSIONS_LABEL"
description="JCONFIG_PERMISSIONS_DESC"
>
<field
name="rules"
type="rules"
label="JCONFIG_PERMISSIONS_LABEL"
class="inputbox"
filter="rules"
validate="rules"
component="com_banners"
section="component" />
</fieldset>
</config>

View File

@ -0,0 +1,63 @@
<?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 master display controller.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersController extends JControllerLegacy
{
/**
* Method to display a view.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
*/
public function display($cachable = false, $urlparams = false)
{
require_once JPATH_COMPONENT.'/helpers/banners.php';
BannersHelper::updateReset();
$view = $this->input->get('view', 'banners');
$layout = $this->input->get('layout', 'default');
$id = $this->input->getInt('id');
// Check for edit form.
if ($view == 'banner' && $layout == 'edit' && !$this->checkEditId('com_banners.edit.banner', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_banners&view=banners', false));
return false;
}
elseif ($view == 'client' && $layout == 'edit' && !$this->checkEditId('com_banners.edit.client', $id)) {
// Somehow the person just went to the form - we don't allow that.
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
$this->setMessage($this->getError(), 'error');
$this->setRedirect(JRoute::_('index.php?option=com_banners&view=clients', false));
return false;
}
parent::display();
return $this;
}
}

View File

@ -0,0 +1,115 @@
<?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;
/**
* Banner controller class.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersControllerBanner extends JControllerForm
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_BANNERS_BANNER';
/**
* Method override to check if you can add a new record.
*
* @param array $data An array of input data.
*
* @return boolean
*
* @since 1.6
*/
protected function allowAdd($data = array())
{
$user = JFactory::getUser();
$filter = $this->input->getInt('filter_category_id');
$categoryId = JArrayHelper::getValue($data, 'catid', $filter, 'int');
$allow = null;
if ($categoryId)
{
// If the category has been passed in the URL check it.
$allow = $user->authorise('core.create', $this->option . '.category.' . $categoryId);
}
if ($allow === null)
{
// In the absence of better information, revert to the component permissions.
return parent::allowAdd($data);
}
else
{
return $allow;
}
}
/**
* Method override to check if you can edit an existing record.
*
* @param array $data An array of input data.
* @param string $key The name of the key for the primary key.
*
* @return boolean
*
* @since 1.6
*/
protected function allowEdit($data = array(), $key = 'id')
{
$user = JFactory::getUser();
$recordId = (int) isset($data[$key]) ? $data[$key] : 0;
$categoryId = 0;
if ($recordId)
{
$categoryId = (int) $this->getModel()->getItem($recordId)->catid;
}
if ($categoryId)
{
// The category has been set. Check the category permissions.
return $user->authorise('core.edit', $this->option . '.category.' . $categoryId);
}
else
{
// Since there is no asset tracking, revert to the component permissions.
return parent::allowEdit($data, $key);
}
}
/**
* Method to run batch operations.
*
* @param string $model The model
*
* @return boolean True on success.
*
* @since 2.5
*/
public function batch($model = null)
{
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Set the model
$model = $this->getModel('Banner', '', array());
// Preset the redirect
$this->setRedirect(JRoute::_('index.php?option=com_banners&view=banners' . $this->getRedirectToListAppend(), false));
return parent::batch($model);
}
}

View File

@ -0,0 +1,90 @@
<?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 list controller class.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersControllerBanners extends JControllerAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_BANNERS_BANNERS';
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
parent::__construct($config);
$this->registerTask('sticky_unpublish', 'sticky_publish');
}
/**
* Proxy for getModel.
* @since 1.6
*/
public function getModel($name = 'Banner', $prefix = 'BannersModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* @since 1.6
*/
public function sticky_publish()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$ids = $this->input->get('cid', array(), 'array');
$values = array('sticky_publish' => 1, 'sticky_unpublish' => 0);
$task = $this->getTask();
$value = JArrayHelper::getValue($values, $task, 0, 'int');
if (empty($ids))
{
JError::raiseWarning(500, JText::_('COM_BANNERS_NO_BANNERS_SELECTED'));
}
else
{
// Get the model.
$model = $this->getModel();
// Change the state of the records.
if (!$model->stick($ids, $value))
{
JError::raiseWarning(500, $model->getError());
} else {
if ($value == 1)
{
$ntext = 'COM_BANNERS_N_BANNERS_STUCK';
} else {
$ntext = 'COM_BANNERS_N_BANNERS_UNSTUCK';
}
$this->setMessage(JText::plural($ntext, count($ids)));
}
}
$this->setRedirect('index.php?option=com_banners&view=banners');
}
}

View File

@ -0,0 +1,26 @@
<?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;
/**
* Client controller class.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersControllerClient extends JControllerForm
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_BANNERS_CLIENT';
}

View File

@ -0,0 +1,43 @@
<?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;
/**
* Clients list controller class.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersControllerClients extends JControllerAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_BANNERS_CLIENTS';
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Client', $prefix = 'BannersModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,92 @@
<?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;
/**
* Tracks list controller class.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersControllerTracks extends JControllerLegacy
{
/**
* @var string The context for persistent state.
* @since 1.6
*/
protected $context = 'com_banners.tracks';
/**
* Method to get a model object, loading it if required.
*
* @param string $name The model name. Optional.
* @param string $prefix The class prefix. Optional.
* @param array $config Configuration array for model. Optional.
*
* @return object The model.
*
* @since 1.6
*/
public function getModel($name = 'Tracks', $prefix = 'BannersModel', $config = array('ignore_request' => true))
{
$model = parent::getModel($name, $prefix, $config);
return $model;
}
/**
* Method to remove a record.
*
* @return void
* @since 1.6
*/
public function delete()
{
// Check for request forgeries.
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
// Get the model.
$model = $this->getModel();
// Load the filter state.
$app = JFactory::getApplication();
$type = $app->getUserState($this->context.'.filter.type');
$model->setState('filter.type', $type);
$begin = $app->getUserState($this->context.'.filter.begin');
$model->setState('filter.begin', $begin);
$end = $app->getUserState($this->context.'.filter.end');
$model->setState('filter.end', $end);
$categoryId = $app->getUserState($this->context.'.filter.category_id');
$model->setState('filter.category_id', $categoryId);
$clientId = $app->getUserState($this->context.'.filter.client_id');
$model->setState('filter.client_id', $clientId);
$model->setState('list.limit', 0);
$model->setState('list.start', 0);
$count = $model->getTotal();
// Remove the items.
if (!$model->delete())
{
JError::raiseWarning(500, $model->getError());
}
else
{
$this->setMessage(JText::plural('COM_BANNERS_TRACKS_N_ITEMS_DELETED', $count));
}
$this->setRedirect('index.php?option=com_banners&view=tracks');
}
}

View File

@ -0,0 +1,106 @@
<?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;
/**
* Tracks list controller class.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersControllerTracks extends JControllerLegacy
{
/**
* @var string The context for persistent state.
* @since 1.6
*/
protected $context = 'com_banners.tracks';
/**
* Proxy for getModel.
*
* @param string $name The name of the model.
* @param string $prefix The prefix for the model class name.
*
* @return JModel
* @since 1.6
*/
public function getModel($name = 'Tracks', $prefix = 'BannersModel', $config = array())
{
$model = parent::getModel($name, $prefix, array('ignore_request' => true));
return $model;
}
/**
* Display method for the raw track data.
*
* @param boolean If true, the view output will be cached
* @param array An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}.
*
* @return JController This object to support chaining.
* @since 1.5
* @todo This should be done as a view, not here!
*/
public function display($cachable = false, $urlparams = false)
{
// Get the document object.
$document = JFactory::getDocument();
$vName = 'tracks';
$vFormat = 'raw';
// Get and render the view.
if ($view = $this->getView($vName, $vFormat))
{
// Get the model for the view.
$model = $this->getModel($vName);
// Load the filter state.
$app = JFactory::getApplication();
$type = $app->getUserState($this->context.'.filter.type');
$model->setState('filter.type', $type);
$begin = $app->getUserState($this->context.'.filter.begin');
$model->setState('filter.begin', $begin);
$end = $app->getUserState($this->context.'.filter.end');
$model->setState('filter.end', $end);
$categoryId = $app->getUserState($this->context.'.filter.category_id');
$model->setState('filter.category_id', $categoryId);
$clientId = $app->getUserState($this->context.'.filter.client_id');
$model->setState('filter.client_id', $clientId);
$model->setState('list.limit', 0);
$model->setState('list.start', 0);
$form = JRequest::getVar('jform');
$model->setState('basename', $form['basename']);
$model->setState('compressed', $form['compressed']);
$config = JFactory::getConfig();
$cookie_domain = $config->get('cookie_domain', '');
$cookie_path = $config->get('cookie_path', '/');
setcookie(JApplication::getHash($this->context.'.basename'), $form['basename'], time() + 365 * 86400, $cookie_path, $cookie_domain);
setcookie(JApplication::getHash($this->context.'.compressed'), $form['compressed'], time() + 365 * 86400, $cookie_path, $cookie_domain);
// Push the model into the view (as default).
$view->setModel($model, true);
// Push document object into the view.
$view->document = $document;
$view->display();
}
}
}

View 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;
}
}

View 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);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,549 @@
<?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;
/**
* Banner model.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersModelBanner extends JModelAdmin
{
/**
* @var string The prefix to use with controller messages.
* @since 1.6
*/
protected $text_prefix = 'COM_BANNERS_BANNER';
/**
* Method to perform batch operations on an item or a set of items.
*
* @param array $commands An array of commands to perform.
* @param array $pks An array of item ids.
* @param array $contexts An array of item contexts.
*
* @return boolean Returns true on success, false on failure.
*
* @since 2.5
*/
public function batch($commands, $pks, $contexts)
{
// Sanitize user ids.
$pks = array_unique($pks);
JArrayHelper::toInteger($pks);
// Remove any values of zero.
if (array_search(0, $pks, true))
{
unset($pks[array_search(0, $pks, true)]);
}
if (empty($pks))
{
$this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED'));
return false;
}
$done = false;
if (!empty($commands['category_id']))
{
$cmd = JArrayHelper::getValue($commands, 'move_copy', 'c');
if ($cmd == 'c')
{
$result = $this->batchCopy($commands['category_id'], $pks, $contexts);
if (is_array($result))
{
$pks = $result;
}
else
{
return false;
}
}
elseif ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (strlen($commands['client_id']) > 0)
{
if (!$this->batchClient($commands['client_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!empty($commands['language_id']))
{
if (!$this->batchLanguage($commands['language_id'], $pks, $contexts))
{
return false;
}
$done = true;
}
if (!$done)
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
return false;
}
// Clear the cache
$this->cleanCache();
return true;
}
/**
* Batch client changes for a group of banners.
*
* @param string $value The new value matching a client.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True if successful, false otherwise and internal error is set.
*
* @since 2.5
*/
protected function batchClient($value, $pks, $contexts)
{
// Set the variables
$user = JFactory::getUser();
$table = $this->getTable();
foreach ($pks as $pk)
{
if ($user->authorise('core.edit', $contexts[$pk]))
{
$table->reset();
$table->load($pk);
$table->cid = (int) $value;
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));
return false;
}
}
// Clean the cache
$this->cleanCache();
return true;
}
/**
* Batch copy items to a new category or current.
*
* @param integer $value The new category.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return mixed An array of new IDs on success, boolean false on failure.
*
* @since 2.5
*/
protected function batchCopy($value, $pks, $contexts)
{
$categoryId = (int) $value;
$table = $this->getTable();
$i = 0;
// Check that the category exists
if ($categoryId)
{
$categoryTable = JTable::getInstance('Category');
if (!$categoryTable->load($categoryId))
{
if ($error = $categoryTable->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
}
}
if (empty($categoryId))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND'));
return false;
}
// Check that the user has create permission for the component
$user = JFactory::getUser();
if (!$user->authorise('core.create', 'com_banners.category.' . $categoryId))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE'));
return false;
}
// Parent exists so we let's proceed
while (!empty($pks))
{
// Pop the first ID off the stack
$pk = array_shift($pks);
$table->reset();
// Check that the row actually exists
if (!$table->load($pk))
{
if ($error = $table->getError())
{
// Fatal error
$this->setError($error);
return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}
// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $table->alias, $table->name);
$table->name = $data['0'];
$table->alias = $data['1'];
// Reset the ID because we are making a copy
$table->id = 0;
// New category ID
$table->catid = $categoryId;
// TODO: Deal with ordering?
//$table->ordering = 1;
// Check the row.
if (!$table->check())
{
$this->setError($table->getError());
return false;
}
// Store the row.
if (!$table->store())
{
$this->setError($table->getError());
return false;
}
// Get the new item ID
$newId = $table->get('id');
// Add the new ID to the array
$newIds[$i] = $newId;
$i++;
}
// Clean the cache
$this->cleanCache();
return $newIds;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->state != -2)
{
return;
}
$user = JFactory::getUser();
if (!empty($record->catid))
{
return $user->authorise('core.delete', 'com_banners.category.' . (int) $record->catid);
}
else
{
return parent::canDelete($record);
}
}
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
// Check against the category.
if (!empty($record->catid))
{
return $user->authorise('core.edit.state', 'com_banners.category.' . (int) $record->catid);
}
// Default to component settings if category not known.
else
{
return parent::canEditState($record);
}
}
/**
* Returns a JTable object, always creating it.
*
* @param string $type The table type to instantiate. [optional]
* @param string $prefix A prefix for the table class name. [optional]
* @param array $config Configuration array for model. [optional]
*
* @return JTable A database object
*
* @since 1.6
*/
public function getTable($type = 'Banner', $prefix = 'BannersTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form. [optional]
* @param boolean $loadData True if the form is to load its own data (default case), false if not. [optional]
*
* @return mixed A JForm object on success, false on failure
*
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_banners.banner', 'banner', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
// Determine correct permissions to check.
if ($this->getState('banner.id'))
{
// Existing record. Can only edit in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.edit');
}
else
{
// New record. Can only create in selected categories.
$form->setFieldAttribute('catid', 'action', 'core.create');
}
// Modify the form based on access controls.
if (!$this->canEditState((object) $data))
{
// Disable fields for display.
$form->setFieldAttribute('ordering', 'disabled', 'true');
$form->setFieldAttribute('publish_up', 'disabled', 'true');
$form->setFieldAttribute('publish_down', 'disabled', 'true');
$form->setFieldAttribute('state', 'disabled', 'true');
$form->setFieldAttribute('sticky', 'disabled', 'true');
// Disable fields while saving.
// The controller has already verified this is a record you can edit.
$form->setFieldAttribute('ordering', 'filter', 'unset');
$form->setFieldAttribute('publish_up', 'filter', 'unset');
$form->setFieldAttribute('publish_down', 'filter', 'unset');
$form->setFieldAttribute('state', 'filter', 'unset');
$form->setFieldAttribute('sticky', 'filter', 'unset');
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
*
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$app = JFactory::getApplication();
$data = $app->getUserState('com_banners.edit.banner.data', array());
if (empty($data))
{
$data = $this->getItem();
// Prime some default values.
if ($this->getState('banner.id') == 0)
{
$data->set('catid', $app->input->getInt('catid', $app->getUserState('com_banners.banners.filter.category_id')));
}
}
$this->preprocessData('com_banners.banner', $data);
return $data;
}
/**
* Method to stick records.
*
* @param array &$pks The ids of the items to publish.
* @param integer $value The value of the published state
*
* @return boolean True on success.
*
* @since 1.6
*/
public function stick(&$pks, $value = 1)
{
$user = JFactory::getUser();
$table = $this->getTable();
$pks = (array) $pks;
// Access checks.
foreach ($pks as $i => $pk)
{
if ($table->load($pk))
{
if (!$this->canEditState($table))
{
// Prune items that you can't change.
unset($pks[$i]);
JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
}
}
// Attempt to change the state of the records.
if (!$table->stick($pks, $value, $user->get('id')))
{
$this->setError($table->getError());
return false;
}
return true;
}
/**
* A protected method to get a set of ordering conditions.
*
* @param JTable $table A record object.
*
* @return array An array of conditions to add to add to ordering queries.
*
* @since 1.6
*/
protected function getReorderConditions($table)
{
$condition = array();
$condition[] = 'catid = '. (int) $table->catid;
$condition[] = 'state >= 0';
return $condition;
}
/**
* @since 3.0
*/
protected function prepareTable($table)
{
$date = JFactory::getDate();
$user = JFactory::getUser();
if (empty($table->id))
{
// Set the values
$table->created = $date->toSql();
// Set ordering to the last item if not set
if (empty($table->ordering))
{
$db = JFactory::getDbo();
$db->setQuery('SELECT MAX(ordering) FROM #__banners');
$max = $db->loadResult();
$table->ordering = $max + 1;
}
}
else
{
// Set the values
$table->modified = $date->toSql();
$table->modified_by = $user->get('id');
}
// Increment the content version number.
$table->version++;
}
/**
* Method to save the form data.
*
* @param array The form data.
*
* @return boolean True on success.
* @since 1.6
*/
public function save($data)
{
$app = JFactory::getApplication();
// Alter the name for save as copy
if ($app->input->get('task') == 'save2copy')
{
list($name, $alias) = $this->generateNewTitle($data['catid'], $data['alias'], $data['name']);
$data['name'] = $name;
$data['alias'] = $alias;
$data['state'] = 0;
}
if (parent::save($data))
{
return true;
}
return false;
}
}

View File

@ -0,0 +1,252 @@
<?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;
/**
* Methods supporting a list of banner records.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersModelBanners extends JModelList
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'cid', 'a.cid', 'client_name',
'name', 'a.name',
'alias', 'a.alias',
'state', 'a.state',
'ordering', 'a.ordering',
'language', 'a.language',
'catid', 'a.catid', 'category_title',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'created', 'a.created',
'impmade', 'a.impmade',
'imptotal', 'a.imptotal',
'clicks', 'a.clicks',
'publish_up', 'a.publish_up',
'publish_down', 'a.publish_down',
'state', 'sticky', 'a.sticky',
);
}
parent::__construct($config);
}
/**
* Method to get the maximum ordering value for each category.
*
* @since 1.6
*/
public function &getCategoryOrders()
{
if (!isset($this->cache['categoryorders']))
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('MAX(ordering) as ' . $db->quoteName('max') . ', catid')
->select('catid')
->from('#__banners')
->group('catid');
$db->setQuery($query);
$this->cache['categoryorders'] = $db->loadAssocList('catid', 0);
}
return $this->cache['categoryorders'];
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
* @since 1.6
*/
protected function getListQuery()
{
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id AS id, a.name AS name, a.alias AS alias,' .
'a.checked_out AS checked_out,' .
'a.checked_out_time AS checked_out_time, a.catid AS catid,' .
'a.clicks AS clicks, a.metakey AS metakey, a.sticky AS sticky,' .
'a.impmade AS impmade, a.imptotal AS imptotal,' .
'a.state AS state, a.ordering AS ordering,' .
'a.purchase_type as purchase_type,' .
'a.language, a.publish_up, a.publish_down'
)
);
$query->from($db->quoteName('#__banners') . ' AS a');
// Join over the language
$query->select('l.title AS language_title')
->join('LEFT', $db->quoteName('#__languages') . ' AS l ON l.lang_code = a.language');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Join over the categories.
$query->select('c.title AS category_title')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
// Join over the clients.
$query->select('cl.name AS client_name,cl.purchase_type as client_purchase_type')
->join('LEFT', '#__banner_clients AS cl ON cl.id = a.cid');
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
// Filter by category.
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
$query->where('a.catid = ' . (int) $categoryId);
}
// Filter by client.
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
$query->where('a.cid = ' . (int) $clientId);
}
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('(a.name LIKE ' . $search . ' OR a.alias LIKE ' . $search . ')');
}
}
// Filter on the language.
if ($language = $this->getState('filter.language'))
{
$query->where('a.language = ' . $db->quote($language));
}
// Add the list ordering clause.
$orderCol = $this->state->get('list.ordering', 'ordering');
$orderDirn = $this->state->get('list.direction', 'ASC');
if ($orderCol == 'ordering' || $orderCol == 'category_title')
{
$orderCol = 'c.title ' . $orderDirn . ', a.ordering';
}
if ($orderCol == 'client_name')
{
$orderCol = 'cl.name';
}
$query->order($db->escape($orderCol . ' ' . $orderDirn));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
* @return string A store id.
* @since 1.6
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.state');
$id .= ':' . $this->getState('filter.category_id');
$id .= ':' . $this->getState('filter.language');
return parent::getStoreId($id);
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'Banner', $prefix = 'BannersTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
$clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
$language = $this->getUserStateFromRequest($this->context . '.filter.language', 'filter_language', '');
$this->setState('filter.language', $language);
// Load the parameters.
$params = JComponentHelper::getParams('com_banners');
$this->setState('params', $params);
// List state information.
parent::populateState('a.name', 'asc');
}
}

View File

@ -0,0 +1,134 @@
<?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;
/**
* Client model.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersModelClient extends JModelAdmin
{
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to delete the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canDelete($record)
{
if (!empty($record->id))
{
if ($record->state != -2)
{
return;
}
$user = JFactory::getUser();
if (!empty($record->catid))
{
return $user->authorise('core.delete', 'com_banners.category.'.(int) $record->catid);
}
else {
return $user->authorise('core.delete', 'com_banners');
}
}
}
/**
* Method to test whether a record can be deleted.
*
* @param object A record object.
* @return boolean True if allowed to change the state of the record. Defaults to the permission set in the component.
* @since 1.6
*/
protected function canEditState($record)
{
$user = JFactory::getUser();
if (!empty($record->catid))
{
return $user->authorise('core.edit.state', 'com_banners.category.'.(int) $record->catid);
}
else
{
return $user->authorise('core.edit.state', 'com_banners');
}
}
/**
* Returns a reference to the a Table object, always creating it.
*
* @param type The table type to instantiate
* @param string A prefix for the table class name. Optional.
* @param array Configuration array for model. Optional.
* @return JTable A database object
* @since 1.6
*/
public function getTable($type = 'Client', $prefix = 'BannersTable', $config = array())
{
return JTable::getInstance($type, $prefix, $config);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return mixed A JForm object on success, false on failure
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_banners.client', 'client', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
// Check the session for previously entered form data.
$data = JFactory::getApplication()->getUserState('com_banners.edit.client.data', array());
if (empty($data))
{
$data = $this->getItem();
}
$this->preprocessData('com_banners.client', $data);
return $data;
}
/**
* Prepare and sanitise the table data prior to saving.
*
* @param JTable A JTable object.
* @since 1.6
*/
protected function prepareTable($table)
{
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
}
}

View File

@ -0,0 +1,165 @@
<?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;
/**
* Methods supporting a list of banner records.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersModelClients extends JModelList
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'id', 'a.id',
'name', 'a.name',
'contact', 'a.contact',
'state', 'a.state',
'checked_out', 'a.checked_out',
'checked_out_time', 'a.checked_out_time',
'nbanners',
);
}
parent::__construct($config);
}
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$search = $this->getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
$this->setState('filter.search', $search);
$state = $this->getUserStateFromRequest($this->context . '.filter.state', 'filter_state', '', 'string');
$this->setState('filter.state', $state);
// Load the parameters.
$params = JComponentHelper::getParams('com_banners');
$this->setState('params', $params);
// List state information.
parent::populateState('a.name', 'asc');
}
/**
* Method to get a store id based on model configuration state.
*
* This is necessary because the model is used by the component and
* different modules that might need different sets of data or different
* ordering requirements.
*
* @param string $id A prefix for the store id.
*
* @return string A store id.
*/
protected function getStoreId($id = '')
{
// Compile the store id.
$id .= ':' . $this->getState('filter.search');
$id .= ':' . $this->getState('filter.access');
$id .= ':' . $this->getState('filter.state');
return parent::getStoreId($id);
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
*/
protected function getListQuery()
{
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
$this->getState(
'list.select',
'a.id AS id,' .
'a.name AS name,' .
'a.contact AS contact,' .
'a.checked_out AS checked_out,' .
'a.checked_out_time AS checked_out_time, ' .
'a.state AS state,' .
'a.metakey AS metakey,' .
'a.purchase_type as purchase_type'
)
);
$query->from($db->quoteName('#__banner_clients') . ' AS a');
// Join over the banners for counting
$query->select('COUNT(b.id) as nbanners')
->join('LEFT', '#__banners AS b ON a.id = b.cid');
// Join over the users for the checked out user.
$query->select('uc.name AS editor')
->join('LEFT', '#__users AS uc ON uc.id=a.checked_out');
// Filter by published state
$published = $this->getState('filter.state');
if (is_numeric($published))
{
$query->where('a.state = ' . (int) $published);
}
elseif ($published === '')
{
$query->where('(a.state IN (0, 1))');
}
$query->group('a.id, a.name, a.contact, a.checked_out, a.checked_out_time, a.state, a.metakey, a.purchase_type, uc.name');
// Filter by search in title
$search = $this->getState('filter.search');
if (!empty($search))
{
if (stripos($search, 'id:') === 0)
{
$query->where('a.id = ' . (int) substr($search, 3));
}
else
{
$search = $db->quote('%' . $db->escape($search, true) . '%');
$query->where('a.name LIKE ' . $search);
}
}
$ordering_o = $this->getState('list.ordering', 'ordering');
if ($ordering_o == 'nbanners')
{
$ordering_o = 'COUNT(b.id)';
}
// Add the list ordering clause.
$query->order($db->escape($ordering_o) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
//echo nl2br(str_replace('#__','jos_',$query));
return $query;
}
}

View File

@ -0,0 +1,79 @@
<?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;
/**
* Download model.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.5
*/
class BannersModelDownload extends JModelForm
{
protected $_context = 'com_banners.tracks';
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState()
{
$input = JFactory::getApplication()->input;
$basename = $input->cookie->getString(JApplication::getHash($this->_context.'.basename'), '__SITE__');
$this->setState('basename', $basename);
$compressed = $input->cookie->getInt(JApplication::getHash($this->_context.'.compressed'), 1);
$this->setState('compressed', $compressed);
}
/**
* Method to get the record form.
*
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
*
* @return mixed A JForm object on success, false on failure
* @since 1.6
*/
public function getForm($data = array(), $loadData = true)
{
// Get the form.
$form = $this->loadForm('com_banners.download', 'download', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form))
{
return false;
}
return $form;
}
/**
* Method to get the data that should be injected in the form.
*
* @return mixed The data for the form.
* @since 1.6
*/
protected function loadFormData()
{
$data = array(
'basename' => $this->getState('basename'),
'compressed' => $this->getState('compressed')
);
$this->preprocessData('com_banners.download', $data);
return $data;
}
}

View File

@ -0,0 +1,43 @@
<?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;
JFormHelper::loadFieldClass('list');
require_once __DIR__ . '/../../helpers/banners.php';
/**
* Bannerclient Field class for the Joomla Framework.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class JFormFieldBannerClient extends JFormFieldList
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'BannerClient';
/**
* Method to get the field options.
*
* @return array The field option objects.
* @since 1.6
*/
public function getOptions()
{
return BannersHelper::getClientOptions();
}
}

View File

@ -0,0 +1,41 @@
<?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;
/**
* Clicks Field class for the Joomla Framework.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class JFormFieldClicks extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Clicks';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$onclick = ' onclick="document.id(\''.$this->id.'\').value=\'0\';"';
return '<input class="input-small" type="text" name="' . $this->name . '" id="' . $this->id . '" value="' . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '" readonly="readonly" /> <a class="btn" ' . $onclick . '><i class="icon-refresh"></i> ' . JText::_('COM_BANNERS_RESET_CLICKS') . '</a>';
}
}

View File

@ -0,0 +1,41 @@
<?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;
/**
* Clicks Field class for the Joomla Framework.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class JFormFieldImpMade extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ImpMade';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$onclick = ' onclick="document.id(\''.$this->id.'\').value=\'0\';"';
return '<input class="input-small" type="text" name="'.$this->name.'" id="'.$this->id.'" value="'.htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8').'" readonly="readonly" /> <a class="btn" '.$onclick.'><i class="icon-refresh"></i> '.JText::_('COM_BANNERS_RESET_IMPMADE').'</a>';
}
}

View File

@ -0,0 +1,47 @@
<?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;
/**
* Impressions Field class for the Joomla Framework.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class JFormFieldImpTotal extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'ImpTotal';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$class = ' class="validate-numeric text_area"';
$onchange = ' onchange="document.id(\''.$this->id.'_unlimited\').checked=document.id(\''.$this->id.'\').value==\'\';"';
$onclick = ' onclick="if (document.id(\''.$this->id.'_unlimited\').checked) document.id(\''.$this->id.'\').value=\'\';"';
$value = empty($this->value) ? '' : $this->value;
$checked = empty($this->value) ? ' checked="checked"' : '';
return '<input type="text" name="'.$this->name.'" id="'.$this->id.'" size="9" value="'.htmlspecialchars($value, ENT_COMPAT, 'UTF-8').'" '.$class.$onchange.' />
<fieldset class="checkboxes impunlimited"><input id="'.$this->id.'_unlimited" type="checkbox"'.$checked.$onclick.' />
<label for="'.$this->id.'_unlimited" id="jform-imp" type="text">'.JText::_('COM_BANNERS_UNLIMITED').'</label></fieldset>';
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,71 @@
<?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;
/**
* Supports an HTML select list of banners
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class JFormFieldOrdering extends JFormField
{
/**
* The form field type.
*
* @var string
* @since 1.6
*/
protected $type = 'Ordering';
/**
* Method to get the field input markup.
*
* @return string The field input markup.
* @since 1.6
*/
protected function getInput()
{
$html = array();
$attr = '';
// Initialize some field attributes.
$attr .= $this->element['class'] ? ' class="'.(string) $this->element['class'].'"' : '';
$attr .= ((string) $this->element['disabled'] == 'true') ? ' disabled="disabled"' : '';
$attr .= $this->element['size'] ? ' size="'.(int) $this->element['size'].'"' : '';
// Initialize JavaScript field attributes.
$attr .= $this->element['onchange'] ? ' onchange="'.(string) $this->element['onchange'].'"' : '';
// Get some field values from the form.
$bannerId = (int) $this->form->getValue('id');
$categoryId = (int) $this->form->getValue('catid');
// Build the query for the ordering list.
$query = 'SELECT ordering AS value, name AS text' .
' FROM #__banners' .
' WHERE catid = ' . (int) $categoryId .
' ORDER BY ordering';
// Create a read-only list (no name) with a hidden input to store the value.
if ((string) $this->element['readonly'] == 'true')
{
$html[] = JHtml::_('list.ordering', '', $query, trim($attr), $this->value, $bannerId ? 0 : 1);
$html[] = '<input type="hidden" name="'.$this->name.'" value="'.$this->value.'"/>';
}
// Create a regular list.
else {
$html[] = JHtml::_('list.ordering', $this->name, $query, trim($attr), $this->value, $bannerId ? 0 : 1);
}
return implode($html);
}
}

View File

@ -0,0 +1,219 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="details"
addfieldpath="/administrator/components/com_banners/models/fields"
>
<field name="id" type="text" default="0"
readonly="true" class="readonly"
label="JGLOBAL_FIELD_ID_LABEL" description ="JGLOBAL_FIELD_ID_DESC" />
<field name="name" type="text" class="inputbox"
size="40" label="COM_BANNERS_FIELD_NAME_LABEL"
description="COM_BANNERS_FIELD_NAME_DESC" required="true" />
<field name="alias" type="text" class="inputbox"
size="40" label="JFIELD_ALIAS_LABEL"
description="COM_BANNERS_FIELD_ALIAS_DESC" />
<field name="catid" type="categoryedit" extension="com_banners"
label="JCATEGORY" description="COM_BANNERS_FIELD_CATEGORY_DESC"
class="inputbox" required="true"
addfieldpath="/administrator/components/com_categories/models/fields"
>
>
</field>
<field name="state" type="list"
label="JSTATUS" description="COM_BANNERS_FIELD_STATE_DESC"
class="inputbox span12 small" size="1" default="1" >
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="ordering" type="ordering" class="inputbox"
label="JFIELD_ORDERING_LABEL" description="JFIELD_ORDERING_DESC" />
<field name="language" type="contentlanguage" label="JFIELD_LANGUAGE_LABEL"
description="COM_BANNERS_FIELD_LANGUAGE_DESC" class="inputbox span12 small"
>
<option value="*">JALL</option>
</field>
<field name="description" type="textarea" class="inputbox"
rows="3" cols="30" label="JGLOBAL_DESCRIPTION"
description="COM_BANNERS_FIELD_DESCRIPTION_DESC" />
<field name="type" type="list"
label="COM_BANNERS_FIELD_TYPE_LABEL" description="COM_BANNERS_FIELD_TYPE_DESC"
default="0" class="inputbox"
>
<option value="0">COM_BANNERS_FIELD_VALUE_IMAGE
</option>
<option value="1">COM_BANNERS_FIELD_VALUE_CUSTOM
</option>
</field>
<field name="custombannercode" type="textarea" class="inputbox"
rows="3" cols="30" filter="raw"
label="COM_BANNERS_FIELD_CUSTOMCODE_LABEL" description="COM_BANNERS_FIELD_CUSTOMCODE_DESC" />
<field name="clickurl" type="url" class="inputbox" filter="url"
label="COM_BANNERS_FIELD_CLICKURL_LABEL" description="COM_BANNERS_FIELD_CLICKURL_DESC" />
</fieldset>
<fieldset name="publish"
label="COM_BANNERS_GROUP_LABEL_PUBLISHING_DETAILS"
>
<field name="created" type="calendar"
label="COM_BANNERS_FIELD_CREATED_LABEL" description="COM_BANNERS_FIELD_CREATED_DESC"
class="inputbox" size="22" format="%Y-%m-%d %H:%M:%S"
filter="user_utc" />
<field name="created_by" type="user"
label="COM_BANNERS_FIELD_CREATED_BY_LABEL" description="COM_BANNERS_FIELD_CREATED_BY_DESC" />
<field name="created_by_alias" type="text"
label="COM_BANNERS_FIELD_CREATED_BY_ALIAS_LABEL" description="COM_BANNERS_FIELD_CREATED_BY_ALIAS_DESC"
class="inputbox" size="20" />
<field name="modified" type="calendar" class="readonly"
label="JGLOBAL_FIELD_MODIFIED_LABEL" description="COM_BANNERS_FIELD_MODIFIED_DESC"
size="22" readonly="true" format="%Y-%m-%d %H:%M:%S" filter="user_utc" />
<field name="modified_by" type="user"
label="JGLOBAL_FIELD_MODIFIED_BY_LABEL"
class="readonly"
readonly="true"
filter="unset"
/>
<field name="version" type="text" class="readonly"
label="COM_BANNERS_FIELD_VERSION_LABEL" size="6" description="COM_BANNERS_FIELD_VERSION_DESC"
readonly="true" filter="unset" />
<field name="publish_up" type="calendar"
label="COM_BANNERS_FIELD_PUBLISH_UP_LABEL" description="COM_BANNERS_FIELD_PUBLISH_UP_DESC"
class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22"
filter="user_utc" />
<field name="publish_down" type="calendar"
label="COM_BANNERS_FIELD_PUBLISH_DOWN_LABEL" description="COM_BANNERS_FIELD_PUBLISH_DOWN_DESC"
class="inputbox" format="%Y-%m-%d %H:%M:%S" size="22"
filter="user_utc" />
</fieldset>
<fieldset name="bannerdetails"
label="COM_BANNERS_GROUP_LABEL_BANNER_DETAILS"
>
<field name="sticky" type="list" default="0"
label="COM_BANNERS_FIELD_STICKY_LABEL"
description="COM_BANNERS_FIELD_STICKY_DESC"
class="span12 small"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="otherparams">
<field name="imptotal" type="imptotal" default="0"
label="COM_BANNERS_FIELD_IMPTOTAL_LABEL" description="COM_BANNERS_FIELD_IMPTOTAL_DESC" />
<field name="impmade" type="impmade" default="0"
label="COM_BANNERS_FIELD_IMPMADE_LABEL" description="COM_BANNERS_FIELD_IMPMADE_DESC" />
<field name="clicks" type="clicks" default="0"
label="COM_BANNERS_FIELD_CLICKS_LABEL" description="COM_BANNERS_FIELD_CLICKS_DESC" />
<field name="cid" type="bannerclient"
label="COM_BANNERS_FIELD_CLIENT_LABEL" description="COM_BANNERS_FIELD_CLIENT_DESC" />
<field name="purchase_type" type="list"
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL" description="COM_BANNERS_FIELD_PURCHASETYPE_DESC"
default="0" class="inputbox"
>
<option value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT
</option>
<option value="1">COM_BANNERS_FIELD_VALUE_1
</option>
<option value="2">COM_BANNERS_FIELD_VALUE_2
</option>
<option value="3">COM_BANNERS_FIELD_VALUE_3
</option>
<option value="4">COM_BANNERS_FIELD_VALUE_4
</option>
<option value="5">COM_BANNERS_FIELD_VALUE_5
</option>
</field>
<field name="track_impressions" type="list" default="0"
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
description="COM_BANNERS_FIELD_TRACKIMPRESSION_DESC"
>
<option value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT
</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="track_clicks" type="list" default="0"
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL" description="COM_BANNERS_FIELD_TRACKCLICK_DESC"
>
<option value="-1">COM_BANNERS_FIELD_VALUE_USECLIENTDEFAULT
</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS"
>
<field name="metakey" type="textarea" class="inputbox"
rows="3" cols="30" label="JFIELD_META_KEYWORDS_LABEL"
description="COM_BANNERS_FIELD_METAKEYWORDS_DESC" />
<field name="own_prefix" type="radio" class="btn-group"
label="COM_BANNERS_FIELD_BANNEROWNPREFIX_LABEL"
description="COM_BANNERS_FIELD_BANNEROWNPREFIX_DESC"
default="0"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="metakey_prefix" type="text"
label="COM_BANNERS_FIELD_METAKEYWORDPREFIX_LABEL"
description="COM_BANNERS_FIELD_METAKEYWORDPREFIX_DESC" />
</fieldset>
<fields name="params">
<fieldset name="image">
<field name="imageurl" type="media" directory="banners"
hide_none="1" label="COM_BANNERS_FIELD_IMAGE_LABEL"
size="40"
description="COM_BANNERS_FIELD_IMAGE_DESC" />
<field name="width" type="text"
class="inputbox validate-numeric" label="COM_BANNERS_FIELD_WIDTH_LABEL"
description="COM_BANNERS_FIELD_WIDTH_DESC" />
<field name="height" type="text"
class="inputbox validate-numeric" label="COM_BANNERS_FIELD_HEIGHT_LABEL"
description="COM_BANNERS_FIELD_HEIGHT_DESC" />
<field name="alt" type="text" class="inputbox"
label="COM_BANNERS_FIELD_ALT_LABEL" description="COM_BANNERS_FIELD_ALT_DESC" />
</fieldset>
</fields>
<fieldset name="custom">
<field name="bannercode" type="textarea" class="inputbox"
rows="3" cols="30" filter="raw"
label="COM_BANNERS_FIELD_CUSTOMCODE_LABEL" description="COM_BANNERS_FIELD_CUSTOMCODE_DESC" />
</fieldset>
</form>

View File

@ -0,0 +1,103 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="details"
addfieldpath="/administrator/components/com_banners/models/fields"
>
<field name="id" type="text" default="0"
readonly="true" class="readonly"
label="JGLOBAL_FIELD_ID_LABEL" description ="JGLOBAL_FIELD_ID_DESC"/>
<field name="name" type="text" class="inputbox"
size="40" label="COM_BANNERS_FIELD_CLIENT_NAME_LABEL"
description="COM_BANNERS_FIELD_CLIENT_NAME_DESC"
required="true" />
<field name="contact" type="text" class="inputbox"
size="40" label="COM_BANNERS_FIELD_CONTACT_LABEL"
description="COM_BANNERS_FIELD_CONTACT_DESC" required="true" />
<field name="email" type="email" class="inputbox"
size="40" label="COM_BANNERS_FIELD_EMAIL_LABEL"
description="COM_BANNERS_FIELD_EMAIL_DESC" validate="email"
required="true" />
<field name="state" type="list"
label="JSTATUS" description="COM_BANNERS_FIELD_CLIENT_STATE_DESC"
class="inputbox" size="1" default="1"
>
<option value="1">JPUBLISHED</option>
<option value="0">JUNPUBLISHED</option>
<option value="2">JARCHIVED</option>
<option value="-2">JTRASHED</option>
</field>
<field name="purchase_type" type="list"
label="COM_BANNERS_FIELD_PURCHASETYPE_LABEL" description="COM_BANNERS_FIELD_PURCHASETYPE_DESC"
default="0" class="inputbox"
>
<option value="-1">JGLOBAL_USE_GLOBAL
</option>
<option value="1">COM_BANNERS_FIELD_VALUE_1
</option>
<option value="2">COM_BANNERS_FIELD_VALUE_2
</option>
<option value="3">COM_BANNERS_FIELD_VALUE_3
</option>
<option value="4">COM_BANNERS_FIELD_VALUE_4
</option>
<option value="5">COM_BANNERS_FIELD_VALUE_5
</option>
</field>
<field name="track_impressions" type="list" default="0"
label="COM_BANNERS_FIELD_TRACKIMPRESSION_LABEL"
description="COM_BANNERS_FIELD_TRACKIMPRESSION_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="track_clicks" type="list" default="0"
label="COM_BANNERS_FIELD_TRACKCLICK_LABEL" description="COM_BANNERS_FIELD_TRACKCLICK_DESC"
>
<option value="">JGLOBAL_USE_GLOBAL</option>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
<fieldset name="metadata"
label="JGLOBAL_FIELDSET_METADATA_OPTIONS"
>
<field name="metakey" type="textarea" class="inputbox"
rows="3" cols="30" label="JFIELD_META_KEYWORDS_LABEL"
description="COM_BANNERS_FIELD_CLIENT_METAKEYWORDS_DESC" />
<field name="own_prefix" type="radio" class="btn-group"
label="COM_BANNERS_FIELD_CLIENTOWNPREFIX_LABEL"
description="COM_BANNERS_FIELD_CLIENTOWNPREFIX_DESC"
default="0"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="metakey_prefix" type="text"
label="COM_BANNERS_FIELD_CLIENT_METAKEYWORDPREFIX_LABEL"
description="COM_BANNERS_FIELD_CLIENT_METAKEYWORDPREFIX_DESC" />
</fieldset>
<fieldset name="extra" label="Banners_Extra">
<field name="extrainfo" type="textarea" class="inputbox"
rows="10" cols="40" label="COM_BANNERS_FIELD_EXTRAINFO_LABEL"
description="COM_BANNERS_FIELD_EXTRAINFO_DESC" />
</fieldset>
</form>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<fieldset name="details">
<field name="compressed" type="radio" class="btn-group"
label="COM_BANNERS_FIELD_COMPRESSED_LABEL"
description="COM_BANNERS_FIELD_COMPRESSED_DESC"
default="0"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="basename" type="text"
class="inputbox" size="40"
label="COM_BANNERS_FIELD_BASENAME_LABEL" description="COM_BANNERS_FIELD_BASENAME_DESC" />
</fieldset>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,515 @@
<?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;
/**
* Methods supporting a list of tracks.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersModelTracks extends JModelList
{
/**
* Constructor.
*
* @param array An optional associative array of configuration settings.
* @see JController
* @since 1.6
*/
public function __construct($config = array())
{
if (empty($config['filter_fields']))
{
$config['filter_fields'] = array(
'name', 'b.name',
'cl.name', 'client_name',
'cat.title', 'category_title',
'track_type', 'a.track_type',
'count', 'a.count',
'track_date', 'a.track_date',
);
}
parent::__construct($config);
}
/**
* @since 1.6
*/
protected $basename;
/**
* Method to auto-populate the model state.
*
* Note. Calling getState in this method will result in recursion.
*
* @since 1.6
*/
protected function populateState($ordering = null, $direction = null)
{
// Load the filter state.
$type = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type');
$this->setState('filter.type', $type);
$begin = $this->getUserStateFromRequest($this->context . '.filter.begin', 'filter_begin', '', 'string');
$this->setState('filter.begin', $begin);
$end = $this->getUserStateFromRequest($this->context . '.filter.end', 'filter_end', '', 'string');
$this->setState('filter.end', $end);
$categoryId = $this->getUserStateFromRequest($this->context . '.filter.category_id', 'filter_category_id', '');
$this->setState('filter.category_id', $categoryId);
$clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
$this->setState('filter.client_id', $clientId);
// Load the parameters.
$params = JComponentHelper::getParams('com_banners');
$this->setState('params', $params);
// List state information.
parent::populateState('b.name', 'asc');
}
/**
* Build an SQL query to load the list data.
*
* @return JDatabaseQuery
* @since 1.6
*/
protected function getListQuery()
{
require_once JPATH_COMPONENT . '/helpers/banners.php';
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
// Select the required fields from the table.
$query->select(
'a.track_date as track_date,'
. 'a.track_type as track_type,'
. $db->quoteName('a.count') . ' as ' . $db->quoteName('count')
);
$query->from($db->quoteName('#__banner_tracks') . ' AS a');
// Join with the banners
$query->join('LEFT', $db->quoteName('#__banners') . ' as b ON b.id=a.banner_id')
->select('b.name as name');
// Join with the client
$query->join('LEFT', $db->quoteName('#__banner_clients') . ' as cl ON cl.id=b.cid')
->select('cl.name as client_name');
// Join with the category
$query->join('LEFT', $db->quoteName('#__categories') . ' as cat ON cat.id=b.catid')
->select('cat.title as category_title');
// Filter by type
$type = $this->getState('filter.type');
if (!empty($type))
{
$query->where('a.track_type = ' . (int) $type);
}
// Filter by client
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
$query->where('b.cid = ' . (int) $clientId);
}
// Filter by category
$catedoryId = $this->getState('filter.category_id');
if (is_numeric($catedoryId))
{
$query->where('b.catid = ' . (int) $catedoryId);
}
// Filter by begin date
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
$query->where('a.track_date >= ' . $db->quote($begin));
}
// Filter by end date
$end = $this->getState('filter.end');
if (!empty($end))
{
$query->where('a.track_date <= ' . $db->quote($end));
}
// Add the list ordering clause.
$orderCol = $this->getState('list.ordering', 'name');
$query->order($db->escape($orderCol) . ' ' . $db->escape($this->getState('list.direction', 'ASC')));
return $query;
}
/**
* Method to delete rows.
*
* @param array An array of item ids.
*
* @return boolean Returns true on success, false on failure.
*/
public function delete()
{
$user = JFactory::getUser();
$categoryId = $this->getState('category_id');
// Access checks.
if ($categoryId)
{
$allow = $user->authorise('core.delete', 'com_banners.category.' . (int) $categoryId);
}
else
{
$allow = $user->authorise('core.delete', 'com_banners');
}
if ($allow)
{
// Delete tracks from this banner
$db = $this->getDbo();
$query = $db->getQuery(true)
->delete($db->quoteName('#__banner_tracks'));
// Filter by type
$type = $this->getState('filter.type');
if (!empty($type))
{
$query->where('track_type = ' . (int) $type);
}
// Filter by begin date
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
$query->where('track_date >= ' . $db->quote($begin));
}
// Filter by end date
$end = $this->getState('filter.end');
if (!empty($end))
{
$query->where('track_date <= ' . $db->quote($end));
}
$where = '1';
// Filter by client
$clientId = $this->getState('filter.client_id');
if (!empty($clientId))
{
$where .= ' AND cid = ' . (int) $clientId;
}
// Filter by category
if (!empty($categoryId))
{
$where .= ' AND catid = ' . (int) $categoryId;
}
$query->where('banner_id IN (SELECT id FROM ' . $db->quoteName('#__banners') . ' WHERE ' . $where . ')');
$db->setQuery($query);
$this->setError((string) $query);
try
{
$db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
else
{
JError::raiseWarning(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
return true;
}
/**
* Get file name
*
* @return string The file name
* @since 1.6
*/
public function getBaseName()
{
if (!isset($this->basename))
{
$app = JFactory::getApplication();
$basename = $this->getState('basename');
$basename = str_replace('__SITE__', $app->getCfg('sitename'), $basename);
$categoryId = $this->getState('filter.category_id');
if (is_numeric($categoryId))
{
if ($categoryId > 0)
{
$basename = str_replace('__CATID__', $categoryId, $basename);
}
else
{
$basename = str_replace('__CATID__', '', $basename);
}
$categoryName = $this->getCategoryName();
$basename = str_replace('__CATNAME__', $categoryName, $basename);
}
else
{
$basename = str_replace('__CATID__', '', $basename);
$basename = str_replace('__CATNAME__', '', $basename);
}
$clientId = $this->getState('filter.client_id');
if (is_numeric($clientId))
{
if ($clientId > 0)
{
$basename = str_replace('__CLIENTID__', $clientId, $basename);
}
else
{
$basename = str_replace('__CLIENTID__', '', $basename);
}
$clientName = $this->getClientName();
$basename = str_replace('__CLIENTNAME__', $clientName, $basename);
}
else
{
$basename = str_replace('__CLIENTID__', '', $basename);
$basename = str_replace('__CLIENTNAME__', '', $basename);
}
$type = $this->getState('filter.type');
if ($type > 0)
{
$basename = str_replace('__TYPE__', $type, $basename);
$typeName = JText::_('COM_BANNERS_TYPE' . $type);
$basename = str_replace('__TYPENAME__', $typeName, $basename);
}
else
{
$basename = str_replace('__TYPE__', '', $basename);
$basename = str_replace('__TYPENAME__', '', $basename);
}
$begin = $this->getState('filter.begin');
if (!empty($begin))
{
$basename = str_replace('__BEGIN__', $begin, $basename);
}
else
{
$basename = str_replace('__BEGIN__', '', $basename);
}
$end = $this->getState('filter.end');
if (!empty($end))
{
$basename = str_replace('__END__', $end, $basename);
}
else
{
$basename = str_replace('__END__', '', $basename);
}
$this->basename = $basename;
}
return $this->basename;
}
/**
* Get the category name.
*
* @return string The category name
* @since 1.6
*/
protected function getCategoryName()
{
$categoryId = $this->getState('filter.category_id');
if ($categoryId)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('title')
->from($db->quoteName('#__categories'))
->where($db->quoteName('id') . '=' . $db->quote($categoryId));
$db->setQuery($query);
try
{
$name = $db->loadResult();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
else
{
$name = JText::_('COM_BANNERS_NOCATEGORYNAME');
}
return $name;
}
/**
* Get the category name
*
* @return string The category name.
* @since 1.6
*/
protected function getClientName()
{
$clientId = $this->getState('filter.client_id');
if ($clientId)
{
$db = $this->getDbo();
$query = $db->getQuery(true)
->select('name')
->from($db->quoteName('#__banner_clients'))
->where($db->quoteName('id') . '=' . $db->quote($clientId));
$db->setQuery($query);
try
{
$name = $db->loadResult();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
}
else
{
$name = JText::_('COM_BANNERS_NOCLIENTNAME');
}
return $name;
}
/**
* Get the file type.
*
* @return string The file type
* @since 1.6
*/
public function getFileType()
{
return $this->getState('compressed') ? 'zip' : 'csv';
}
/**
* Get the mime type.
*
* @return string The mime type.
* @since 1.6
*/
public function getMimeType()
{
return $this->getState('compressed') ? 'application/zip' : 'text/csv';
}
/**
* Get the content
*
* @return string The content.
* @since 1.6
*/
public function getContent()
{
if (!isset($this->content))
{
$this->content = '';
$this->content .=
'"' . str_replace('"', '""', JText::_('COM_BANNERS_HEADING_NAME')) . '","' .
str_replace('"', '""', JText::_('COM_BANNERS_HEADING_CLIENT')) . '","' .
str_replace('"', '""', JText::_('JCATEGORY')) . '","' .
str_replace('"', '""', JText::_('COM_BANNERS_HEADING_TYPE')) . '","' .
str_replace('"', '""', JText::_('COM_BANNERS_HEADING_COUNT')) . '","' .
str_replace('"', '""', JText::_('JDATE')) . '"' . "\n";
foreach ($this->getItems() as $item)
{
$this->content .=
'"' . str_replace('"', '""', $item->name) . '","' .
str_replace('"', '""', $item->client_name) . '","' .
str_replace('"', '""', $item->category_title) . '","' .
str_replace('"', '""', ($item->track_type == 1 ? JText::_('COM_BANNERS_IMPRESSION') : JText::_('COM_BANNERS_CLICK'))) . '","' .
str_replace('"', '""', $item->count) . '","' .
str_replace('"', '""', $item->track_date) . '"' . "\n";
}
if ($this->getState('compressed'))
{
$app = JFactory::getApplication('administrator');
$files = array();
$files['track'] = array();
$files['track']['name'] = $this->getBasename() . '.csv';
$files['track']['data'] = $this->content;
$files['track']['time'] = time();
$ziproot = $app->getCfg('tmp_path') . '/' . uniqid('banners_tracks_') . '.zip';
// run the packager
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
$delete = JFolder::files($app->getCfg('tmp_path') . '/', uniqid('banners_tracks_'), false, true);
if (!empty($delete))
{
if (!JFile::delete($delete))
{
// JFile::delete throws an error
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_DELETE_FAILURE'));
return false;
}
}
if (!$packager = JArchive::getAdapter('zip'))
{
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_ADAPTER_FAILURE'));
return false;
}
elseif (!$packager->create($ziproot, $files))
{
$this->setError(JText::_('COM_BANNERS_ERR_ZIP_CREATE_FAILURE'));
return false;
}
$this->content = file_get_contents($ziproot);
}
}
return $this->content;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,69 @@
CREATE TABLE `#__banners` (
`id` INTEGER NOT NULL auto_increment,
`cid` INTEGER NOT NULL DEFAULT '0',
`type` INTEGER NOT NULL DEFAULT '0',
`name` VARCHAR(255) NOT NULL DEFAULT '',
`alias` VARCHAR(255) NOT NULL DEFAULT '',
`imptotal` INTEGER NOT NULL DEFAULT '0',
`impmade` INTEGER NOT NULL DEFAULT '0',
`clicks` INTEGER NOT NULL DEFAULT '0',
`clickurl` VARCHAR(200) NOT NULL DEFAULT '',
`state` TINYINT(3) NOT NULL DEFAULT '0',
`catid` INTEGER UNSIGNED NOT NULL DEFAULT 0,
`description` TEXT NOT NULL,
`custombannercode` VARCHAR(2048) NOT NULL,
`sticky` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0,
`ordering` INTEGER NOT NULL DEFAULT 0,
`metakey` TEXT NOT NULL,
`params` TEXT NOT NULL,
`own_prefix` TINYINT(1) NOT NULL DEFAULT '0',
`metakey_prefix` VARCHAR(255) NOT NULL DEFAULT '',
`purchase_type` TINYINT NOT NULL DEFAULT '-1',
`track_clicks` TINYINT NOT NULL DEFAULT '-1',
`track_impressions` TINYINT NOT NULL DEFAULT '-1',
`checked_out` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`checked_out_time` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_up` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`publish_down` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`reset` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`created` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00',
`language` char(7) NOT NULL DEFAULT '',
PRIMARY KEY (`id`),
INDEX `idx_state` (`state`),
INDEX `idx_own_prefix` (`own_prefix`),
INDEX `idx_metakey_prefix` (`metakey_prefix`),
INDEX `idx_banner_catid`(`catid`),
INDEX `idx_language` (`language`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `#__banner_clients` (
`id` INTEGER NOT NULL auto_increment,
`name` VARCHAR(255) NOT NULL DEFAULT '',
`contact` VARCHAR(255) NOT NULL DEFAULT '',
`email` VARCHAR(255) NOT NULL DEFAULT '',
`extrainfo` TEXT NOT NULL,
`state` TINYINT(3) NOT NULL DEFAULT '0',
`checked_out` INTEGER UNSIGNED NOT NULL DEFAULT '0',
`checked_out_time` DATETIME NOT NULL default '0000-00-00 00:00:00',
`metakey` TEXT NOT NULL,
`own_prefix` TINYINT NOT NULL DEFAULT '0',
`metakey_prefix` VARCHAR(255) NOT NULL default '',
`purchase_type` TINYINT NOT NULL DEFAULT '-1',
`track_clicks` TINYINT NOT NULL DEFAULT '-1',
`track_impressions` TINYINT NOT NULL DEFAULT '-1',
PRIMARY KEY (`id`),
INDEX `idx_own_prefix` (`own_prefix`),
INDEX `idx_metakey_prefix` (`metakey_prefix`)
) DEFAULT CHARSET=utf8;
CREATE TABLE `#__banner_tracks` (
`track_date` DATETIME NOT NULL,
`track_type` INTEGER UNSIGNED NOT NULL,
`banner_id` INTEGER UNSIGNED NOT NULL,
`count` INTEGER UNSIGNED NOT NULL DEFAULT '0',
PRIMARY KEY (`track_date`, `track_type`, `banner_id`),
INDEX `idx_track_date` (`track_date`),
INDEX `idx_track_type` (`track_type`),
INDEX `idx_banner_id` (`banner_id`)
) DEFAULT CHARSET=utf8;

View File

@ -0,0 +1,6 @@
DROP TABLE IF EXISTS `#__banners`;
DROP TABLE IF EXISTS `#__banner_clients`;
DROP TABLE IF EXISTS `#__banner_tracks`;

View File

@ -0,0 +1,338 @@
<?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;
/**
* Banner table
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.5
*/
class BannersTableBanner extends JTable
{
/**
* Constructor
*
* @since 1.5
*/
public function __construct(&$_db)
{
parent::__construct('#__banners', 'id', $_db);
$date = JFactory::getDate();
$this->created = $date->toSql();
}
public function clicks()
{
$query = 'UPDATE #__banners'
. ' SET clicks = (clicks + 1)'
. ' WHERE id = ' . (int) $this->id;
$this->_db->setQuery($query);
$this->_db->execute();
}
/**
* Overloaded check function
*
* @return boolean
* @see JTable::check
* @since 1.5
*/
public function check()
{
// Set name
$this->name = htmlspecialchars_decode($this->name, ENT_QUOTES);
// Set alias
$this->alias = JApplication::stringURLSafe($this->alias);
if (empty($this->alias))
{
$this->alias = JApplication::stringURLSafe($this->name);
}
// Check the publish down date is not earlier than publish up.
if ($this->publish_down > $this->_db->getNullDate() && $this->publish_down < $this->publish_up)
{
$this->setError(JText::_('JGLOBAL_START_PUBLISH_AFTER_FINISH'));
return false;
}
// Set ordering
if ($this->state < 0)
{
// Set ordering to 0 if state is archived or trashed
$this->ordering = 0;
} elseif (empty($this->ordering))
{
// Set ordering to last if ordering was 0
$this->ordering = self::getNextOrder($this->_db->quoteName('catid').'=' . $this->_db->quote($this->catid).' AND state>=0');
}
return true;
}
/**
* Overloaded bind function
*
* @param array $hash named array
* @return null|string null is operation was satisfactory, otherwise returns an error
* @see JTable:bind
* @since 1.5
*/
public function bind($array, $ignore = array())
{
if (isset($array['params']) && is_array($array['params']))
{
$registry = new JRegistry;
$registry->loadArray($array['params']);
if ((int) $registry->get('width', 0) < 0){
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED', JText::_('COM_BANNERS_FIELD_WIDTH_LABEL')));
return false;
}
if ((int) $registry->get('height', 0) < 0){
$this->setError(JText::sprintf('JLIB_DATABASE_ERROR_NEGATIVE_NOT_PERMITTED', JText::_('COM_BANNERS_FIELD_HEIGHT_LABEL')));
return false;
}
// Converts the width and height to an absolute numeric value:
$width = abs((int) $registry->get('width', 0));
$height = abs((int) $registry->get('height', 0));
// Sets the width and height to an empty string if = 0
$registry->set('width', ($width ? $width : ''));
$registry->set('height', ($height ? $height : ''));
$array['params'] = (string) $registry;
}
if (isset($array['imptotal']))
{
$array['imptotal'] = abs((int) $array['imptotal']);
}
return parent::bind($array, $ignore);
}
/**
* Method to store a row
*
* @param boolean $updateNulls True to update fields even if they are null.
*/
public function store($updateNulls = false)
{
if (empty($this->id))
{
$purchase_type = $this->purchase_type;
if ($purchase_type < 0 && $this->cid)
{
$client = JTable::getInstance('Client', 'BannersTable');
$client->load($this->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:
$this->reset = $this->_db->getNullDate();
break;
case 2:
$date = JFactory::getDate('+1 year '.date('Y-m-d', strtotime('now')));
$this->reset = $this->_db->quote($date->toSql());
break;
case 3:
$date = JFactory::getDate('+1 month '.date('Y-m-d', strtotime('now')));
$this->reset = $this->_db->quote($date->toSql());
break;
case 4:
$date = JFactory::getDate('+7 day '.date('Y-m-d', strtotime('now')));
$this->reset = $this->_db->quote($date->toSql());
break;
case 5:
$date = JFactory::getDate('+1 day '.date('Y-m-d', strtotime('now')));
$this->reset = $this->_db->quote($date->toSql());
break;
}
// Store the row
parent::store($updateNulls);
}
else
{
// Get the old row
$oldrow = JTable::getInstance('Banner', 'BannersTable');
if (!$oldrow->load($this->id) && $oldrow->getError())
{
$this->setError($oldrow->getError());
}
// Verify that the alias is unique
$table = JTable::getInstance('Banner', 'BannersTable');
if ($table->load(array('alias' => $this->alias, 'catid' => $this->catid)) && ($table->id != $this->id || $this->id == 0))
{
$this->setError(JText::_('COM_BANNERS_ERROR_UNIQUE_ALIAS'));
return false;
}
// Store the new row
parent::store($updateNulls);
// Need to reorder ?
if ($oldrow->state >= 0 && ($this->state < 0 || $oldrow->catid != $this->catid))
{
// Reorder the oldrow
$this->reorder($this->_db->quoteName('catid').'=' . $this->_db->quote($oldrow->catid).' AND state>=0');
}
}
return count($this->getErrors()) == 0;
}
/**
* Method to set the publishing state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed An optional array of primary key values to update. If not
* set the instance property value is used.
* @param integer The publishing state. eg. [0 = unpublished, 1 = published, 2=archived, -2=trashed]
* @param integer The user id of the user performing the operation.
* @return boolean True on success.
* @since 1.6
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else {
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Get an instance of the table
$table = JTable::getInstance('Banner', 'BannersTable');
// For all keys
foreach ($pks as $pk)
{
// Load the banner
if (!$table->load($pk))
{
$this->setError($table->getError());
}
// Verify checkout
if ($table->checked_out == 0 || $table->checked_out == $userId)
{
// Change the state
$table->state = $state;
$table->checked_out = 0;
$table->checked_out_time = $this->_db->getNullDate();
// Check the row
$table->check();
// Store the row
if (!$table->store())
{
$this->setError($table->getError());
}
}
}
return count($this->getErrors()) == 0;
}
/**
* Method to set the sticky state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed An optional array of primary key values to update. If not
* set the instance property value is used.
* @param integer The sticky state. eg. [0 = unsticked, 1 = sticked]
* @param integer The user id of the user performing the operation.
* @return boolean True on success.
* @since 1.6
*/
public function stick($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else {
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Get an instance of the table
$table = JTable::getInstance('Banner', 'BannersTable');
// For all keys
foreach ($pks as $pk)
{
// Load the banner
if (!$table->load($pk))
{
$this->setError($table->getError());
}
// Verify checkout
if ($table->checked_out == 0 || $table->checked_out == $userId)
{
// Change the state
$table->sticky = $state;
$table->checked_out = 0;
$table->checked_out_time = $this->_db->getNullDate();
// Check the row
$table->check();
// Store the row
if (!$table->store())
{
$this->setError($table->getError());
}
}
}
return count($this->getErrors()) == 0;
}
}

View File

@ -0,0 +1,112 @@
<?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;
/**
* Client table
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersTableClient extends JTable
{
public function __construct(&$_db)
{
$this->checked_out_time = $_db->getNullDate();
parent::__construct('#__banner_clients', 'id', $_db);
}
/**
* Method to set the publishing state for a row or list of rows in the database
* table. The method respects checked out rows by other users and will attempt
* to checkin rows that it can after adjustments are made.
*
* @param mixed An optional array of primary key values to update. If not
* set the instance property value is used.
* @param integer The publishing state. eg. [0 = unpublished, 1 = published]
* @param integer The user id of the user performing the operation.
* @return boolean True on success.
* @since 1.0.4
*/
public function publish($pks = null, $state = 1, $userId = 0)
{
$k = $this->_tbl_key;
// Sanitize input.
JArrayHelper::toInteger($pks);
$userId = (int) $userId;
$state = (int) $state;
// If there are no primary keys set check to see if the instance key is set.
if (empty($pks))
{
if ($this->$k)
{
$pks = array($this->$k);
}
// Nothing to set publishing state on, return false.
else {
$this->setError(JText::_('JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
return false;
}
}
// Build the WHERE clause for the primary keys.
$where = $k.'='.implode(' OR '.$k.'=', $pks);
// Determine if there is checkin support for the table.
if (!property_exists($this, 'checked_out') || !property_exists($this, 'checked_out_time'))
{
$checkin = '';
}
else
{
$checkin = ' AND (checked_out = 0 OR checked_out = '.(int) $userId.')';
}
// Update the publishing state for rows with the given primary keys.
$this->_db->setQuery(
'UPDATE '.$this->_db->quoteName($this->_tbl).
' SET '.$this->_db->quoteName('state').' = '.(int) $state .
' WHERE ('.$where.')' .
$checkin
);
try
{
$this->_db->execute();
}
catch (RuntimeException $e)
{
$this->setError($e->getMessage());
return false;
}
// If checkin is supported and all rows were adjusted, check them in.
if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
{
// Checkin the rows.
foreach ($pks as $pk)
{
$this->checkin($pk);
}
}
// If the JTable instance value is in the list of primary keys that were set, set the instance.
if (in_array($this->$k, $pks))
{
$this->state = $state;
}
$this->setError('');
return true;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,220 @@
<?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;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'banner.cancel' || document.formvalidator.isValid(document.id('banner-form')))
{
Joomla.submitform(task, document.getElementById('banner-form'));
}
}
window.addEvent('domready', function()
{
document.id('jform_type0').addEvent('click', function(e){
document.id('image').setStyle('display', 'block');
document.id('url').setStyle('display', 'block');
document.id('custom').setStyle('display', 'none');
});
document.id('jform_type1').addEvent('click', function(e){
document.id('image').setStyle('display', 'none');
document.id('url').setStyle('display', 'block');
document.id('custom').setStyle('display', 'block');
});
if (document.id('jform_type0').checked==true)
{
document.id('jform_type0').fireEvent('click');
}
else
{
document.id('jform_type1').fireEvent('click');
}
});
</script>
<form action="<?php echo JRoute::_('index.php?option=com_banners&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="banner-form" class="form-validate form-horizontal">
<?php echo JLayoutHelper::render('joomla.edit.item_title', $this); ?>
<!-- Begin Banner -->
<div class="span10 form-horizontal">
<fieldset>
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'details')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'details', JText::_('COM_BANNERS_BANNER_DETAILS', true)); ?>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('name'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('name'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('alias'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('alias'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('catid'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('catid'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('type'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('type'); ?>
</div>
</div>
<div id="image">
<?php foreach ($this->form->getFieldset('image') as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
</div>
<div class="control-group" id="custom">
<div class="control-label">
<?php echo $this->form->getLabel('custombannercode'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('custombannercode'); ?>
</div>
</div>
<div class="control-group" id="url">
<div class="control-label">
<?php echo $this->form->getLabel('clickurl'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('clickurl'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('description'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('description'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('id'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('id'); ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'publishing', JText::_('COM_BANNERS_GROUP_LABEL_PUBLISHING_DETAILS', true)); ?>
<?php foreach ($this->form->getFieldset('publish') as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'otherparams', JText::_('COM_BANNERS_GROUP_LABEL_BANNER_DETAILS', true)); ?>
<?php foreach ($this->form->getFieldset('otherparams') as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'metadata', JText::_('JGLOBAL_FIELDSET_METADATA_OPTIONS', true)); ?>
<?php foreach ($this->form->getFieldset('metadata') as $field) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $field->label; ?>
</div>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
</fieldset>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</div>
<!-- End Newsfeed -->
<!-- Begin Sidebar -->
<div class="span2">
<h4><?php echo JText::_('JDETAILS');?></h4>
<hr />
<fieldset class="form-vertical">
<div class="control-group">
<div class="controls">
<?php echo $this->form->getValue('name'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('state'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('state'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('sticky'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('sticky'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('language'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('language'); ?>
</div>
</div>
</fieldset>
</div>
<!-- End Sidebar -->
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,98 @@
<?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;
JLoader::register('BannersHelper', JPATH_COMPONENT.'/helpers/banners.php');
/**
* View to edit a banner.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.5
*/
class BannersViewBanner extends JViewLegacy
{
protected $form;
protected $item;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
// Initialiase variables.
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$userId = $user->get('id');
$isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $userId);
// Since we don't track these assets at the item level, use the category id.
$canDo = BannersHelper::getActions($this->item->catid, 0);
JToolbarHelper::title($isNew ? JText::_('COM_BANNERS_MANAGER_BANNER_NEW') : JText::_('COM_BANNERS_MANAGER_BANNER_EDIT'), 'banners.png');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit') || count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0))
{
JToolbarHelper::apply('banner.apply');
JToolbarHelper::save('banner.save');
if ($canDo->get('core.create'))
{
JToolbarHelper::save2new('banner.save2new');
}
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
JToolbarHelper::save2copy('banner.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('banner.cancel');
}
else
{
JToolbarHelper::cancel('banner.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_BANNERS_EDIT');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,255 @@
<?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;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$canOrder = $user->authorise('core.edit.state', 'com_banners.category');
$archived = $this->state->get('filter.published') == 2 ? true : false;
$trashed = $this->state->get('filter.published') == -2 ? true : false;
$params = (isset($this->state->params)) ? $this->state->params : new JObject;
$saveOrder = $listOrder == 'ordering';
if ($saveOrder)
{
$saveOrderingUrl = 'index.php?option=com_banners&task=banners.saveOrderAjax&tmpl=component';
JHtml::_('sortablelist.sortable', 'articleList', 'adminForm', strtolower($listDirn), $saveOrderingUrl);
}
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_banners&view=banners'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo JText::_('COM_BANNERS_SEARCH_IN_TITLE');?></label>
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_BANNERS_SEARCH_IN_TITLE'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC');?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING');?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING');?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY');?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder);?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped" id="articleList">
<thead>
<tr>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'ordering', $listDirn, $listOrder, null, 'asc', 'JGRID_HEADING_ORDERING'); ?>
</th>
<th width="1%" class="hidden-phone">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="1%" class="nowrap center">
<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo JHtml::_('grid.sort', 'COM_BANNERS_HEADING_NAME', 'a.name', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'COM_BANNERS_HEADING_STICKY', 'a.sticky', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'COM_BANNERS_HEADING_CLIENT', 'client_name', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'COM_BANNERS_HEADING_IMPRESSIONS', 'impmade', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'COM_BANNERS_HEADING_CLICKS', 'clicks', $listDirn, $listOrder); ?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_LANGUAGE', 'a.language', $listDirn, $listOrder); ?>
</th>
<th width="1%" class="nowrap center hidden-phone">
<?php echo JHtml::_('grid.sort', 'JGRID_HEADING_ID', 'a.id', $listDirn, $listOrder); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="13">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$ordering = ($listOrder == 'ordering');
$item->cat_link = JRoute::_('index.php?option=com_categories&extension=com_banners&task=edit&type=other&cid[]='. $item->catid);
$canCreate = $user->authorise('core.create', 'com_banners.category.' . $item->catid);
$canEdit = $user->authorise('core.edit', 'com_banners.category.' . $item->catid);
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $userId || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_banners.category.' . $item->catid) && $canCheckin;
?>
<tr class="row<?php echo $i % 2; ?>" sortable-group-id="<?php echo $item->catid?>">
<td class="order nowrap center hidden-phone">
<?php
$iconClass = '';
if (!$canChange)
{
$iconClass = ' inactive';
}
elseif (!$saveOrder)
{
$iconClass = ' inactive tip-top hasTooltip" title="' . JHtml::tooltipText('JORDERINGDISABLED');
}
?>
<span class="sortable-handler <?php echo $iconClass ?>">
<i class="icon-menu"></i>
</span>
<?php if ($canChange && $saveOrder) : ?>
<input type="text" style="display:none" name="order[]" size="5"
value="<?php echo $item->ordering; ?>" class="width-20 text-area-order " />
<?php endif; ?>
</td>
<td class="center hidden-phone">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td class="center">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'banners.', $canChange, 'cb', $item->publish_up, $item->publish_down); ?>
</td>
<td class="nowrap has-context">
<div class="pull-left">
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'banners.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_banners&task=banner.edit&id='.(int) $item->id); ?>">
<?php echo $this->escape($item->name); ?></a>
<?php else : ?>
<?php echo $this->escape($item->name); ?>
<?php endif; ?>
<div class="small">
<?php echo $this->escape($item->category_title); ?>
</div>
</div>
<div class="pull-left">
<?php
// Create dropdown items
JHtml::_('dropdown.edit', $item->id, 'banner.');
JHtml::_('dropdown.divider');
if ($item->state) :
JHtml::_('dropdown.unpublish', 'cb' . $i, 'banners.');
else :
JHtml::_('dropdown.publish', 'cb' . $i, 'banners.');
endif;
JHtml::_('dropdown.divider');
if ($archived) :
JHtml::_('dropdown.unarchive', 'cb' . $i, 'banners.');
else :
JHtml::_('dropdown.archive', 'cb' . $i, 'banners.');
endif;
if ($item->checked_out) :
JHtml::_('dropdown.checkin', 'cb' . $i, 'banners.');
endif;
if ($trashed) :
JHtml::_('dropdown.untrash', 'cb' . $i, 'banners.');
else :
JHtml::_('dropdown.trash', 'cb' . $i, 'banners.');
endif;
// render dropdown list
echo JHtml::_('dropdown.render');
?>
</div>
</td>
<td class="center hidden-phone">
<?php echo JHtml::_('banner.pinned', $item->sticky, $i, $canChange); ?>
</td>
<td class="small hidden-phone">
<?php echo $item->client_name;?>
</td>
<td class="small hidden-phone">
<?php echo JText::sprintf('COM_BANNERS_IMPRESSIONS', $item->impmade, $item->imptotal ? $item->imptotal : JText::_('COM_BANNERS_UNLIMITED'));?>
</td>
<td class="center small hidden-phone">
<?php echo $item->clicks;?> -
<?php echo sprintf('%.2f%%', $item->impmade ? 100 * $item->clicks / $item->impmade : 0);?>
</td>
<td class="small nowrap hidden-phone">
<?php if ($item->language == '*'):?>
<?php echo JText::alt('JALL', 'language'); ?>
<?php else:?>
<?php echo $item->language_title ? $this->escape($item->language_title) : JText::_('JUNDEFINED'); ?>
<?php endif;?>
</td>
<td class="center hidden-phone">
<?php echo $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php //Load the batch processing form. ?>
<?php echo $this->loadTemplate('batch'); ?>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1,47 @@
<?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;
$published = $this->state->get('filter.published');
?>
<div class="modal hide fade" id="collapseModal">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
<h3><?php echo JText::_('COM_BANNERS_BATCH_OPTIONS');?></h3>
</div>
<div class="modal-body">
<p><?php echo JText::_('COM_BANNERS_BATCH_TIP'); ?></p>
<div class="control-group">
<div class="controls">
<?php echo JHtml::_('banner.clients');?>
</div>
</div>
<div class="control-group">
<div class="controls">
<?php echo JHtml::_('batch.language'); ?>
</div>
</div>
<?php if ($published >= 0) : ?>
<div class="control-group">
<div class="controls">
<?php echo JHtml::_('batch.item', 'com_banners');?>
</div>
</div>
<?php endif; ?>
</div>
<div class="modal-footer">
<button class="btn" type="button" onclick="document.id('batch-category-id').value='';document.id('batch-client-id').value='';document.id('batch-language-id').value=''" data-dismiss="modal">
<?php echo JText::_('JCANCEL'); ?>
</button>
<button class="btn btn-primary" type="submit" onclick="Joomla.submitbutton('banner.batch');">
<?php echo JText::_('JGLOBAL_BATCH_PROCESS'); ?>
</button>
</div>
</div>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,193 @@
<?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;
/**
* View class for a list of banners.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersViewBanners extends JViewLegacy
{
protected $categories;
protected $items;
protected $pagination;
protected $state;
/**
* Method to display the view.
*
* @param string $tpl A template file to load. [optional]
*
* @return mixed A string if successful, otherwise a JError object.
*
* @since 1.6
*/
public function display($tpl = null)
{
$this->categories = $this->get('CategoryOrders');
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
BannersHelper::addSubmenu('banners');
$this->addToolbar();
require_once JPATH_COMPONENT . '/models/fields/bannerclient.php';
// Include the component HTML helpers.
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @return void
*
* @since 1.6
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT . '/helpers/banners.php';
$canDo = BannersHelper::getActions($this->state->get('filter.category_id'));
$user = JFactory::getUser();
// Get the toolbar object instance
$bar = JToolBar::getInstance('toolbar');
JToolbarHelper::title(JText::_('COM_BANNERS_MANAGER_BANNERS'), 'banners.png');
if (count($user->getAuthorisedCategories('com_banners', 'core.create')) > 0)
{
JToolbarHelper::addNew('banner.add');
}
if (($canDo->get('core.edit')))
{
JToolbarHelper::editList('banner.edit');
}
if ($canDo->get('core.edit.state'))
{
if ($this->state->get('filter.state') != 2)
{
JToolbarHelper::publish('banners.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('banners.unpublish', 'JTOOLBAR_UNPUBLISH', true);
}
if ($this->state->get('filter.state') != -1)
{
if ($this->state->get('filter.state') != 2)
{
JToolbarHelper::archiveList('banners.archive');
}
elseif ($this->state->get('filter.state') == 2)
{
JToolbarHelper::unarchiveList('banners.publish');
}
}
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::checkin('banners.checkin');
}
if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('', 'banners.delete', 'JTOOLBAR_EMPTY_TRASH');
}
elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('banners.trash');
}
// Add a batch button
if ($user->authorise('core.create', 'com_banners') && $user->authorise('core.edit', 'com_banners') && $user->authorise('core.edit.state', 'com_banners'))
{
JHtml::_('bootstrap.modal', 'collapseModal');
$title = JText::_('JTOOLBAR_BATCH');
// Instantiate a new JLayoutFile instance and render the batch button
$layout = new JLayoutFile('joomla.toolbar.batch');
$dhtml = $layout->render(array('title' => $title));
$bar->appendButton('Custom', $dhtml, 'batch');
}
if ($canDo->get('core.admin'))
{
JToolbarHelper::preferences('com_banners');
}
JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_BANNERS');
JHtmlSidebar::setAction('index.php?option=com_banners&view=banners');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_state',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true)
);
JHtmlSidebar::addFilter(
JText::_('COM_BANNERS_SELECT_CLIENT'),
'filter_client_id',
JHtml::_('select.options', BannersHelper::getClientOptions(), 'value', 'text', $this->state->get('filter.client_id'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_banners'), 'value', 'text', $this->state->get('filter.category_id'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_LANGUAGE'),
'filter_language',
JHtml::_('select.options', JHtml::_('contentlanguage.existing', true, true), 'value', 'text', $this->state->get('filter.language'))
);
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'ordering' => JText::_('JGRID_HEADING_ORDERING'),
'a.state' => JText::_('JSTATUS'),
'a.name' => JText::_('COM_BANNERS_HEADING_NAME'),
'a.sticky' => JText::_('COM_BANNERS_HEADING_STICKY'),
'client_name' => JText::_('COM_BANNERS_HEADING_CLIENT'),
'impmade' => JText::_('COM_BANNERS_HEADING_IMPRESSIONS'),
'clicks' => JText::_('COM_BANNERS_HEADING_CLICKS'),
'a.language' => JText::_('JGRID_HEADING_LANGUAGE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,139 @@
<?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;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('behavior.formvalidation');
JHtml::_('formbehavior.chosen', 'select');
$canDo = BannersHelper::getActions();
?>
<script type="text/javascript">
Joomla.submitbutton = function(task)
{
if (task == 'client.cancel' || document.formvalidator.isValid(document.id('client-form')))
{
Joomla.submitform(task, document.getElementById('client-form'));
}
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_banners&layout=edit&id='.(int) $this->item->id); ?>" method="post" name="adminForm" id="client-form" class="form-validate form-horizontal">
<?php echo JLayoutHelper::render('joomla.edit.item_title', $this); ?>
<?php echo JHtml::_('bootstrap.startTabSet', 'myTab', array('active' => 'general')); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'general', empty($this->item->id) ? JText::_('COM_BANNERS_NEW_CLIENT', true) : JText::sprintf('COM_BANNERS_EDIT_CLIENT', $this->item->id, true)); ?>
<div class="row-fluid">
<div class="span6">
<?php if ($canDo->get('core.edit.state')) : ?>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('state'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('state'); ?>
</div>
</div>
<?php endif; ?>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('name'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('name'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('contact'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('contact'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('email'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('email'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('purchase_type'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('purchase_type'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('track_impressions'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('track_impressions'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('track_clicks'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('track_clicks'); ?>
</div>
</div>
<div class="control-group">
<div class="control-label">
<?php echo $this->form->getLabel('id'); ?>
</div>
<div class="controls">
<?php echo $this->form->getInput('id'); ?>
</div>
</div>
</div>
<div class="span6">
<?php foreach ($this->form->getFieldset('extra') as $field) : ?>
<div class="control-group">
<?php if (!$field->hidden) : ?>
<div class="control-label">
<?php echo $field->label; ?>
</div>
<?php endif; ?>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
</div>
</div>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.addTab', 'myTab', 'metadata', JText::_('JGLOBAL_FIELDSET_METADATA_OPTIONS', true)); ?>
<?php foreach ($this->form->getFieldset('metadata') as $field) : ?>
<div class="control-group">
<?php if (!$field->hidden) : ?>
<div class="control-label">
<?php echo $field->label; ?>
</div>
<?php endif; ?>
<div class="controls">
<?php echo $field->input; ?>
</div>
</div>
<?php endforeach; ?>
<?php echo JHtml::_('bootstrap.endTab'); ?>
<?php echo JHtml::_('bootstrap.endTabSet'); ?>
<input type="hidden" name="task" value="" />
<?php echo JHtml::_('form.token'); ?>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,93 @@
<?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;
JLoader::register('BannersHelper', JPATH_COMPONENT.'/helpers/banners.php');
/**
* View to edit a client.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.5
*/
class BannersViewClient extends JViewLegacy
{
protected $form;
protected $item;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
$this->item = $this->get('Item');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$this->addToolbar();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
JFactory::getApplication()->input->set('hidemainmenu', true);
$user = JFactory::getUser();
$isNew = ($this->item->id == 0);
$checkedOut = !($this->item->checked_out == 0 || $this->item->checked_out == $user->get('id'));
$canDo = BannersHelper::getActions();
JToolbarHelper::title($isNew ? JText::_('COM_BANNERS_MANAGER_CLIENT_NEW') : JText::_('COM_BANNERS_MANAGER_CLIENT_EDIT'), 'banners-clients.png');
// If not checked out, can save the item.
if (!$checkedOut && ($canDo->get('core.edit')||$canDo->get('core.create')))
{
JToolbarHelper::apply('client.apply');
JToolbarHelper::save('client.save');
}
if (!$checkedOut && $canDo->get('core.create')) {
JToolbarHelper::save2new('client.save2new');
}
// If an existing item, can save to a copy.
if (!$isNew && $canDo->get('core.create'))
{
JToolbarHelper::save2copy('client.save2copy');
}
if (empty($this->item->id))
{
JToolbarHelper::cancel('client.cancel');
}
else
{
JToolbarHelper::cancel('client.cancel', 'JTOOLBAR_CLOSE');
}
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_CLIENTS_EDIT');
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,205 @@
<?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;
JHtml::addIncludePath(JPATH_COMPONENT.'/helpers/html');
JHtml::_('bootstrap.tooltip');
JHtml::_('behavior.multiselect');
JHtml::_('dropdown.init');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$params = (isset($this->state->params)) ? $this->state->params : new JObject;
$archived = $this->state->get('filter.published') == 2 ? true : false;
$trashed = $this->state->get('filter.published') == -2 ? true : false;
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_banners&view=clients'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label for="filter_search" class="element-invisible"><?php echo JText::_('COM_BANNERS_SEARCH_IN_TITLE');?></label>
<input type="text" name="filter_search" id="filter_search" placeholder="<?php echo JText::_('JSEARCH_FILTER'); ?>" value="<?php echo $this->escape($this->state->get('filter.search')); ?>" class="hasTooltip" title="<?php echo JHtml::tooltipText('COM_BANNERS_SEARCH_IN_TITLE'); ?>" />
</div>
<div class="btn-group pull-left">
<button type="submit" class="btn hasTooltip" title="<?php echo JHtml::tooltipText('JSEARCH_FILTER_SUBMIT'); ?>"><i class="icon-search"></i></button>
<button type="button" class="btn hasTooltip" title="<?php JHtml::tooltipText('JSEARCH_FILTER_CLEAR'); ?>" onclick="document.id('filter_search').value='';this.form.submit();"><i class="icon-remove"></i></button>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC');?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING');?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING');?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY');?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder);?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th width="1%" class="hidden-phone">
<?php echo JHtml::_('grid.checkall'); ?>
</th>
<th width="5%" class="center">
<?php echo JHtml::_('grid.sort', 'JSTATUS', 'a.published', $listDirn, $listOrder); ?>
</th>
<th>
<?php echo JText::_('COM_BANNERS_HEADING_CLIENT'); ?>
</th>
<th width="20%" class="hidden-phone">
<?php echo JText::_('COM_BANNERS_HEADING_CONTACT'); ?>
</th>
<th width="5%" class="hidden-phone">
<?php echo JText::_('COM_BANNERS_HEADING_ACTIVE'); ?>
</th>
<th width="10%" class="hidden-phone">
<?php echo JText::_('COM_BANNERS_HEADING_PURCHASETYPE'); ?>
</th>
<th width="1%" class="nowrap hidden-phone">
<?php echo JText::_('JGRID_HEADING_ID'); ?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="8">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :
$ordering = ($listOrder == 'ordering');
$canCreate = $user->authorise('core.create', 'com_banners');
$canEdit = $user->authorise('core.edit', 'com_banners');
$canCheckin = $user->authorise('core.manage', 'com_checkin') || $item->checked_out == $user->get('id') || $item->checked_out == 0;
$canChange = $user->authorise('core.edit.state', 'com_banners') && $canCheckin;
?>
<tr class="row<?php echo $i % 2; ?>">
<td class="center hidden-phone">
<?php echo JHtml::_('grid.id', $i, $item->id); ?>
</td>
<td class="center">
<?php echo JHtml::_('jgrid.published', $item->state, $i, 'clients.', $canChange);?>
</td>
<td class="nowrap has-context">
<div class="pull-left">
<?php if ($item->checked_out) : ?>
<?php echo JHtml::_('jgrid.checkedout', $i, $item->editor, $item->checked_out_time, 'clients.', $canCheckin); ?>
<?php endif; ?>
<?php if ($canEdit) : ?>
<a href="<?php echo JRoute::_('index.php?option=com_banners&task=client.edit&id='.(int) $item->id); ?>">
<?php echo $this->escape($item->name); ?></a>
<?php else : ?>
<?php echo $this->escape($item->name); ?>
<?php endif; ?>
</div>
<div class="pull-left">
<?php
// Create dropdown items
JHtml::_('dropdown.edit', $item->id, 'client.');
JHtml::_('dropdown.divider');
if ($item->state) :
JHtml::_('dropdown.unpublish', 'cb' . $i, 'clients.');
else :
JHtml::_('dropdown.publish', 'cb' . $i, 'clients.');
endif;
JHtml::_('dropdown.divider');
if ($archived) :
JHtml::_('dropdown.unarchive', 'cb' . $i, 'clients.');
else :
JHtml::_('dropdown.archive', 'cb' . $i, 'clients.');
endif;
if ($item->checked_out) :
JHtml::_('dropdown.checkin', 'cb' . $i, 'clients.');
endif;
if ($trashed) :
JHtml::_('dropdown.untrash', 'cb' . $i, 'clients.');
else :
JHtml::_('dropdown.trash', 'cb' . $i, 'clients.');
endif;
// render dropdown list
echo JHtml::_('dropdown.render');
?>
</div>
</td>
<td class="small hidden-phone">
<?php echo $item->contact;?>
</td>
<td class="center hidden-phone">
<?php echo $item->nbanners; ?>
</td>
<td class="small hidden-phone">
<?php if ($item->purchase_type < 0):?>
<?php echo JText::sprintf('COM_BANNERS_DEFAULT', JText::_('COM_BANNERS_FIELD_VALUE_'.$params->get('purchase_type')));?>
<?php else:?>
<?php echo JText::_('COM_BANNERS_FIELD_VALUE_'.$item->purchase_type);?>
<?php endif;?>
</td>
<td class="center hidden-phone">
<?php echo $item->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,118 @@
<?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;
/**
* View class for a list of clients.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersViewClients extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
BannersHelper::addSubmenu('clients');
$this->addToolbar();
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT.'/helpers/banners.php';
$canDo = BannersHelper::getActions();
JToolbarHelper::title(JText::_('COM_BANNERS_MANAGER_CLIENTS'), 'banners-clients.png');
if ($canDo->get('core.create'))
{
JToolbarHelper::addNew('client.add');
}
if ($canDo->get('core.edit'))
{
JToolbarHelper::editList('client.edit');
}
if ($canDo->get('core.edit.state'))
{
JToolbarHelper::publish('clients.publish', 'JTOOLBAR_PUBLISH', true);
JToolbarHelper::unpublish('clients.unpublish', 'JTOOLBAR_UNPUBLISH', true);
JToolbarHelper::archiveList('clients.archive');
JToolbarHelper::checkin('clients.checkin');
}
if ($this->state->get('filter.state') == -2 && $canDo->get('core.delete'))
{
JToolbarHelper::deleteList('', 'clients.delete', 'JTOOLBAR_EMPTY_TRASH');
} elseif ($canDo->get('core.edit.state'))
{
JToolbarHelper::trash('clients.trash');
}
if ($canDo->get('core.admin'))
{
JToolbarHelper::preferences('com_banners');
}
JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_CLIENTS');
JHtmlSidebar::setAction('index.php?option=com_banners&view=clients');
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_PUBLISHED'),
'filter_state',
JHtml::_('select.options', JHtml::_('jgrid.publishedOptions'), 'value', 'text', $this->state->get('filter.state'), true)
);
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'a.status' => JText::_('JSTATUS'),
'a.name' => JText::_('COM_BANNERS_HEADING_CLIENT'),
'contact' => JText::_('COM_BANNERS_HEADING_CONTACT'),
'client_name' => JText::_('COM_BANNERS_HEADING_CLIENT'),
'nbanners' => JText::_('COM_BANNERS_HEADING_ACTIVE'),
'a.id' => JText::_('JGRID_HEADING_ID')
);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,32 @@
<?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;
?>
<form
action="<?php echo JRoute::_('index.php?option=com_banners&task=tracks.display&format=raw');?>"
method="post"
name="adminForm"
id="download-form"
class="form-validate">
<fieldset class="adminform">
<legend><?php echo JText::_('COM_BANNERS_TRACKS_DOWNLOAD');?></legend>
<?php foreach ($this->form->getFieldset() as $field) : ?>
<?php if (!$field->hidden) : ?>
<?php echo $field->label; ?>
<?php endif; ?>
<?php echo $field->input; ?>
<?php endforeach; ?>
<div class="clr"></div>
<button type="button" onclick="this.form.submit();window.top.setTimeout('window.parent.SqueezeBox.close()', 700);"><?php echo JText::_('COM_BANNERS_TRACKS_EXPORT');?></button>
<button type="button" onclick="window.parent.SqueezeBox.close();"><?php echo JText::_('COM_BANNERS_CANCEL');?></button>
</fieldset>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,38 @@
<?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;
/**
* View class for download a list of tracks.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersViewDownload extends JViewLegacy
{
protected $form;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->form = $this->get('Form');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
parent::display($tpl);
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,138 @@
<?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;
JHtml::addIncludePath(JPATH_COMPONENT . '/helpers/html');
JHtml::_('behavior.multiselect');
JHtml::_('behavior.modal', 'a.modal');
JHtml::_('formbehavior.chosen', 'select');
$user = JFactory::getUser();
$userId = $user->get('id');
$listOrder = $this->escape($this->state->get('list.ordering'));
$listDirn = $this->escape($this->state->get('list.direction'));
$sortFields = $this->getSortFields();
?>
<script type="text/javascript">
Joomla.orderTable = function()
{
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != '<?php echo $listOrder; ?>')
{
dirn = 'asc';
}
else
{
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, '');
}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_banners&view=tracks'); ?>" method="post" name="adminForm" id="adminForm">
<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="span2">
<?php echo $this->sidebar; ?>
</div>
<div id="j-main-container" class="span10">
<?php else : ?>
<div id="j-main-container">
<?php endif;?>
<div id="filter-bar" class="btn-toolbar">
<div class="filter-search btn-group pull-left">
<label class="filter-hide-lbl" for="filter_begin"><?php echo JText::_('COM_BANNERS_BEGIN_LABEL'); ?></label>
<?php echo JHtml::_('calendar', $this->state->get('filter.begin'), 'filter_begin', 'filter_begin', '%Y-%m-%d', array('size' => 10, 'onchange' => "this.form.fireEvent('submit');this.form.submit()"));?>
</div>
<div class="filter-search btn-group pull-left">
<label class="filter-hide-lbl" for="filter_end"><?php echo JText::_('COM_BANNERS_END_LABEL'); ?></label>
<?php echo JHtml::_('calendar', $this->state->get('filter.end'), 'filter_end', 'filter_end', '%Y-%m-%d', array('size' => 10, 'onchange' => "this.form.fireEvent('submit');this.form.submit()"));?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="limit" class="element-invisible"><?php echo JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC');?></label>
<?php echo $this->pagination->getLimitBox(); ?>
</div>
<div class="btn-group pull-right hidden-phone">
<label for="directionTable" class="element-invisible"><?php echo JText::_('JFIELD_ORDERING_DESC');?></label>
<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JFIELD_ORDERING_DESC');?></option>
<option value="asc" <?php if ($listDirn == 'asc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_ASCENDING');?></option>
<option value="desc" <?php if ($listDirn == 'desc') echo 'selected="selected"'; ?>><?php echo JText::_('JGLOBAL_ORDER_DESCENDING');?></option>
</select>
</div>
<div class="btn-group pull-right">
<label for="sortTable" class="element-invisible"><?php echo JText::_('JGLOBAL_SORT_BY');?></label>
<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">
<option value=""><?php echo JText::_('JGLOBAL_SORT_BY');?></option>
<?php echo JHtml::_('select.options', $sortFields, 'value', 'text', $listOrder);?>
</select>
</div>
</div>
<div class="clearfix"> </div>
<table class="table table-striped">
<thead>
<tr>
<th class="title">
<?php echo JText::_('COM_BANNERS_HEADING_NAME');?>
</th>
<th width="20%" class="nowrap">
<?php echo JText::_('COM_BANNERS_HEADING_CLIENT');?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JText::_('COM_BANNERS_HEADING_TYPE');?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JText::_('COM_BANNERS_HEADING_COUNT');?>
</th>
<th width="10%" class="nowrap hidden-phone">
<?php echo JText::_('JDATE');?>
</th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="6">
<?php echo $this->pagination->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->items as $i => $item) :?>
<tr class="row<?php echo $i % 2; ?>">
<td>
<?php echo $item->name;?>
<div class="small">
<?php echo $item->category_title;?>
</div>
</td>
<td>
<?php echo $item->client_name;?>
</td>
<td class="small hidden-phone">
<?php echo $item->track_type == 1 ? JText::_('COM_BANNERS_IMPRESSION') : JText::_('COM_BANNERS_CLICK');?>
</td>
<td class="hidden-phone">
<?php echo $item->count;?>
</td>
<td class="hidden-phone">
<?php echo JHtml::_('date', $item->track_date, JText::_('DATE_FORMAT_LC4').' H:i');?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<input type="hidden" name="task" value="" />
<input type="hidden" name="boxchecked" value="0" />
<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
<?php echo JHtml::_('form.token'); ?>
</div>
</form>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View 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('_JEXEC') or die;
/**
* View class for a list of tracks.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersViewTracks extends JViewLegacy
{
protected $items;
protected $pagination;
protected $state;
/**
* Display the view
*/
public function display($tpl = null)
{
$this->items = $this->get('Items');
$this->pagination = $this->get('Pagination');
$this->state = $this->get('State');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
BannersHelper::addSubmenu('tracks');
$this->addToolbar();
require_once JPATH_COMPONENT .'/models/fields/bannerclient.php';
$this->sidebar = JHtmlSidebar::render();
parent::display($tpl);
}
/**
* Add the page title and toolbar.
*
* @since 1.6
*/
protected function addToolbar()
{
require_once JPATH_COMPONENT.'/helpers/banners.php';
$canDo = BannersHelper::getActions($this->state->get('filter.category_id'));
JToolbarHelper::title(JText::_('COM_BANNERS_MANAGER_TRACKS'), 'banners-tracks.png');
$bar = JToolBar::getInstance('toolbar');
$bar->appendButton('Slider', 'export', 'JTOOLBAR_EXPORT', 'index.php?option=com_banners&amp;view=download&amp;tmpl=component', 600, 300);
if ($canDo->get('core.delete'))
{
$bar->appendButton('Confirm', 'COM_BANNERS_DELETE_MSG', 'delete', 'COM_BANNERS_TRACKS_DELETE', 'tracks.delete', false);
JToolbarHelper::divider();
}
if ($canDo->get('core.admin'))
{
JToolbarHelper::preferences('com_banners');
JToolbarHelper::divider();
}
JToolbarHelper::help('JHELP_COMPONENTS_BANNERS_TRACKS');
JHtmlSidebar::setAction('index.php?option=com_banners&view=tracks');
JHtmlSidebar::addFilter(
JText::_('COM_BANNERS_SELECT_CLIENT'),
'filter_client_id',
JHtml::_('select.options', BannersHelper::getClientOptions(), 'value', 'text', $this->state->get('filter.client_id'))
);
JHtmlSidebar::addFilter(
JText::_('JOPTION_SELECT_CATEGORY'),
'filter_category_id',
JHtml::_('select.options', JHtml::_('category.options', 'com_banners'), 'value', 'text', $this->state->get('filter.category_id'))
);
JHtmlSidebar::addFilter(
JText::_('COM_BANNERS_SELECT_TYPE'),
'filter_type',
JHtml::_('select.options', array(JHtml::_('select.option', 1, JText::_('COM_BANNERS_IMPRESSION')), JHtml::_('select.option', 2, JText::_('COM_BANNERS_CLICK'))), 'value', 'text', $this->state->get('filter.type'))
);
}
/**
* Returns an array of fields the table can be sorted by
*
* @return array Array containing the field name to sort by as the key and display text as value
*
* @since 3.0
*/
protected function getSortFields()
{
return array(
'b.name' => JText::_('COM_BANNERS_HEADING_NAME'),
'cl.name' => JText::_('COM_BANNERS_HEADING_CLIENT'),
'track_type' => JText::_('COM_BANNERS_HEADING_TYPE'),
'count' => JText::_('COM_BANNERS_HEADING_COUNT'),
'track_date' => JText::_('JDATE')
);
}
}

View File

@ -0,0 +1,43 @@
<?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;
/**
* View class for a list of tracks.
*
* @package Joomla.Administrator
* @subpackage com_banners
* @since 1.6
*/
class BannersViewTracks extends JViewLegacy
{
/**
* Display the view
*/
public function display($tpl = null)
{
$basename = $this->get('BaseName');
$filetype = $this->get('FileType');
$mimetype = $this->get('MimeType');
$content = $this->get('Content');
// Check for errors.
if (count($errors = $this->get('Errors')))
{
JError::raiseError(500, implode("\n", $errors));
return false;
}
$document = JFactory::getDocument();
$document->setMimeEncoding($mimetype);
JResponse::setHeader('Content-disposition', 'attachment; filename="'.$basename.'.'.$filetype.'"; creation-date="'.JFactory::getDate()->toRFC822().'"', true);
echo $content;
}
}