| Current Path : /home/juvelize/www/administrator/components/com_elioallvideos2/helpers/ |
| Current File : /home/juvelize/www/administrator/components/com_elioallvideos2/helpers/helper.php |
<?php
/** ______________________________________________
* o O | |
* ((((( o < Generated with Cook Self Service V1.5.2 |
* ( o o ) |______________________________________________|
* --------oOOO-----(_)-----OOOo---------------------------------- www.j-cook.pro --- +
* @version 2.0
* @package ElioAllVideos 2
* @subpackage Viewlevels
* @copyright http://www.eliopro.fr 28.10.2012
* @author Félix Dr. Dimitric - http://www.eliopro.fr - felix@eliopro.fr
* @license GNU/GPL
*
* /!\ Joomla! is free software.
* This version may have been modified pursuant to the GNU General Public License,
* and as distributed it includes or is derivative of works licensed under the
* GNU General Public License or other free or open source software licenses.
*
* .oooO Oooo. See COPYRIGHT.php for copyright notices and details.
* ( ) ( )
* -------------\ (----) /----------------------------------------------------------- +
* \_) (_/
*/
// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );
if (!class_exists('JDom'))
require_once(JPATH_ADMIN_ELIOALLVIDEOS2 .DS.'dom'.DS.'dom.php');
class Elioallvideos2Helper
{
/*
* Recreate the URL with a redirect in order to :
* -> keep an good SEF
* -> always kill the post
* -> precisely control the request
*/
function urlRequest($vars = array())
{
$parts = array();
//Contains followers
$authorizedInUrl = array('option', 'view', 'layout', 'Itemid', 'tmpl', 'lang');
$request = JRequest::get();
foreach($request as $key => $value)
{
if (in_array($key, $authorizedInUrl))
$parts[] = $key . '=' . $value;
}
$cid = JRequest::getVar( 'cid', array(), 'post', 'array' );
if (empty($cid))
$cid = JRequest::getVar( 'cid', array(), 'get', 'array' );
if (!empty($cid))
{
$cidVals = implode(",", $cid);
if ($cidVals != '0')
$parts[] = 'cid[]=' . $cidVals;
}
if (count($vars))
foreach($vars as $key => $value)
$parts[] = $key . '=' . $value;
return JRoute::_("index.php?" . implode("&", $parts), false);
}
/*
* Redirect Back
* Can be called in View if controller redirection has already been done
* Can be raised when the user ask a page with a direct url
* Handle some security to avoid recursivity
* TODO : Customize your own rules here
*/
function redirectBack($notAllowed = true)
{
if ($notAllowed && JFactory::getUser()->id == 0)
{
JRequest::setVar('option','com_users');
JRequest::setVar('view','login');
JRequest::setVar('layout','');
$url = self::urlRequest(); //Login page
}
else
{
// TODO : Not finished : only redirect to Root
JFactory::getApplication()->redirect(JURI::base(true));
return;
$current = JURI::current();
//Get the previous page : TODO : finish this
$url = (isset($_SERVER['HTTP_REFERER'])?$_SERVER['HTTP_REFERER']:null);
if (!$url || ($url == $current))
{
JRequest::setVar('view','');
JRequest::setVar('layout','');
$url = self::urlRequest(); //Component Root
}
if ($url == $current)
{
$url = JURI::base(true); // Site Root
}
}
JFactory::getApplication()->redirect($url);
}
function headerDeclarations()
{
$app = JFactory::getApplication();
$doc = JFactory::getDocument();
$siteUrl = JURI::root(true);
$siteUrl = str_replace("\\", "/", $siteUrl); //Win servers
$componentUrl = $siteUrl . '/components/com_elioallvideos2';
$componentUrlAdmin = $siteUrl .'/administrator/components/com_elioallvideos2';
//Javascript
$doc->addScript($siteUrl . '/media/system/js/core.js');
// Mootools non conflict is handled here :
$doc->addScriptDeclaration("var Moo = document.id;");
//Load jQuery from the CDN
$doc->addScript('http://code.jquery.com/jquery.min.js');
$doc->addScript('http://code.jquery.com/ui/1.8.24/jquery-ui.min.js');
//Load the jQuery-Validation-Engine (MIT License, Copyright(c) 2011 Cedric Dugas http://www.position-absolute.com)
$doc->addScript($componentUrlAdmin . '/js/jquery.validationEngine.js');
$doc->addStyleSheet($componentUrlAdmin . '/css/validationEngine.jquery.css');
cimport('helpers.html.validator');
JHtmlValidator::loadLanguageScript();
//TODO : Define here the default framework to use with $
// Mootools is still used in Joomla native javascript functionalities
$doc->addScriptDeclaration("var $" . " = Moo;"); //Moo ; jQuery
/*
* How to write a plugins in non-conflict modes :
*
(function($){
// Write your code here, using $.
// The local var $ represents jQuery framework
})(jQuery);
// exactly the same, with for MooTools plugins
(function($){
...
})(Moo);
*/
//CSS
if ($app->isAdmin())
{
$doc->addStyleSheet($componentUrlAdmin . '/css/elioallvideos2.css');
$doc->addStyleSheet($componentUrlAdmin . '/css/toolbar.css');
// Blue stork override
$styles = "fieldset td.key label{display: block;}fieldset input, fieldset textarea, fieldset select, fieldset img, fieldset button{float: none;}fieldset label, fieldset span.faux-label{float: none;display: inline;min-width: inherit;}";
$doc->addStyleDeclaration($styles);
}
else if ($app->isSite())
{
$doc->addStyleSheet($componentUrl . '/css/elioallvideos2.css');
$doc->addStyleSheet($componentUrl . '/css/toolbar.css');
}
}
function getACL()
{
jimport('joomla.access.access');
$user = JFactory::getUser();
$result = new JObject;
$actions = JAccess::getActions('com_elioallvideos2', 'component');
foreach ($actions as $action) {
$result->set($action->name, $user->authorise($action->name, 'com_elioallvideos2'));
}
return $result;
}
}
class Elioallvideos2ThirdTable
{
var $tableName;
var $select;
var $join;
var $order;
var $extra;
function __construct($tableName)
{
$this->tableName = $tableName;
}
function setQuery($select = null, $join = null, $where = null, $order = null, $extra = null)
{
$this->select = $select;
$this->join = $join;
$this->where = $where;
$this->order = $order;
$this->extra = $extra;
}
function loadObjectList()
{
$db = JFactory::getDBO();
$query = 'SELECT *' . $this->select
. ' FROM #__' . $this->tableName;
if ($this->join)
$query .= ", " . $this->join;
if ($this->where)
$query .= ' WHERE ' . $this->where;
if ($this->order)
$query .= ' ORDER BY '. $this->order;
if ($this->extra)
$query .= " " . $this->extra;
$db->setQuery( $query );
return $db->loadObjectList();
}
}