Exemplo n.º 1
0
 /**
  * Echoes any HTML to show after the view template
  *
  * @param   string  $view   The current view
  * @param   string  $task   The current task
  * @param   array   $input  The input array (request parameters)
  */
 public function postRender($view, $task, $input, $config = array())
 {
     list($isCli, ) = FOFDispatcher::isCliAdmin();
     $format = $input->getCmd('format', 'html');
     if ($format != 'html' || $isCli) {
         return;
     }
     echo "</div>\n";
 }
Exemplo n.º 2
0
 /**
  * Displays the view
  *
  * @param   string  $tpl  The template to use
  *
  * @return  boolean|null False if we can't render anything
  */
 public function display($tpl = null)
 {
     $model = $this->getModel();
     // Get the form
     $this->form = $this->getModel()->getForm();
     $this->form->setModel($model);
     $this->form->setView($this);
     // Get some useful information
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     // Get the task set in the model
     $task = $model->getState('task', 'browse');
     // Call the relevant method
     $method_name = 'on' . ucfirst($task);
     if (method_exists($this, $method_name)) {
         $result = $this->{$method_name}($tpl);
     } else {
         $result = $this->onDisplay();
     }
     // Bail out if we're told not to render anything
     if ($result === false) {
         return;
     }
     // Render the toolbar
     $toolbar = FOFToolbar::getAnInstance($this->input->getCmd('option', 'com_foobar'), $this->config);
     $toolbar->perms = $this->perms;
     $toolbar->renderToolbar($this->input->getCmd('view', 'cpanel'), $task, $this->input);
     // Show the view
     // -- Output HTML before the view template
     $this->preRender();
     // -- Try to load a view template; if not exists render the form directly
     $basePath = $isAdmin ? 'admin:' : 'site:';
     $basePath .= $this->config['option'] . '/';
     $basePath .= $this->config['view'] . '/';
     $path = $basePath . $this->getLayout();
     if ($tpl) {
         $path .= '_' . $tpl;
     }
     $viewTemplate = $this->loadAnyTemplate($path);
     // If there was no template file found, display the form
     if ($viewTemplate instanceof Exception) {
         $viewTemplate = $this->getRenderedForm();
     }
     // -- Output the view template
     echo $viewTemplate;
     // -- Output HTML after the view template
     $this->postRender();
 }
Exemplo n.º 3
0
 /**
  * Parses the configuration of the specified component
  *
  * @param   string   $component  The name of the component, e.g. com_foobar
  * @param   boolean  $force      Force reload even if it's already parsed?
  *
  * @return  void
  */
 public function parseComponent($component, $force = false)
 {
     if (!$force && isset(self::$configurations[$component])) {
         return;
     }
     static $isCli, $isAdmin;
     if (is_null($isCli)) {
         list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     }
     if ($isCli) {
         $order = array('cli', 'backend');
     } elseif ($isAdmin) {
         $order = array('backend');
     } else {
         $order = array('frontend');
     }
     $order = array_reverse($order);
     self::$configurations[$component] = array();
     foreach ($order as $area) {
         $config = $this->parseComponentArea($component, $area);
         self::$configurations[$component] = array_merge_recursive(self::$configurations[$component], $config);
     }
 }
Exemplo n.º 4
0
<?php

/**
 * @package     db8 locate
 * @author	Peter Martin
 * @copyright   Copyright (C) 2014 Peter Martin / db8.nl
 * @license     GNU General Public License version 2 or later
 */
defined('_JEXEC') or die;
// Load FOF
require_once JPATH_LIBRARIES . '/fof/include.php';
// Quit if FOF is not installed
if (!defined('FOF_INCLUDED')) {
    JError::raiseError('500', 'FOF is not installed!');
    return;
}
FOFDispatcher::getTmpInstance('com_db8locate')->dispatch();
Exemplo n.º 5
0
 /**
  * Sets an entire array of search paths for templates or resources.
  *
  * @param   string  $type  The type of path to set, typically 'template'.
  * @param   mixed   $path  The new search path, or an array of search paths.  If null or false, resets to the current directory only.
  *
  * @return  void
  *
  */
 protected function _setPath($type, $path)
 {
     list($isCli, ) = FOFDispatcher::isCliAdmin();
     // Clear out the prior search dirs
     $this->_path[$type] = array();
     // Actually add the user-specified directories
     $this->_addPath($type, $path);
     // Always add the fallback directories as last resort
     switch (strtolower($type)) {
         case 'template':
             // Set the alternative template search dir
             if (!$isCli) {
                 $app = JFactory::getApplication();
                 $component = preg_replace('/[^A-Z0-9_\\.-]/i', '', $this->input->getCmd('option'));
                 $fallback = JPATH_THEMES . '/' . $app->getTemplate() . '/html/' . $component . '/' . $this->getName();
                 $this->_addPath('template', $fallback);
             }
             break;
     }
 }
Exemplo n.º 6
0
 /**
  * Parse a fancy path definition into a path relative to the site's root.
  * It returns both the normal and alternative (template media override) path.
  * For example, media://com_foobar/css/test.css is parsed into
  * array(
  *   'normal' => 'media/com_foobar/css/test.css',
  *   'alternate' => 'templates/mytemplate/media/com_foobar/css//test.css'
  * );
  *
  * The valid protocols are:
  * media://		The media directory or a media override
  * admin://		Path relative to administrator directory (no alternate)
  * site://		Path relative to site's root (no alternate)
  *
  * @param   string  $path       Fancy path
  *
  * @return  array  Array of normal and alternate parsed path
  */
 public static function getAltPaths($path)
 {
     static $isCli = null;
     static $isAdmin = null;
     if (is_null($isCli) && is_null($isAdmin)) {
         list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     }
     $protoAndPath = explode('://', $path, 2);
     if (count($protoAndPath) < 2) {
         $protocol = 'media';
     } else {
         $protocol = $protoAndPath[0];
         $path = $protoAndPath[1];
     }
     $path = ltrim($path, '/' . DIRECTORY_SEPARATOR);
     switch ($protocol) {
         case 'media':
             // Do we have a media override in the template?
             $pathAndParams = explode('?', $path, 2);
             $altPath = 'templates/' . JFactory::getApplication()->getTemplate() . '/media/';
             $ret = array('normal' => 'media/' . $pathAndParams[0], 'alternate' => ($isAdmin ? 'administrator/' : '') . $altPath . $pathAndParams[0]);
             break;
         case 'admin':
             $ret = array('normal' => 'administrator/' . $path);
             break;
         default:
         case 'site':
             $ret = array('normal' => $path);
             break;
     }
     // For CSS and JS files, add a debug path if the supplied file is compressed
     JLoader::import('joomla.filesystem.file');
     $ext = JFile::getExt($ret['normal']);
     if (in_array($ext, array('css', 'js'))) {
         $file = basename(JFile::stripExt($ret['normal']));
         /*
          * Detect if we received a file in the format name.min.ext
          * If so, strip the .min part out, otherwise append -uncompressed
          */
         if (strlen($file) > 4 && strrpos($file, '.min', '-4')) {
             $position = strrpos($file, '.min', '-4');
             $filename = str_replace('.min', '.', $file, $position);
         } else {
             $filename = $file . '-uncompressed.' . $ext;
         }
         // Clone the $ret array so we can manipulate the 'normal' path a bit
         $temp = (array) clone (object) $ret;
         $normalPath = explode('/', $temp['normal']);
         array_pop($normalPath);
         $normalPath[] = $filename;
         $ret['debug'] = implode('/', $normalPath);
     }
     return $ret;
 }
Exemplo n.º 7
0
<?php

/*------------------------------------------------------------------------
# SP Polls - Ajax Poll Component by JoomShaper.com
# ------------------------------------------------------------------------
# author    JoomShaper http://www.joomshaper.com
# Copyright (C) 2010 - 2016 JoomShaper.com. All Rights Reserved.
# License - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
# Websites: http://www.joomshaper.com
-------------------------------------------------------------------------*/
defined('_JEXEC') or die('resticted aceess');
// Load FOF
include_once JPATH_LIBRARIES . '/fof/include.php';
if (!defined('FOF_INCLUDED')) {
    JFactory::getApplication()->enqueueMessage('FOF is not installed', '500');
}
FOFDispatcher::getTmpInstance('com_sppolls')->dispatch();
Exemplo n.º 8
0
/**
 * @package AkeebaBackup
 * @copyright Copyright (c)2009-2013 Nicholas K. Dionysopoulos
 * @license GNU General Public License version 3, or later
 *
 * @since 1.3
 */
// Protect from unauthorized access
defined('_JEXEC') or die;
JDEBUG ? define('AKEEBADEBUG', 1) : null;
// Check for PHP4
if (defined('PHP_VERSION')) {
    $version = PHP_VERSION;
} elseif (function_exists('phpversion')) {
    $version = phpversion();
} else {
    // No version info. I'll lie and hope for the best.
    $version = '5.0.0';
}
// Old PHP version detected. EJECT! EJECT! EJECT!
if (!version_compare($version, '5.3.0', '>=')) {
    return JError::raise(E_ERROR, 500, 'This version of PHP is not compatible with Akeeba Backup');
}
JLoader::import('joomla.application.component.model');
// Load FOF
include_once JPATH_SITE . '/libraries/fof/include.php';
if (!defined('FOF_INCLUDED') || !class_exists('FOFForm', true)) {
    JError::raiseError('500', 'Your Akeeba Backup installation is broken; please re-install. Alternatively, extract the installation archive and copy the fof directory inside your site\'s libraries directory.');
}
FOFDispatcher::getTmpInstance('com_akeeba')->dispatch();
Exemplo n.º 9
0
 public function dispatch()
 {
     if (!class_exists('AkeebaControllerDefault')) {
         require_once JPATH_ADMINISTRATOR . '/components/com_akeeba/controllers/default.php';
     }
     // Merge the language overrides
     $paths = array(JPATH_ROOT, JPATH_ADMINISTRATOR);
     $jlang = JFactory::getLanguage();
     $jlang->load($this->component, $paths[0], 'en-GB', true);
     $jlang->load($this->component, $paths[0], null, true);
     $jlang->load($this->component, $paths[1], 'en-GB', true);
     $jlang->load($this->component, $paths[1], null, true);
     $jlang->load($this->component . '.override', $paths[0], 'en-GB', true);
     $jlang->load($this->component . '.override', $paths[0], null, true);
     $jlang->load($this->component . '.override', $paths[1], 'en-GB', true);
     $jlang->load($this->component . '.override', $paths[1], null, true);
     FOFInflector::addWord('alice', 'alices');
     // Timezone fix; avoids errors printed out by PHP 5.3.3+ (thanks Yannick!)
     if (function_exists('date_default_timezone_get') && function_exists('date_default_timezone_set')) {
         if (function_exists('error_reporting')) {
             $oldLevel = error_reporting(0);
         }
         $serverTimezone = @date_default_timezone_get();
         if (empty($serverTimezone) || !is_string($serverTimezone)) {
             $serverTimezone = 'UTC';
         }
         if (function_exists('error_reporting')) {
             error_reporting($oldLevel);
         }
         @date_default_timezone_set($serverTimezone);
     }
     // Necessary defines for Akeeba Engine
     if (!defined('AKEEBAENGINE')) {
         define('AKEEBAENGINE', 1);
         // Required for accessing Akeeba Engine's factory class
         define('AKEEBAROOT', dirname(__FILE__) . '/akeeba');
         define('ALICEROOT', dirname(__FILE__) . '/alice');
     }
     // Setup Akeeba's ACLs, honoring laxed permissions in component's parameters, if set
     // Access check, Joomla! 1.6 style.
     $user = JFactory::getUser();
     if (!$user->authorise('core.manage', 'com_akeeba')) {
         return JError::raiseError(403, JText::_('JERROR_ALERTNOAUTHOR'));
     }
     // Make sure we have a profile set throughout the component's lifetime
     $session = JFactory::getSession();
     $profile_id = $session->get('profile', null, 'akeeba');
     if (is_null($profile_id)) {
         // No profile is set in the session; use default profile
         $session->set('profile', 1, 'akeeba');
     }
     // Load the factory
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/akeeba/factory.php';
     @(include_once JPATH_COMPONENT_ADMINISTRATOR . '/alice/factory.php');
     // Load the Akeeba Backup configuration and check user access permission
     $aeconfig = AEFactory::getConfiguration();
     AEPlatform::getInstance()->load_configuration();
     unset($aeconfig);
     // Preload helpers
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/includes.php';
     require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/escape.php';
     // Load the utils helper library
     AEPlatform::getInstance()->load_version_defines();
     // Create a versioning tag for our static files
     $staticFilesVersioningTag = md5(AKEEBA_VERSION . AKEEBA_DATE);
     define('AKEEBAMEDIATAG', $staticFilesVersioningTag);
     // If JSON functions don't exist, load our compatibility layer
     if (!function_exists('json_encode') || !function_exists('json_decode')) {
         require_once JPATH_COMPONENT_ADMINISTRATOR . '/helpers/jsonlib.php';
     }
     // Look for controllers in the plugins folder
     $option = $this->input->get('option', 'com_foobar', 'cmd');
     $view = $this->input->get('view', $this->defaultView, 'cmd');
     $c = FOFInflector::singularize($view);
     $alt_path = JPATH_ADMINISTRATOR . '/components/' . $option . '/plugins/controllers/' . $c . '.php';
     JLoader::import('joomla.filesystem.file');
     if (JFile::exists($alt_path)) {
         // The requested controller exists and there you load it...
         require_once $alt_path;
     }
     $this->input->set('view', $this->view);
     parent::dispatch();
 }
Exemplo n.º 10
0
<?php

/**
* @version     1.0
* @package     Joomla
* @subpackage  com_redslider
* @author      redWEB Aps <*****@*****.**>
* @copyright   com_redslider (C) 2008 - 2012 redCOMPONENT.com
* @license     GNU/GPL, see LICENSE.php
* com_redslider can be downloaded from www.redcomponent.com
* com_redslider is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License 2
* as published by the Free Software Foundation.
* com_redslider is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with com_redslider; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
// No direct access
defined('_JEXEC') or die;
// Load FOF
include_once JPATH_LIBRARIES . '/fof/include.php';
// Check if FOF library installed or not
if (!defined('FOF_INCLUDED')) {
    JError::raiseError('500', 'FOF is not installed');
}
FOFDispatcher::getTmpInstance('com_redslider')->dispatch();
Exemplo n.º 11
0
 /**
  * Returns a static object instance of a particular table type
  *
  * @param   string  $type    The table name
  * @param   string  $prefix  The prefix of the table class
  * @param   array   $config  Optional configuration variables
  *
  * @return FOFTable
  */
 public static function &getAnInstance($type = null, $prefix = 'JTable', $config = array())
 {
     static $instances = array();
     // Make sure $config is an array
     if (is_object($config)) {
         $config = (array) $config;
     } elseif (!is_array($config)) {
         $config = array();
     }
     // Guess the component name
     if (!array_key_exists('input', $config)) {
         $config['input'] = new FOFInput();
     }
     if ($config['input'] instanceof FOFInput) {
         $tmpInput = $config['input'];
     } else {
         $tmpInput = new FOFInput($config['input']);
     }
     $option = $tmpInput->getCmd('option', '');
     $tmpInput->set('option', $option);
     $config['input'] = $tmpInput;
     if (!in_array($prefix, array('Table', 'JTable'))) {
         preg_match('/(.*)Table$/', $prefix, $m);
         $option = 'com_' . strtolower($m[1]);
     }
     if (array_key_exists('option', $config)) {
         $option = $config['option'];
     }
     $config['option'] = $option;
     if (!array_key_exists('view', $config)) {
         $config['view'] = $config['input']->getCmd('view', 'cpanel');
     }
     if (is_null($type)) {
         if ($prefix == 'JTable') {
             $prefix = 'Table';
         }
         $type = $config['view'];
     }
     $type = preg_replace('/[^A-Z0-9_\\.-]/i', '', $type);
     $tableClass = $prefix . ucfirst($type);
     $configProvider = new FOFConfigProvider();
     $configProviderKey = $option . '.views.' . FOFInflector::singularize($type) . '.config.';
     if (!array_key_exists($tableClass, $instances)) {
         if (!class_exists($tableClass)) {
             list($isCLI, $isAdmin) = FOFDispatcher::isCliAdmin();
             if (!$isAdmin) {
                 $basePath = JPATH_SITE;
             } else {
                 $basePath = JPATH_ADMINISTRATOR;
             }
             $searchPaths = array($basePath . '/components/' . $config['option'] . '/tables', JPATH_ADMINISTRATOR . '/components/' . $config['option'] . '/tables');
             if (array_key_exists('tablepath', $config)) {
                 array_unshift($searchPaths, $config['tablepath']);
             }
             $altPath = $configProvider->get($configProviderKey . 'table_path', null);
             if ($altPath) {
                 array_unshift($searchPaths, JPATH_ADMINISTRATOR . '/components/' . $option . '/' . $altPath);
             }
             JLoader::import('joomla.filesystem.path');
             $path = JPath::find($searchPaths, strtolower($type) . '.php');
             if ($path) {
                 require_once $path;
             }
         }
         if (!class_exists($tableClass)) {
             $tableClass = 'FOFTable';
         }
         $tbl_common = str_replace('com_', '', $config['option']) . '_';
         if (!array_key_exists('tbl', $config)) {
             $config['tbl'] = strtolower('#__' . $tbl_common . strtolower(FOFInflector::pluralize($type)));
         }
         $altTbl = $configProvider->get($configProviderKey . 'tbl', null);
         if ($altTbl) {
             $config['tbl'] = $altTbl;
         }
         if (!array_key_exists('tbl_key', $config)) {
             $keyName = FOFInflector::singularize($type);
             $config['tbl_key'] = strtolower($tbl_common . $keyName . '_id');
         }
         $altTblKey = $configProvider->get($configProviderKey . 'tbl_key', null);
         if ($altTblKey) {
             $config['tbl_key'] = $altTblKey;
         }
         if (!array_key_exists('db', $config)) {
             $config['db'] = JFactory::getDBO();
         }
         $instance = new $tableClass($config['tbl'], $config['tbl_key'], $config['db']);
         $instance->setInput($tmpInput);
         if (array_key_exists('trigger_events', $config)) {
             $instance->setTriggerEvents($config['trigger_events']);
         }
         $instances[$tableClass] = $instance;
     }
     return $instances[$tableClass];
 }
Exemplo n.º 12
0
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

defined('_JEXEC') or die();

// Load FOF
if (file_exists(JPATH_LIBRARIES.'/fof/include.php')) {
	include_once JPATH_LIBRARIES.'/fof/include.php';
} else {
	include_once JPATH_COMPONENT_ADMINISTRATOR.'/fof/include.php';
}
if(!defined('FOF_INCLUDED')) {
	JFactory::getApplication()->enqueueMessage('Your Overload installation is broken; please re-install. Alternatively, extract the installation archive and copy the fof directory inside your site\'s libraries directory.', 'error');
	return false;
}

// Dispatch
FOFDispatcher::getTmpInstance('com_overload')->dispatch();
Exemplo n.º 13
0
 public function dispatch()
 {
     // Look for controllers in the plugins folder
     $option = $this->input->get('option', 'com_foobar', 'cmd');
     $view = $this->input->get('view', $this->defaultView, 'cmd');
     $c = FOFInflector::singularize($view);
     $alt_path = JPATH_SITE . '/components/' . $option . '/plugins/controllers/' . $c . '.php';
     JLoader::import('joomla.filesystem.file');
     if (JFile::exists($alt_path)) {
         // The requested controller exists and there you load it...
         require_once $alt_path;
     }
     $this->input->set('view', $this->view);
     parent::dispatch();
 }
Exemplo n.º 14
0
 /**
  * Applies CSRF protection by means of a standard Joomla! token (nonce) check.
  * Raises a 403 Access Forbidden error through JError or an exception
  * (depending the Joomla! version) if the check fails.
  *
  * @return  boolean  True if the CSRF check is successful
  */
 protected function _csrfProtection()
 {
     static $isCli = null, $isAdmin = null;
     if (is_null($isCli)) {
         list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     }
     switch ($this->csrfProtection) {
         // Never
         case 0:
             return true;
             break;
             // Always
         // Always
         case 1:
             break;
             // Only back-end and HTML format
         // Only back-end and HTML format
         case 2:
             if ($isCli) {
                 return true;
             } elseif (!$isAdmin && $this->input->get('format', 'html', 'cmd') != 'html') {
                 return true;
             }
             break;
             // Only back-end
         // Only back-end
         case 3:
             if (!$isAdmin) {
                 return true;
             }
             break;
     }
     $hasToken = false;
     $session = JFactory::getSession();
     // Joomla! 1.5/1.6/1.7/2.5 (classic Joomla! API) method
     if (method_exists('JUtility', 'getToken')) {
         $token = JUtility::getToken();
         $hasToken = $this->input->get($token, false, 'none') == 1;
         if (!$hasToken) {
             $hasToken = $this->input->get('_token', null, 'none') == $token;
         }
     }
     // Joomla! 2.5+ (Platform 12.1+) method
     if (!$hasToken) {
         if (method_exists($session, 'getToken')) {
             $token = $session->getToken();
             $hasToken = $this->input->get($token, false, 'none') == 1;
             if (!$hasToken) {
                 $hasToken = $this->input->get('_token', null, 'none') == $token;
             }
         }
     }
     // Joomla! 2.5+ formToken method
     if (!$hasToken) {
         if (method_exists($session, 'getFormToken')) {
             $token = $session->getFormToken();
             $hasToken = $this->input->get($token, false, 'none') == 1;
             if (!$hasToken) {
                 $hasToken = $this->input->get('_token', null, 'none') == $token;
             }
         }
     }
     if (!$hasToken) {
         if (version_compare(JVERSION, '3.0', 'ge')) {
             throw new Exception(JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'), 403);
         } else {
             JError::raiseError('403', JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN'));
         }
         return false;
     }
 }
Exemplo n.º 15
0
 public function __construct($config = array())
 {
     $this->defaultView = 'extensions';
     parent::__construct($config);
 }
Exemplo n.º 16
0
<?php

/**
 * @package     SP Simple Portfolio
 *
 * @copyright   Copyright (C) 2010 - 2014 JoomShaper. All rights reserved.
 * @license     GNU General Public License version 2 or later.
 */
defined('_JEXEC') or die;
$doc = JFactory::getDocument();
// Load FOF
include_once JPATH_LIBRARIES . '/fof/include.php';
if (!defined('FOF_INCLUDED')) {
    JError::raiseError('500', 'FOF is not installed');
    return;
}
FOFDispatcher::getTmpInstance('com_spsimpleportfolio')->dispatch();
Exemplo n.º 17
0
 /**
  * Executes before rendering a generic page, default to actions necessary
  * for the Browse task.
  *
  * @param   string  $tpl  Subtemplate to use
  *
  * @return  boolean  Return true to allow rendering of the page
  */
 protected function onDisplay($tpl = null)
 {
     $view = $this->input->getCmd('view', 'cpanel');
     if (in_array($view, array('cpanel', 'cpanels'))) {
         return;
     }
     // Load the model
     $model = $this->getModel();
     // ...ordering
     $this->lists->set('order', $model->getState('filter_order', 'id', 'cmd'));
     $this->lists->set('order_Dir', $model->getState('filter_order_Dir', 'DESC', 'cmd'));
     // Assign data to the view
     $this->assign('items', $model->getItemList());
     $this->assign('pagination', $model->getPagination());
     $this->assignRef('lists', $this->lists);
     //pass page params on frontend only
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     if (!$isAdmin && !$isCli) {
         $params = JFactory::getApplication()->getParams();
         $this->assignRef('params', $params);
     }
     return true;
 }
Exemplo n.º 18
0
 /**
  * This method runs after a record with key value $id is deleted
  *
  * @param   integer  $id  The id of the record which was deleted
  *
  * @return  boolean  Return false to raise an error, true otherwise
  */
 protected function onAfterDelete($id)
 {
     list($isCLI, $isAdmin) = FOFDispatcher::isCliAdmin();
     // Let's import the plugin only if we're not in CLI (content plugin needs a user)
     if (!$isCLI) {
         JPluginHelper::importPlugin('content');
     }
     $dispatcher = JDispatcher::getInstance();
     try {
         $name = $this->input->getCmd('view', 'cpanel');
         $context = $this->option . '.' . $name;
         $result = $dispatcher->trigger($this->event_after_delete, array($context, $this->_recordForDeletion));
         unset($this->_recordForDeletion);
     } catch (Exception $e) {
         // Oops, an exception occured!
         $this->setError($e->getMessage());
         return false;
     }
 }
Exemplo n.º 19
0
// Access check.
$user = JFactory::getUser();
$comp = 'com_babioonevent';
// START: Akeeba Live Update
$view = JFactory::getApplication()->input->get('view', 'cpanels');
// Load files if needed
if ($view == 'liveupdate' || $view == 'cpanels') {
    if (file_exists(JPATH_COMPONENT . '/liveupdate/liveupdate.php')) {
        require_once JPATH_COMPONENT . '/liveupdate/liveupdate.php';
    } else {
        return JError::raiseWarning(404, JText::_(strtoupper($comp) . '_COULD_NOT_LOAD_LIVEUPDATE_FILES'));
    }
}
if ($view == 'liveupdate') {
    if (JFactory::getUser()->authorise('core.admin', $comp)) {
        LiveUpdate::handleRequest();
        return;
    } else {
        return JError::raiseWarning(404, JText::_('JERROR_ALERTNOAUTHOR'));
    }
}
// END: Akeeba Live Update
$doc = JFactory::getDocument();
if (BabioonEventHelper::isVersion3()) {
    // Add css
    $doc->addStyleSheet(JURI::base(true) . '/../media/babioon/css/3x.css');
} else {
    $doc->addStyleSheet(JURI::base(true) . '/../media/babioon/css/2x.css');
}
FOFDispatcher::getTmpInstance('com_babioonevent')->dispatch();
/** EOF **/
Exemplo n.º 20
0
 /**
  * Automatically detects all views of the component
  *
  * @return array
  */
 protected function getMyViews()
 {
     $views = array();
     $t_views = array();
     $using_meta = false;
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     if ($isAdmin) {
         $basePath = JPATH_ADMINISTRATOR;
     } elseif ($isCli) {
         $basePath = JPATH_ROOT;
     } else {
         $basePath = JPATH_SITE;
     }
     $searchPath = $basePath . '/components/' . $this->component . '/views';
     JLoader::import('joomla.filesystem.folder');
     JLoader::import('joomla.utilities.arrayhelper');
     $allFolders = JFolder::folders($searchPath);
     if (!empty($allFolders)) {
         foreach ($allFolders as $folder) {
             $view = $folder;
             // View already added
             if (in_array(FOFInflector::pluralize($view), $t_views)) {
                 continue;
             }
             // Do we have a 'skip.xml' file in there?
             $files = JFolder::files($searchPath . '/' . $view, '^skip\\.xml$');
             if (!empty($files)) {
                 continue;
             }
             //Do we have extra information about this view? (ie. ordering)
             $meta = JFolder::files($searchPath . '/' . $view, '^metadata\\.xml$');
             //Not found, do we have it inside the plural one?
             if (!$meta) {
                 $plural = FOFInflector::pluralize($view);
                 if (in_array($plural, $allFolders)) {
                     $view = $plural;
                     $meta = JFolder::files($searchPath . '/' . $view, '^metadata\\.xml$');
                 }
             }
             if (!empty($meta)) {
                 $using_meta = true;
                 $xml = simplexml_load_file($searchPath . '/' . $view . '/' . $meta[0]);
                 $order = (int) $xml->foflib->ordering;
             } else {
                 // Next place. It's ok since the index are 0-based and count is 1-based
                 if (!isset($to_order)) {
                     $to_order = array();
                 }
                 $order = count($to_order);
             }
             $view = FOFInflector::pluralize($view);
             $t_view = new stdClass();
             $t_view->ordering = $order;
             $t_view->view = $view;
             $to_order[] = $t_view;
             $t_views[] = $view;
         }
     }
     JArrayHelper::sortObjects($to_order, 'ordering');
     $views = JArrayHelper::getColumn($to_order, 'view');
     //if not using the metadata file, let's put the cpanel view on top
     if (!$using_meta) {
         $cpanel = array_search('cpanels', $views);
         if ($cpanel !== false) {
             unset($views[$cpanel]);
             array_unshift($views, 'cpanels');
         }
     }
     return $views;
 }
Exemplo n.º 21
0
<?php

/**
 * @package     Joomla.Administrator
 * @subpackage  com_postinstall
 *
 * @copyright   Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */
defined('_JEXEC') or die;
// Load the RAD layer
if (!defined('FOF_INCLUDED')) {
    require_once JPATH_LIBRARIES . '/fof/include.php';
}
// Dispatch the component
FOFDispatcher::getTmpInstance('com_postinstall')->dispatch();
Exemplo n.º 22
0
    /**
     * Renders a FOFForm for a Browse view and returns the corresponding HTML
     *
     * @param   FOFForm   $form      The form to render
     * @param   FOFModel  $model     The model providing our data
     * @param   FOFInput  $input     The input object
     *
     * @return  string    The HTML rendering of the form
     */
    protected function renderFormBrowse(FOFForm &$form, FOFModel $model, FOFInput $input)
    {
        static $isCli = null, $isAdmin = null;
        if (is_null($isCli)) {
            list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
        }
        $html = '';
        // Joomla! 3.0+ support
        if (version_compare(JVERSION, '3.0', 'ge')) {
            JHtml::_('bootstrap.tooltip');
            JHtml::_('behavior.multiselect');
            JHtml::_('dropdown.init');
            JHtml::_('formbehavior.chosen', 'select');
            $view = $form->getView();
            $order = $view->escape($view->getLists()->order);
            $html .= <<<ENDJS
<script type="text/javascript">
\tJoomla.orderTable = function() {
\t\ttable = document.getElementById("sortTable");
\t\tdirection = document.getElementById("directionTable");
\t\torder = table.options[table.selectedIndex].value;
\t\tif (order != '{$order}') {
\t\t\tdirn = 'asc';
\t\t} else {
\t\t\tdirn = direction.options[direction.selectedIndex].value;
\t\t}
\t\tJoomla.tableOrdering(order, dirn, '');
\t}
</script>

ENDJS;
        }
        // Getting all header row elements
        $headerFields = $form->getHeaderset();
        // Get form parameters
        $show_header = $form->getAttribute('show_header', 1);
        $show_filters = $form->getAttribute('show_filters', 1);
        $show_pagination = $form->getAttribute('show_pagination', 1);
        $norows_placeholder = $form->getAttribute('norows_placeholder', '');
        // Joomla! 3.0 sidebar support
        if (version_compare(JVERSION, '3.0', 'gt') && $show_filters) {
            JHtmlSidebar::setAction("index.php?option=" . $input->getCmd('option') . "&view=" . FOFInflector::pluralize($input->getCmd('view')));
        }
        // Pre-render the header and filter rows
        $header_html = '';
        $filter_html = '';
        $sortFields = array();
        if ($show_header || $show_filters) {
            foreach ($headerFields as $headerField) {
                $header = $headerField->header;
                $filter = $headerField->filter;
                $buttons = $headerField->buttons;
                $options = $headerField->options;
                $sortable = $headerField->sortable;
                $tdwidth = $headerField->tdwidth;
                // Under Joomla! < 3.0 we can't have filter-only fields
                if (version_compare(JVERSION, '3.0', 'lt') && empty($header)) {
                    continue;
                }
                // If it's a sortable field, add to the list of sortable fields
                if ($sortable) {
                    $sortFields[$headerField->name] = JText::_($headerField->label);
                }
                // Get the table data width, if set
                if (!empty($tdwidth)) {
                    $tdwidth = 'width="' . $tdwidth . '"';
                } else {
                    $tdwidth = '';
                }
                if (!empty($header)) {
                    $header_html .= "\t\t\t\t\t<th {$tdwidth}>" . PHP_EOL;
                    $header_html .= "\t\t\t\t\t\t" . $header;
                    $header_html .= "\t\t\t\t\t</th>" . PHP_EOL;
                }
                if (version_compare(JVERSION, '3.0', 'ge')) {
                    // Joomla! 3.0 or later
                    if (!empty($filter)) {
                        $filter_html .= '<div class="filter-search btn-group pull-left">' . "\n";
                        $filter_html .= "\t" . '<label for="title" class="element-invisible">';
                        $filter_html .= $headerField->label;
                        $filter_html .= "</label>\n";
                        $filter_html .= "\t{$filter}\n";
                        $filter_html .= "</div>\n";
                        if (!empty($buttons)) {
                            $filter_html .= '<div class="btn-group pull-left hidden-phone">' . "\n";
                            $filter_html .= "\t{$buttons}\n";
                            $filter_html .= '</div>' . "\n";
                        }
                    } elseif (!empty($options)) {
                        $label = $headerField->label;
                        JHtmlSidebar::addFilter('- ' . JText::_($label) . ' -', (string) $headerField->name, JHtml::_('select.options', $options, 'value', 'text', $form->getModel()->getState($headerField->name, ''), true));
                    }
                } else {
                    // Joomla! 2.5
                    $filter_html .= "\t\t\t\t\t<td>" . PHP_EOL;
                    if (!empty($filter)) {
                        $filter_html .= "\t\t\t\t\t\t{$filter}" . PHP_EOL;
                        if (!empty($buttons)) {
                            $filter_html .= "\t\t\t\t\t\t<nobr>{$buttons}</nobr>" . PHP_EOL;
                        }
                    } elseif (!empty($options)) {
                        $label = $headerField->label;
                        $emptyOption = JHtml::_('select.option', '', '- ' . JText::_($label) . ' -');
                        array_unshift($options, $emptyOption);
                        $attribs = array('onchange' => 'document.adminForm.submit();');
                        $filter = JHtml::_('select.genericlist', $options, $headerField->name, $attribs, 'value', 'text', $headerField->value, false, true);
                        $filter_html .= "\t\t\t\t\t\t{$filter}" . PHP_EOL;
                    }
                    $filter_html .= "\t\t\t\t\t</td>" . PHP_EOL;
                }
            }
        }
        // Start the form
        $filter_order = $form->getView()->getLists()->order;
        $filter_order_Dir = $form->getView()->getLists()->order_Dir;
        $html .= '<form action="index.php" method="post" name="adminForm" id="adminForm">' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="view" value="' . FOFInflector::pluralize($input->getCmd('view')) . '" />' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="task" value="' . $input->getCmd('task', 'browse') . '" />' . PHP_EOL;
        // The id field is required in Joomla! 3 front-end to prevent the pagination limit box from screwing it up. Huh!!
        if (version_compare(JVERSION, '3.0', 'ge') && !$isAdmin && !$isCli) {
            $html .= "\t" . '<input type="hidden" name="id" value="' . $input->getCmd('id', '') . '" />' . PHP_EOL;
        }
        $html .= "\t" . '<input type="hidden" name="boxchecked" value="" />' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="hidemainmenu" value="" />' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="filter_order" value="' . $filter_order . '" />' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="filter_order_Dir" value="' . $filter_order_Dir . '" />' . PHP_EOL;
        $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL;
        if (version_compare(JVERSION, '3.0', 'ge')) {
            // Joomla! 3.0+
            // Get and output the sidebar, if present
            $sidebar = JHtmlSidebar::render();
            if ($show_filters && !empty($sidebar)) {
                $html .= '<div id="j-sidebar-container" class="span2">' . "\n";
                $html .= "\t{$sidebar}\n";
                $html .= "</div>\n";
                $html .= '<div id="j-main-container" class="span10">' . "\n";
            } else {
                $html .= '<div id="j-main-container">' . "\n";
            }
            // Render header search fields, if the header is enabled
            if ($show_header) {
                $html .= "\t" . '<div id="filter-bar" class="btn-toolbar">' . "\n";
                $html .= "{$filter_html}\n";
                if ($show_pagination) {
                    // Render the pagination rows per page selection box, if the pagination is enabled
                    $html .= "\t" . '<div class="btn-group pull-right hidden-phone">' . "\n";
                    $html .= "\t\t" . '<label for="limit" class="element-invisible">' . JText::_('JFIELD_PLG_SEARCH_SEARCHLIMIT_DESC') . '</label>' . "\n";
                    $html .= "\t\t" . $model->getPagination()->getLimitBox() . "\n";
                    $html .= "\t" . '</div>' . "\n";
                }
                if (!empty($sortFields)) {
                    // Display the field sort order
                    $asc_sel = $view->getLists()->order_Dir == 'asc' ? 'selected="selected"' : '';
                    $desc_sel = $view->getLists()->order_Dir == 'desc' ? 'selected="selected"' : '';
                    $html .= "\t" . '<div class="btn-group pull-right hidden-phone">' . "\n";
                    $html .= "\t\t" . '<label for="directionTable" class="element-invisible">' . JText::_('JFIELD_ORDERING_DESC') . '</label>' . "\n";
                    $html .= "\t\t" . '<select name="directionTable" id="directionTable" class="input-medium" onchange="Joomla.orderTable()">' . "\n";
                    $html .= "\t\t\t" . '<option value="">' . JText::_('JFIELD_ORDERING_DESC') . '</option>' . "\n";
                    $html .= "\t\t\t" . '<option value="asc" ' . $asc_sel . '>' . JText::_('JGLOBAL_ORDER_ASCENDING') . '</option>' . "\n";
                    $html .= "\t\t\t" . '<option value="desc" ' . $desc_sel . '>' . JText::_('JGLOBAL_ORDER_DESCENDING') . '</option>' . "\n";
                    $html .= "\t\t" . '</select>' . "\n";
                    $html .= "\t" . '</div>' . "\n\n";
                    // Display the sort fields
                    $html .= "\t" . '<div class="btn-group pull-right">' . "\n";
                    $html .= "\t\t" . '<label for="sortTable" class="element-invisible">' . JText::_('JGLOBAL_SORT_BY') . '</label>' . "\n";
                    $html .= "\t\t" . '<select name="sortTable" id="sortTable" class="input-medium" onchange="Joomla.orderTable()">' . "\n";
                    $html .= "\t\t\t" . '<option value="">' . JText::_('JGLOBAL_SORT_BY') . '</option>' . "\n";
                    $html .= "\t\t\t" . JHtml::_('select.options', $sortFields, 'value', 'text', $view->getLists()->order) . "\n";
                    $html .= "\t\t" . '</select>' . "\n";
                    $html .= "\t" . '</div>' . "\n";
                }
                $html .= "\t</div>\n\n";
                $html .= "\t" . '<div class="clearfix"> </div>' . "\n\n";
            }
        }
        // Start the table output
        $html .= "\t\t" . '<table class="table table-striped" id="itemsList">' . PHP_EOL;
        // Open the table header region if required
        if ($show_header || $show_filters && version_compare(JVERSION, '3.0', 'lt')) {
            $html .= "\t\t\t<thead>" . PHP_EOL;
        }
        // Render the header row, if enabled
        if ($show_header) {
            $html .= "\t\t\t\t<tr>" . PHP_EOL;
            $html .= $header_html;
            $html .= "\t\t\t\t</tr>" . PHP_EOL;
        }
        // Render filter row if enabled
        if ($show_filters && version_compare(JVERSION, '3.0', 'lt')) {
            $html .= "\t\t\t\t<tr>";
            $html .= $filter_html;
            $html .= "\t\t\t\t</tr>";
        }
        // Close the table header region if required
        if ($show_header || $show_filters && version_compare(JVERSION, '3.0', 'lt')) {
            $html .= "\t\t\t</thead>" . PHP_EOL;
        }
        // Loop through rows and fields, or show placeholder for no rows
        $html .= "\t\t\t<tbody>" . PHP_EOL;
        $fields = $form->getFieldset('items');
        $num_columns = count($fields);
        $items = $form->getModel()->getItemList();
        if ($count = count($items)) {
            $m = 1;
            foreach ($items as $i => $item) {
                $table_item = $form->getModel()->getTable();
                $table_item->bind($item);
                $form->bind($item);
                $m = 1 - $m;
                $class = 'row' . $m;
                $html .= "\t\t\t\t<tr class=\"{$class}\">" . PHP_EOL;
                $fields = $form->getFieldset('items');
                foreach ($fields as $field) {
                    $field->rowid = $i;
                    $field->item = $table_item;
                    $class = $field->labelClass ? 'class ="' . $field->labelClass . '"' : '';
                    $html .= "\t\t\t\t\t<td {$class}>" . $field->getRepeatable() . '</td>' . PHP_EOL;
                }
                $html .= "\t\t\t\t</tr>" . PHP_EOL;
            }
        } elseif ($norows_placeholder) {
            $html .= "\t\t\t\t<tr><td colspan=\"{$num_columns}\">";
            $html .= JText::_($norows_placeholder);
            $html .= "</td></tr>\n";
        }
        $html .= "\t\t\t</tbody>" . PHP_EOL;
        // Render the pagination bar, if enabled, on J! 2.5
        if ($show_pagination && version_compare(JVERSION, '3.0', 'lt')) {
            $pagination = $form->getModel()->getPagination();
            $html .= "\t\t\t<tfoot>" . PHP_EOL;
            $html .= "\t\t\t\t<tr><td colspan=\"{$num_columns}\">";
            if ($pagination->total > 0) {
                $html .= $pagination->getListFooter();
            }
            $html .= "</td></tr>\n";
            $html .= "\t\t\t</tfoot>" . PHP_EOL;
        }
        // End the table output
        $html .= "\t\t" . '</table>' . PHP_EOL;
        // Render the pagination bar, if enabled, on J! 3.0+
        if ($show_pagination && version_compare(JVERSION, '3.0', 'ge')) {
            $html .= $model->getPagination()->getListFooter();
        }
        // Close the wrapper element div on Joomla! 3.0+
        if (version_compare(JVERSION, '3.0', 'ge')) {
            $html .= "</div>\n";
        }
        // End the form
        $html .= '</form>' . PHP_EOL;
        return $html;
    }
Exemplo n.º 23
0
<?php

/**
 * @package ZLManager
 * @copyright Copyright (c)2011 JOOlanders SL
 * @license GNU General Public License version 2, or later
 */
// Protect from unauthorized access
defined('_JEXEC') or die('Restricted Access');
// Get and execute the controller (FOF!)
require_once JPATH_COMPONENT_ADMINISTRATOR . '/fof/include.php';
// Dispatch
FOFDispatcher::getAnInstance('com_zlmanager')->dispatch();
Exemplo n.º 24
0
 /**
  * Get the rendering of this field type for a repeatable (grid) display,
  * e.g. in a view listing many item (typically a "browse" task)
  *
  * @since 2.0
  *
  * @return  string  The field HTML
  */
 public function getRepeatable()
 {
     // Initialise
     $show_username = true;
     $show_email = true;
     $show_name = true;
     $show_id = true;
     $show_avatar = true;
     $show_link = false;
     $link_url = null;
     $avatar_method = 'gravatar';
     $avatar_size = 64;
     $class = '';
     // Get the user record
     $user = JFactory::getUser($this->value);
     // Get the field parameters
     if ($this->element['class']) {
         $class = ' class="' . (string) $this->element['class'] . '"';
     }
     if ($this->element['show_username'] == 'false') {
         $show_username = false;
     }
     if ($this->element['show_email'] == 'false') {
         $show_email = false;
     }
     if ($this->element['show_name'] == 'false') {
         $show_name = false;
     }
     if ($this->element['show_id'] == 'false') {
         $show_id = false;
     }
     if ($this->element['show_avatar'] == 'false') {
         $show_avatar = false;
     }
     if ($this->element['avatar_method']) {
         $avatar_method = strtolower($this->element['avatar_method']);
     }
     if ($this->element['avatar_size']) {
         $avatar_size = $this->element['avatar_size'];
     }
     if ($this->element['show_link'] == 'true') {
         $show_link = true;
     }
     if ($this->element['link_url']) {
         $link_url = $this->element['link_url'];
     } else {
         list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
         if ($isAdmin) {
             // If no link is defined in the back-end, assume the user edit
             // link in the User Manager component
             $link_url = 'index.php?option=com_users&task=user.edit&id=[USER:ID]';
         } else {
             // If no link is defined in the front-end, we can't create a
             // default link. Therefore, show no link.
             $show_link = false;
         }
     }
     // Post-process the link URL
     if ($show_link) {
         $replacements = array('[USER:ID]' => $user->id, '[USER:USERNAME]' => $user->username, '[USER:EMAIL]' => $user->email, '[USER:NAME]' => $user->name);
         foreach ($replacements as $key => $value) {
             $link_url = str_replace($key, $value, $link_url);
         }
     }
     // Get the avatar image, if necessary
     if ($show_avatar) {
         $avatar_url = '';
         if ($avatar_method == 'plugin') {
             // Use the user plugins to get an avatar
             JPluginHelper::importPlugin('user');
             $dispatcher = JDispatcher::getInstance();
             $jResponse = $dispatcher->trigger('onUserAvatar', array($user, $avatar_size));
             if (!empty($jResponse)) {
                 foreach ($jResponse as $response) {
                     if ($response) {
                         $avatar_url = $response;
                     }
                 }
             }
             if (empty($avatar_url)) {
                 $show_avatar = false;
             }
         } else {
             // Fall back to the Gravatar method
             $md5 = md5($user->email);
             list($isCLI, $isAdmin) = FOFDispatcher::isCliAdmin();
             if ($isCLI) {
                 $scheme = 'http';
             } else {
                 $scheme = JURI::getInstance()->getScheme();
             }
             if ($scheme == 'http') {
                 $url = 'http://www.gravatar.com/avatar/' . $md5 . '.jpg?s=' . $avatar_size . '&d=mm';
             } else {
                 $url = 'https://secure.gravatar.com/avatar/' . $md5 . '.jpg?s=' . $avatar_size . '&d=mm';
             }
         }
     }
     // Generate the HTML
     $html = '<div id="' . $this->id . '" ' . $class . '>';
     if ($show_avatar) {
         $html .= '<img src="' . $avatar_url . '" align="left" class="fof-usersfield-avatar" />';
     }
     if ($show_link) {
         $html .= '<a href="' . $link_url . '">';
     }
     if ($show_username) {
         $html .= '<span class="fof-usersfield-username">' . $user->username . '</span>';
     }
     if ($show_id) {
         $html .= '<span class="fof-usersfield-id">' . $user->id . '</span>';
     }
     if ($show_name) {
         $html .= '<span class="fof-usersfield-name">' . $user->name . '</span>';
     }
     if ($show_email) {
         $html .= '<span class="fof-usersfield-email">' . $user->email . '</span>';
     }
     if ($show_link) {
         $html .= '</a>';
     }
     $html .= '</div>';
     return $html;
 }
 /**
  * Autoload Toolbars
  *
  * @param   string  $class_name  The name of the class to load
  *
  * @return  void
  */
 public function autoload_fof_toolbar($class_name)
 {
     JLog::add(__METHOD__ . "() autoloading {$class_name}", JLog::DEBUG, 'fof');
     static $isCli = null, $isAdmin = null;
     if (is_null($isCli) && is_null($isAdmin)) {
         list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     }
     if (strpos($class_name, 'Toolbar') === false) {
         return;
     }
     // Change from camel cased into a lowercase array
     $class_modified = preg_replace('/(\\s)+/', '_', $class_name);
     $class_modified = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $class_modified));
     $parts = explode('_', $class_modified);
     // We need two parts in the name
     if (count($parts) != 2) {
         return;
     }
     // We need the second part to be "model"
     if ($parts[1] != 'toolbar') {
         return;
     }
     // Get the information about this class
     $component_raw = $parts[0];
     $component = 'com_' . $parts[0];
     // Get the proper and alternate paths and file names
     $file = "/components/{$component}/toolbar.php";
     $path = $isAdmin || $isCli ? JPATH_ADMINISTRATOR : JPATH_SITE;
     $altPath = $isAdmin || $isCli ? JPATH_SITE : JPATH_ADMINISTRATOR;
     // Try to find the proper class in the proper path
     if (file_exists($path . $file)) {
         @(include_once $path . $file);
     }
     // Try to find the proper class in the alternate path
     if (!class_exists($class_name) && file_exists($altPath . $file)) {
         @(include_once $altPath . $file);
     }
     // No class found? Map to FOFToolbar
     if (!class_exists($class_name)) {
         $this->class_alias('FOFToolbar', $class_name, true);
     }
 }
Exemplo n.º 26
0
 /**
  * Renders the toolbar buttons
  *
  * @param   string    $view    The active view name
  * @param   string    $task    The current task
  * @param   FOFInput  $input   The input object
  * @param   array     $config  Extra configuration variables for the toolbar
  */
 protected function renderButtons($view, $task, $input, $config = array())
 {
     list($isCli, $isAdmin) = FOFDispatcher::isCliAdmin();
     // On command line don't do anything
     if ($isCli) {
         return;
     }
     // Do not render buttons unless we are in the the frontend area and we are asked to do so
     $toolbar = FOFToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config);
     $renderFrontendButtons = $toolbar->getRenderFrontendButtons();
     if ($isAdmin || !$renderFrontendButtons) {
         return;
     }
     // Load main backend language, in order to display toolbar strings
     // (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc)
     $jlang = JFactory::getLanguage();
     $jlang->load('joomla', JPATH_ADMINISTRATOR, null, true);
     $title = JFactory::getApplication()->get('JComponentTitle');
     $bar = JToolBar::getInstance('toolbar');
     // delete faux links, since if SEF is on, Joomla will follow the link instead of submitting the form
     $bar_content = str_replace('href="#"', '', $bar->render());
     echo '<div id="FOFHeaderHolder">', $bar_content, $title, '<div style="clear:both"></div>', '</div>';
 }