Пример #1
0
 /**
  * Get the singleton instance
  * @return  Loader
  */
 private static function instance()
 {
     if (self::$instance == null) {
         self::$instance = new self();
     }
     return self::$instance;
 }
Пример #2
0
 /**
  * Method to setup the autoloaders for the Joomla Platform.
  *
  * @param   int     $changePrivate  Flag for change values and functions to protected instead private in extends files
  * @param   string  $prefix         Prefix for extend files
  * @param   string  $suffix         Suffix for extend files
  *
  * @return  void
  */
 public static function setupOverrideLoader($changePrivate = 0, $prefix = '', $suffix = 'Default')
 {
     self::$changePrivate = $changePrivate;
     self::$prefix = $prefix;
     self::$suffix = $suffix;
     // Register the prefix autoloader.
     spl_autoload_register(array('MVCLoader', 'registerOverrideAutoLoader'), false, true);
 }
Пример #3
0
 /**
  * Override a core classes and just overload methods that need
  *
  * @param   string  $sourcePath   Source Path
  * @param   string  $class        Class
  * @param   string  $jimport      JImport path
  * @param   string  $replacePath  Replace Path
  *
  * @return void
  */
 private static function overrideClass($sourcePath, $class, $jimport, $replacePath)
 {
     // Override library class
     if (!file_exists($sourcePath)) {
         return;
     }
     MVCLoader::setOverrideFile($class, $sourcePath, true, 'LIB_', 'Default');
     if (!empty($jimport)) {
         jimport($jimport);
     }
     MVCLoader::setOverrideFile($class, $replacePath);
 }
Пример #4
0
 /**
  * Get file info
  *
  * @param   string  $includePath  Path for check inner files
  * @param   string  $component    Component name folder
  * @param   string  $filePath     Checking file path
  * @param   string  $type         Type file
  * @param   string  $indexName    Name usage for helper index
  *
  * @return stdClass
  */
 private function getOverrideFileInfo($includePath, $component, $filePath, $type = '', $indexName = '')
 {
     $filePath = JPath::clean($filePath);
     $sameFolderPrefix = $component . '/' . $type;
     if ($type == 'helpers') {
         $app = JFactory::getApplication();
         $baseName = basename($filePath);
         $prefix = substr($baseName, 0, 5);
         if ($app->isAdmin() && $prefix == 'admin' || !$app->isAdmin() && $prefix != 'admin' || !(!$app->isAdmin() && $prefix == 'admin')) {
             $realPath = JPATH_SITE . '/components' . substr($filePath, strlen($includePath));
         } else {
             $realPath = JPATH_ADMINISTRATOR . '/components/' . $sameFolderPrefix . '/' . substr($baseName, 5);
         }
     } else {
         $realPath = JPATH_BASE . '/components/' . substr($filePath, strlen($includePath));
     }
     $realPath = JPath::clean($realPath);
     if (!JFile::exists($realPath)) {
         return;
     }
     $forOverrideFile = file_get_contents($realPath);
     $originalClass = MVCOverrideHelperOverride::getOriginalClass($forOverrideFile);
     unset($forOverrideFile);
     if ($type == 'helpers') {
         JLoader::register($indexName, $filePath);
     } else {
         // Set path for new file
         MVCLoader::setOverrideFile($originalClass, $filePath);
     }
     // Set path for override file
     MVCLoader::setOverrideFile($originalClass, $realPath, true, $this->params->get('extendPrefix', ''), $this->params->get('extendSuffix', 'Default'));
 }