/**
  * Constructor (do not call directly, use DI to call it)
  *
  * Code in here was previously in plugin.foundation.php
  *
  * @param  ApplicationContainerInterface  $di  (This is injected by DI)
  */
 function __construct(ApplicationContainerInterface $di)
 {
     if (self::$loaded) {
         return;
     }
     self::$loaded = true;
     define('_CB_JQUERY_VERSION', '1.11.2');
     // IMPORTANT: when changing version here also change in the 2 XML installation files
     /**
      * CB GLOBALS and initializations
      */
     global $mainframe;
     $mainframe = JFactory::getApplication();
     /** @noinspection PhpDeprecationInspection */
     $acl = JFactory::getACL();
     $sefFunc = array('JRoute', '_');
     $getVarFunction = array('JRequest', 'getVar');
     $Jdocument = JFactory::getDocument();
     if ($Jdocument->getType() == 'html') {
         $getDocFunction = array('JFactory', 'getDocument');
     } else {
         $getDocFunction = false;
     }
     $editor = JFactory::getEditor();
     $editorDisplay = array('display' => array('call' => array($editor, 'display'), 'args' => 'noid'), 'save' => array('call' => array($editor, 'save'), 'args' => 'noid'), 'returns' => true);
     $aclParams = array('canEditUsers' => array('com_comprofiler', 'core.edit', 'users', null), 'canBlockUsers' => array('com_comprofiler', 'core.edit.state', 'users', null), 'canReceiveAdminEmails' => array('com_comprofiler', 'core.admin', 'users', null), 'canEditOwnContent' => array('com_content', 'core.edit.own', 'users', null, 'content', 'own'), 'canAddAllContent' => array('com_content', 'core.create', 'users', null, 'content', 'all'), 'canEditAllContent' => array('com_content', 'core.edit', 'users', null, 'content', 'all'), 'canPublishContent' => array('com_content', 'core.edit.state', 'users', null, 'content', 'all'), 'canInstallPlugins' => array('com_installer', 'core.manage', 'users', null), 'canManageUsers' => array('com_comprofiler', 'core.manage', 'users', null));
     /**
      * CB framework
      * @global CBframework $_CB_framework
      */
     global $_CB_framework;
     $_CB_framework = new CBframework($mainframe, $aclParams, $sefFunc, array('option' => 'com_comprofiler'), $getVarFunction, $getDocFunction, $editorDisplay);
     /** @see CBACL */
     $_CB_framework->acl = $di->get('CBACL', array('acl' => $acl));
     $di->set('CBFramework', $_CB_framework, true);
     /**
      * CB Config
      * @deprecated 2.0, use Application::Config() to get the Configuration Registry object
      * @see Application::Config()
      * @var array
      */
     global $ueConfig;
     $ueConfig['version'] = CBLIB;
     // This doesn't load if yet if in installer, as config database table may not yet be created:
     CBConfig::loadLegacyCBueConfig(true);
     // Lazy-loads later the language files:
     // This is useful if CBLib is loaded too early by plugins before language selection happened in Joomla (solves bug #5360).
     $di->get('Language')->addLanguageFile(function () use($di) {
         if ($di->getCms()->getClientId() === 0) {
             cbimport('language.front');
         } else {
             cbimport('language.all');
         }
     });
     define('_CB_SPOOFCHECKS', isset($ueConfig['enableSpoofCheck']) && $ueConfig['enableSpoofCheck'] ? 1 : 0);
 }
Ejemplo n.º 2
0
 /**
  * Handles an InputInterface\input request and returns the corresponding Output in the container
  * Raises an Core\Exception if task to do is not known or not authorized.
  *
  * @param   string              $method
  * @return  void
  *
  * @throws  \Exception
  */
 public function execute($method)
 {
     $route = array('option' => 'com_comprofiler', 'view' => $this->options['view'], 'action' => $method, 'method' => $this->input->get('act', 'edit', GetterInterface::COMMAND));
     /** @var \CBLib\AhaWow\Controller\Controller $ahaWowController */
     $ahaWowController = $this->di->get('CBLib\\AhaWow\\Controller\\Controller', array('options' => $this->options));
     $ahaWowController->dispatchRoute($route);
 }
Ejemplo n.º 3
0
 /**
  * Handles an InputInterface\input request and returns the corresponding Output in the container
  * Raises an Core\Exception if task to do is not known or not authorized.
  *
  * @param  array            $route   Route of method to execute
  * @param  OutputInterface  $output  Output object
  * @return void
  */
 public function execute(array $route, OutputInterface $output)
 {
     /** @var ActionController $actionController */
     /** @see CBLib\AhaWow\Controller\ActionController::__construct() */
     $actionController = $this->di->get('CBLib\\AhaWow\\Controller\\ActionController', array('input' => $this->input, 'output' => $output, 'options' => $this->options, 'getParams' => $this->getParams, 'data' => $this->data));
     $actionController->setGetParams($this->getParams);
     $actionController->setOptions($this->options);
     $actionController->setData($this->data);
     $outputString = $actionController->handleAction($route);
     $output->append($outputString);
 }
Ejemplo n.º 4
0
 /**
  * Routes and executes the request:
  * Handles a CBLib\input request and returns the corresponding CBLib\Output\Output in the Container
  * using CBLib\RouterInterface and invoking a CBLib\Controller
  * Raises an CBLib\Exception if task to do is not known or not authorized.
  *
  * @return  void
  *
  * @throws  \DomainException
  */
 public function dispatch()
 {
     // Get array( 'classname', 'methodname' ) of the Controller to call:
     $callable = $this->router->parseRoute($this->input);
     if (!is_array($callable)) {
         throw new \DomainException('No route found for this CBLib request.', 404);
     }
     $mainRoutingArgs = $this->router->getMainRoutingArgs();
     // Check if class exists, and if not, use default generic one:
     if (!class_exists($callable[0])) {
         $callable[0] = 'CBLib\\Controller\\Controller';
     }
     // Instantiate the Controller for that task:
     /** @var Controller  $controllerInstance */
     $controllerInstance = $this->di->get($callable[0], array('options' => $mainRoutingArgs));
     if (!is_callable(array($controllerInstance, 'dispatch'))) {
         throw new \DomainException('No route found for this CBLib request.', 404);
     }
     $controllerInstance->dispatch($callable[1]);
 }
Ejemplo n.º 5
0
 /**
  * @param  ApplicationContainerInterface  $di
  * @param  string                         $type    'Web' or 'Cli'
  * @param  array|InputInterface           $input
  * @return InputInterface
  *
  * @throws \InvalidArgumentException
  */
 public function getInput(ApplicationContainerInterface $di, $type, $input)
 {
     // Standalone case without input:
     $srcGpc = $input === null && $type == 'Web';
     if ($srcGpc) {
         //TODO Check here how we could use in the future JInput (which has buggy getArray()).
         // $_REQUEST is needed here because of Joomla's SEF populating only $_REQUEST:
         $input = array_merge($_GET, $_POST, $_REQUEST);
     }
     // Standalone case continued or array for input:
     if (is_array($input)) {
         /** @see \CBLib\Input\Input::__construct() */
         return $di->get('CBLib\\Input\\Input', array('source' => $input, 'srcGp' => $srcGpc))->setNamespaceRegistry('get', $di->get('CBLib\\Input\\Input', array('source' => $_GET, 'srcGp' => $srcGpc)))->setNamespaceRegistry('post', $di->get('CBLib\\Input\\Input', array('source' => $_POST, 'srcGp' => $srcGpc)))->setNamespaceRegistry('files', $di->get('CBLib\\Input\\Input', array('source' => $_FILES, 'srcGp' => $srcGpc)))->setNamespaceRegistry('cookie', $di->get('CBLib\\Input\\Input', array('source' => $_COOKIE, 'srcGp' => $srcGpc)))->setNamespaceRegistry('server', $di->get('CBLib\\Input\\Input', array('source' => $_SERVER, 'srcGp' => $srcGpc)))->setNamespaceRegistry('env', $di->get('CBLib\\Input\\Input', array('source' => $_ENV, 'srcGp' => $srcGpc)));
     }
     // From now on it can only be an object:
     if (!is_object($input)) {
         throw new \InvalidArgumentException('Invalid input argument in CBLib SetMainInput');
     }
     // Already InputInterface:
     if ($input instanceof InputInterface) {
         return $input;
     }
     /** This could be a way to get all inputs from Joomla, but it is not fast because no way to get just the keys or data:
      *	if ( ! $input ) {
      *		// This is not usable and filter is buggy in Joomla 3.3 unfortunately, so can't use:		$input		=	\JFactory::getApplication()->input->getArray();
      *		$inputKeys		=	array_keys( \JFactory::getApplication()->input->getArray() );
      *		$input			=	array();
      *		foreach ( $inputKeys as $k ) {
      *			$input[$k]	=	\JFactory::getApplication()->input->get( $k, null, 'raw' );
      *		}
      *	}
      */
     /** @see \CBLib\Input\Input::__construct() */
     /** @var \JInput|\Traversable $input */
     return $di->get('CBLib\\Input\\Input', array('source' => $input));
 }