示例#1
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;
     }
 }
示例#2
0
 public static function initialize($plathform = '', $params = array())
 {
     switch ($plathform) {
         default:
             //CONSTANTS
             \GCore\C::set('GCORE_FRONT_PATH', dirname(__FILE__) . DS);
             \GCore\C::set('GCORE_ADMIN_PATH', dirname(__FILE__) . DS . 'admin' . DS);
             //initialize language
             \GCore\Libs\Lang::initialize();
             //SET ERROR CONFIG
             if ((int) Libs\Base::getConfig('error_reporting') != 1) {
                 error_reporting((int) Libs\Base::getConfig('error_reporting'));
             }
             if ((bool) Libs\Base::getConfig('debug') === true) {
                 \GCore\Libs\Error::initialize();
             }
             //timezone
             date_default_timezone_set(Libs\Base::getConfig('timezone', 'UTC'));
             break;
     }
     if ($plathform == 'joomla') {
         $mainframe = \JFactory::getApplication();
         \GCore\Libs\Base::setConfig('db_host', $mainframe->getCfg('host'));
         $dbtype = $mainframe->getCfg('dbtype') == 'mysqli' ? 'mysql' : $mainframe->getCfg('dbtype');
         \GCore\Libs\Base::setConfig('db_type', $dbtype);
         \GCore\Libs\Base::setConfig('db_name', $mainframe->getCfg('db'));
         \GCore\Libs\Base::setConfig('db_user', $mainframe->getCfg('user'));
         \GCore\Libs\Base::setConfig('db_pass', $mainframe->getCfg('password'));
         \GCore\Libs\Base::setConfig('db_prefix', $mainframe->getCfg('dbprefix'));
         \GCore\C::set('GSITE_PLATFORM', 'joomla');
         \GCore\C::set('GCORE_FRONT_URL', \JFactory::getURI()->root() . 'libraries/cegcore/');
         \GCore\C::set('GCORE_ADMIN_URL', \JFactory::getURI()->root() . 'libraries/cegcore/admin/');
         \GCore\C::set('GCORE_ROOT_URL', \JFactory::getURI()->root());
         \GCore\C::set('GCORE_ROOT_PATH', dirname(dirname(dirname(__FILE__))) . DS);
         $lang = \JFactory::getLanguage();
         \GCore\Libs\Base::setConfig('site_language', $lang->getTag());
     } else {
         if ($plathform == 'wordpress') {
             global $wpdb;
             \GCore\Libs\Base::setConfig('db_host', DB_HOST);
             $dbtype = 'mysql';
             \GCore\Libs\Base::setConfig('db_type', $dbtype);
             \GCore\Libs\Base::setConfig('db_name', DB_NAME);
             \GCore\Libs\Base::setConfig('db_user', DB_USER);
             \GCore\Libs\Base::setConfig('db_pass', DB_PASSWORD);
             \GCore\Libs\Base::setConfig('db_prefix', $wpdb->prefix);
             \GCore\C::set('GSITE_PLATFORM', 'wordpress');
             \GCore\C::set('GCORE_FRONT_URL', plugins_url() . '/' . $params['component'] . '/cegcore/');
             \GCore\C::set('GCORE_ADMIN_URL', plugins_url() . '/' . $params['component'] . '/cegcore/admin/');
             \GCore\C::set('GCORE_ROOT_URL', site_url() . '/');
             \GCore\C::set('GCORE_ROOT_PATH', dirname(dirname(dirname(__FILE__))) . DS);
             \GCore\Libs\Base::setConfig('site_language', get_bloginfo('language'));
             //change the default page parameter string because WP uses the param "page"
             \GCore\Libs\Base::setConfig('page_url_param_name', 'page_num');
             if (function_exists('wp_magic_quotes')) {
                 $stripslashes_wp = function (&$value) {
                     $value = stripslashes($value);
                 };
                 array_walk_recursive($_GET, $stripslashes_wp);
                 array_walk_recursive($_POST, $stripslashes_wp);
                 array_walk_recursive($_COOKIE, $stripslashes_wp);
                 array_walk_recursive($_REQUEST, $stripslashes_wp);
             }
         } else {
             \GCore\C::set('GSITE_PLATFORM', '');
             \GCore\C::set('GCORE_FRONT_URL', \GCore\Libs\Url::root());
             \GCore\C::set('GCORE_ADMIN_URL', \GCore\Libs\Url::root() . 'admin/');
             \GCore\C::set('GCORE_ROOT_URL', \GCore\C::get('GCORE_FRONT_URL'));
             \GCore\C::set('GCORE_ROOT_PATH', dirname(__FILE__) . DS);
         }
     }
     \GCore\C::set('GSITE_PATH', \GCore\C::get('GCORE_' . strtoupper(GCORE_SITE) . '_PATH'));
     \GCore\C::set('GSITE_URL', \GCore\C::get('GCORE_' . strtoupper(GCORE_SITE) . '_URL'));
 }