Exemplo n.º 1
0
 /**
  * Preload component files to override
  *
  * We read original source file and if are enabled to extend default classes we need to change defined vars because they dont exists at this step.
  *
  * @param string $option
  * @param JRegistry $params
  */
 public static function preload($option, $params)
 {
     if (count(JoomlaOverrideHelperCodepool::addCodePath()) == 0) {
         return;
     }
     //get files that can be overrided
     $componentOverrideFiles = self::loadComponentFiles($option);
     self::registerPaths($option);
     //loading override files
     if (!empty($componentOverrideFiles)) {
         //constants to replace JPATH_COMPONENT, JPATH_COMPONENT_SITE and JPATH_COMPONENT_ADMINISTRATOR
         define('JPATH_SOURCE_COMPONENT', JPATH_BASE . '/components/' . $option);
         define('JPATH_SOURCE_COMPONENT_SITE', JPATH_SITE . '/components/' . $option);
         define('JPATH_SOURCE_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option);
         foreach ($componentOverrideFiles as $componentFile) {
             if ($filePath = JPath::find(JoomlaOverrideHelperCodepool::addCodePath(), $componentFile)) {
                 //include the original code and replace class name add a Default on
                 if ($params->get('extendDefault', 0)) {
                     if (!class_exists(JoomlaOverrideHelperOverride::getClassName(JPATH_BASE . '/components/' . $componentFile))) {
                         JoomlaOverrideHelperOverride::load(JoomlaOverrideHelperOverride::fixDefines(JoomlaOverrideHelperOverride::createDefaultClass(JPATH_BASE . '/components/' . $componentFile)));
                     }
                     require_once $filePath;
                 } else {
                     require_once $filePath;
                 }
             }
         }
     }
 }
Exemplo n.º 2
0
 /**
  * Override a core classes and just overload methods that need
  * 
  * @param string $sourcePath
  * @param string $class
  * @param string $jimport
  * @param string $replacePath
  */
 private static function overrideClass($sourcePath, $class, $jimport, $replacePath)
 {
     //override library class
     JoomlaOverrideHelperOverride::load(JoomlaOverrideHelperOverride::createDefaultClass($sourcePath, 'LIB_'));
     if (!empty($jimport)) {
         jimport($jimport);
     }
     JLoader::register($class, $replacePath, true);
 }
Exemplo n.º 3
0
        }
    }
    if (strpos($class_name, 'model') !== false) {
        $parts = split('model', $class_name);
        $file = '/components/com_' . strtolower($parts[0]) . '/models/' . strtolower(end($parts)) . '.php';
        if (is_file(JPATH_BASE . $file)) {
            if (!class_exists($original_class)) {
                JoomlaOverrideHelperOverride::load(JoomlaOverrideHelperOverride::fixDefines(JoomlaOverrideHelperOverride::createDefaultClass(JPATH_BASE . $file)));
            }
        }
    }
    if (strpos($class_name, 'view') !== false) {
        $format = JFactory::getApplication()->input->get('format', 'html');
        $parts = split('view', $class_name);
        $file = '/components/com_' . strtolower($parts[0]) . '/views/' . strtolower(end($parts)) . '/view.' . $format . '.php';
        if (is_file(JPATH_BASE . $file)) {
            if (!class_exists($original_class)) {
                JoomlaOverrideHelperOverride::load(JoomlaOverrideHelperOverride::fixDefines(JoomlaOverrideHelperOverride::createDefaultClass(JPATH_BASE . $file)));
            }
        }
    }
    if (strpos($class_name, 'table') !== false) {
        $parts = split('table', $class_name);
        $file = '/components/com_' . strtolower($parts[0]) . '/tables/' . strtolower(end($parts)) . '.php';
        if (is_file(JPATH_BASE . $file)) {
            if (!class_exists($original_class)) {
                JoomlaOverrideHelperOverride::load(JoomlaOverrideHelperOverride::fixDefines(JoomlaOverrideHelperOverride::createDefaultClass(JPATH_BASE . $file)));
            }
        }
    }
});