Exemplo n.º 1
0
 /**
  * loads a plugins main php file
  *
  * @param  PluginTable  $plugin
  * @return bool
  */
 public function _loadPluginFile($plugin)
 {
     /** @noinspection PhpUnusedLocalVariableInspection */
     global $_CB_framework, $_PLUGINS;
     // $_PLUGINS is needed for the include below.
     // We don't want language files PHP loading as we do that through cbimport:
     if ($plugin->type == 'language') {
         return false;
     }
     $path = $_CB_framework->getCfg('absolute_path') . '/' . $this->getPluginRelPath($plugin) . '/' . $plugin->element . '.php';
     if (file_exists($path) && is_readable($path)) {
         $savePreviousPluginId = $this->_setLoading($plugin, true);
         $langCache = CBTxt::setLanguage(null);
         $plgLangPath = $_CB_framework->getCfg('absolute_path') . '/' . $this->getPluginRelPath($plugin) . '/language';
         $langPath = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/language';
         $lang = $_CB_framework->getCfg('lang_tag');
         if ($_CB_framework->getUi() == 2) {
             $langLoaded = CBTxt::import($langPath, $lang, '/cbplugin/' . $plugin->element . '-admin_language.php', false);
             if (!$langLoaded) {
                 CBTxt::import($plgLangPath, $lang, 'admin_language.php');
             }
         }
         $langLoaded = CBTxt::import($langPath, $lang, 'cbplugin/' . $plugin->element . '-language.php', false);
         if (!$langLoaded) {
             CBTxt::import($plgLangPath, $lang, 'language.php');
         }
         // We don't want plugins language files to alter the current language loaded so lets reset it:
         CBTxt::setLanguage($langCache);
         /** @noinspection PhpIncludeInspection */
         require_once $path;
         $this->_setLoading($plugin, $savePreviousPluginId);
         return true;
     } else {
         return false;
     }
 }
 /**
  * Includes CB library
  * --- usage: cbimport('cb.xml.simplexml');
  *
  * @param  string  $lib
  * @return void
  */
 function cbimport($lib)
 {
     global $_CB_framework;
     static $imported = array();
     static $tmpClasses = array('cb.html', 'cb.tabs', 'cb.field', 'cb.calendar', 'cb.connection', 'cb.notification');
     if (!isset($imported[$lib])) {
         $liblow = strtolower($lib);
         $pathAr = explode('.', $liblow);
         if ($pathAr[0] == 'language') {
             $langPath = $_CB_framework->getCfg('absolute_path') . '/components/com_comprofiler/plugin/language';
             $langTag = $_CB_framework->getCfg('lang_tag');
             if (!isset($imported['language.front'])) {
                 $imported['language.front'] = true;
                 CBTxt::import($langPath, $langTag, 'language.php');
             }
             if ($pathAr[1] == 'all' && !isset($imported['language.admin'])) {
                 $imported['language.admin'] = true;
                 CBTxt::import($langPath, $langTag, 'admin_language.php');
             }
         } elseif ($lib == 'cb.plugins') {
             // this part is temporary until we refactor those 2 files into the corresponding CB libraries:
             /** @noinspection PhpIncludeInspection */
             require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.class.php';
         } elseif (in_array($lib, $tmpClasses)) {
             // We need to make absolute sure we have our translations before we load our plugins and classes:
             if ($_CB_framework->getUi() == 1) {
                 $loadLang = 'language.front';
             } else {
                 $loadLang = 'language.all';
             }
             if (!isset($imported[$loadLang])) {
                 cbimport($loadLang);
             }
             // this part is temporary until we refactor those 2 files into the corresponding CB libraries:
             if (!isset($imported['cb.plugins'])) {
                 $imported['cb.plugins'] = true;
                 /** @noinspection PhpIncludeInspection */
                 require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/plugin.class.php';
             }
             if (!isset($imported['class'])) {
                 $imported['class'] = true;
                 /** @noinspection PhpIncludeInspection */
                 require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/comprofiler.class.php';
                 new LegacyComprofilerFunctions();
             }
         } elseif ($lib == 'cb.imgtoolbox') {
             // this part is temporary until we refactor those 2 files into the corresponding CB libraries:
             /** @noinspection PhpIncludeInspection */
             require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/imgToolbox.class.php';
         } elseif ($lib == 'cb.snoopy') {
             /** @noinspection PhpIncludeInspection */
             require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/Snoopy.class.php';
         } else {
             array_pop($pathAr);
             $filepath = implode('/', $pathAr) . (count($pathAr) ? '/' : '') . $liblow . '.php';
             /** @noinspection PhpIncludeInspection */
             require_once $_CB_framework->getCfg('absolute_path') . '/administrator/components/com_comprofiler/library/' . $filepath;
         }
         $imported[$lib] = true;
     }
 }