Esempio n. 1
0
 function __construct($site = GCORE_SITE, $thread = 'gcore')
 {
     $app = \GCore\Bootstrap::getApp($site, $thread);
     $this->site = $site;
     $this->thread = $thread;
     $this->_vars = $app->_vars;
     $this->data =& Request::raw();
     //&$_POST;
     //$this->data = array_merge($_GET, $this->data);
     $this->path = $app->path;
     $this->url = $app->url;
     $this->name = get_class($this);
     $this->action = $app->action;
     //set models properties
     if (!empty($this->models)) {
         $this->models = (array) $this->models;
         foreach ($this->models as $model) {
             $alias = Base::getClassName($model);
             $this->{$alias} = new $model();
         }
     }
     //set libs properties
     if (!empty($this->libs)) {
         $this->libs = (array) $this->libs;
         foreach ($this->libs as $lib) {
             $alias = Base::getClassName($lib);
             if (in_array('getInstance', get_class_methods($lib))) {
                 $this->{$alias} = $lib::getInstance();
             } else {
                 $this->{$alias} = new $lib();
             }
             $this->{$alias}->controller =& $this;
         }
     }
 }
Esempio n. 2
0
 function __construct($area, $joption, $extension, $setup = null, $cont_vars = array())
 {
     require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'gcloader.php';
     if (phpversion('pdo') !== false and in_array('mysql', PDO::getAvailableDrivers())) {
         //good, we use PDO
         \GCore\Libs\Base::setConfig('db_adapter', 'joomla');
     } else {
         \GCore\Libs\Base::setConfig('db_adapter', 'joomla');
     }
     \GCore\C::set('EXTENSIONS_PATHS', array(dirname(__FILE__) . DS . 'admin' . DS . 'extensions' . DS => JPATH_SITE . DS . 'administrator' . DS . 'components' . DS, dirname(__FILE__) . DS . 'extensions' . DS => JPATH_SITE . DS . 'components' . DS));
     \GCore\C::set('EXTENSIONS_URLS', array(\JFactory::getURI()->root() . 'libraries/cegcore/admin/extensions/' => \JFactory::getURI()->root() . 'administrator/components/', \JFactory::getURI()->root() . 'libraries/cegcore/extensions/' => \JFactory::getURI()->root() . 'components/'));
     \GCore\C::set('EXTENSIONS_NAMES', array('chronomigrator' => 'com_chronomigrator', 'chronoforms' => 'com_chronoforms5', 'chronoconnectivity' => 'com_chronoconnectivity5', 'chronoforums' => 'com_chronoforums', 'chronolistings' => 'com_chronolistings', 'chronocommunity' => 'com_chronocommunity', 'chronosearch' => 'com_chronosearch', 'chronocontact' => 'com_chronocontact', $extension => 'com_' . $joption));
     //GCore\Libs\Url::$root_ext = array('components', 'com_'.$joption);
     \GCore\Bootstrap::initialize('joomla', array('component' => 'com_' . $joption, 'ext' => $extension));
     $tvout = strlen(\GCore\Libs\Request::data('tvout', null)) > 0 ? \GCore\Libs\Request::data('tvout') : '';
     $controller = \GCore\Libs\Request::data('cont', '');
     $action = \GCore\Libs\Request::data('act', '');
     if (is_callable($setup)) {
         $return_vars = $setup();
         if (!empty($return_vars)) {
             $cont_vars = array_merge($cont_vars, $return_vars);
         }
     }
     if (isset($cont_vars['controller'])) {
         $controller = $cont_vars['controller'];
     }
     if (isset($cont_vars['action'])) {
         $action = $cont_vars['action'];
     }
     $cont_vars['_app_thread'] = 'gcore';
     ob_start();
     echo \GCore\Libs\AppJ::call($area, $extension, $controller, $action, $cont_vars);
     $output = ob_get_clean();
     $output = \GCore\C::fix_urls($output);
     if ($tvout == 'ajax') {
         echo $output;
         $mainframe = \JFactory::getApplication();
         $mainframe->close();
     } else {
         ob_start();
         $toolbar = \GCore\Helpers\Module::render(array('type' => 'toolbar', 'site' => 'admin', 'params' => ''));
         $messages = \GCore\Libs\AppJ::getSystemMessages();
         echo \GCore\Libs\AppJ::getHeader();
         if ($toolbar) {
             echo $toolbar;
             echo '<div style="clear:both;"></div>';
         }
         echo $messages;
         //echo \GCore\Libs\AppJ::getHeader();
         $system_output = ob_get_clean();
         $system_output = \GCore\C::fix_urls($system_output);
         echo $system_output;
         echo $output;
     }
 }
Esempio n. 3
0
 public static function call($site, $extension, $controller = '', $action = '', $params = array(), $check_perm = true)
 {
     //$x_app = self::getInstance($site, 'x_core_'.rand());
     $x_app = \GCore\Bootstrap::getApp($site, 'x_core_' . rand());
     $x_app->extension = $extension;
     $x_app->controller = $controller;
     $x_app->action = $action;
     $x_app->set($params);
     $x_app->dispatch(true, $check_perm);
     return $x_app->buffer;
 }