Exemple #1
0
 /**
  * Register ezote/Autoloader::autoload as autoloader
  */
 public static function register($extensionDir = false)
 {
     if (!static::$registered) {
         static::$extensionDir = $extensionDir ?: \eZExtension::baseDirectory();
         static::$registered = spl_autoload_register(array(new self(), 'autoload'));
     }
 }
 static function loadHandler($directories, $handlerString)
 {
     $foundHandler = false;
     $includeFile = '';
     $baseDirectory = eZExtension::baseDirectory();
     $notificationINI = eZINI::instance('notification.ini');
     $repositoryDirectories = $notificationINI->variable('NotificationEventHandlerSettings', 'RepositoryDirectories');
     $extensionDirectories = $notificationINI->variable('NotificationEventHandlerSettings', 'ExtensionDirectories');
     foreach ($extensionDirectories as $extensionDirectory) {
         $extensionPath = "{$baseDirectory}/{$extensionDirectory}/notification/handler/";
         if (file_exists($extensionPath)) {
             $repositoryDirectories[] = $extensionPath;
         }
     }
     foreach ($repositoryDirectories as $repositoryDirectory) {
         $repositoryDirectory = trim($repositoryDirectory, '/');
         $includeFile = "{$repositoryDirectory}/{$handlerString}/{$handlerString}handler.php";
         if (file_exists($includeFile)) {
             $foundHandler = true;
             break;
         }
     }
     if (!$foundHandler) {
         eZDebug::writeError("Notification handler does not exist: {$handlerString}", __METHOD__);
         return false;
     }
     include_once $includeFile;
     $className = $handlerString . "handler";
     return new $className();
 }
    function initialize()
    {
        $ini = eZINI::instance( 'xmlinstaller.ini' );
        $extensionDirectoryList = array_unique( $ini->variable( 'XMLInstallerSettings', 'ExtensionDirectories' ) );
        $handlerList = array_unique( $ini->variable( 'XMLInstallerSettings', 'XMLInstallerHandler' ) );

        foreach( $extensionDirectoryList as $extensionDirectory )
        {
            $handler = reset( $handlerList );
            do
            {
                $fileName = eZExtension::baseDirectory() . '/' . $extensionDirectory . '/xmlinstallerhandler/' . $handler . '.php';
                if ( file_exists( $fileName ) )
                {
                    include_once( $fileName );
                    $className = $handler;
                    $info = call_user_func(array($className, 'handlerInfo'));
                    if ( array_key_exists( 'XMLName', $info ) && array_key_exists( 'Info', $info ) )
                    {
                        $this->HandlerList[$info['XMLName']] = array( 'Info' => $info['Info'],
                                                                      'File' => $fileName,
                                                                      'Class' => $className );
                    }
                    unset($handlerList[key($handlerList)]);
                    $handler = current( $handlerList );
                }
                else
                {
                    $handler = next( $handlerList );
                }
            } while ( $handler );
        }
    }
    static function create( $handlerName = false )
    {
        $shopINI = eZINI::instance( 'shop.ini' );
        if ( $handlerName === false)
        {
           if ( $shopINI->hasVariable( 'ExchangeRatesSettings', 'ExchangeRatesUpdateHandler' ) )
               $handlerName = $shopINI->variable( 'ExchangeRatesSettings', 'ExchangeRatesUpdateHandler' );
        }

        $handlerName = strtolower( $handlerName );

        $dirList = array();
        $repositoryDirectories = $shopINI->variable( 'ExchangeRatesSettings', 'RepositoryDirectories' );
        $extensionDirectories = $shopINI->variable( 'ExchangeRatesSettings', 'ExtensionDirectories' );

        $baseDirectory = eZExtension::baseDirectory();
        foreach ( $extensionDirectories as $extensionDirectory )
        {
            if ( !empty( $extensionDirectory ) )
                $dirList[] = $baseDirectory . '/' . $extensionDirectory . '/exchangeratehandlers';
        }

        foreach ( $repositoryDirectories as $repositoryDirectory )
        {
            if ( !empty( $repositoryDirectory ) )
                $dirList[] = $repositoryDirectory;
        }

        $foundHandler = false;
        foreach ( $dirList as $dir )
        {
            $includeFile = "$dir/$handlerName/{$handlerName}handler.php";

            if ( file_exists( $includeFile ) )
            {
                $foundHandler = true;
                break;
            }
        }

        if ( !$foundHandler )
        {
            eZDebug::writeError( "Exchange rates update handler '$handlerName' not found, " .
                                   "searched in these directories: " .
                                   implode( ', ', $dirList ),
                                 'eZExchangeRatesUpdateHandler::create' );
            return false;
        }

        require_once( $includeFile );
        $className = $handlerName . 'handler';
        return new $className;
    }
Exemple #5
0
 function sPdf2png()
 {
     $ini = eZINI::instance('spdf2png.ini');
     $this->cacheEnabled = $ini->variable('CacheSettings', 'Cache') == 'enabled';
     $this->debugEnabled = $ini->variable('DebugSettings', 'DebugPDF') == 'enabled';
     $this->javaExec = $ini->variable('BinarySettings', 'JavaExecutable');
     $this->cacheTTL = $ini->variable('CacheSettings', 'TTL');
     $fileSep = eZSys::fileSeparator();
     $this->fileSep = $fileSep;
     $this->extensionDir = eZSys::rootDir() . $fileSep . eZExtension::baseDirectory() . $fileSep . 'pdf2png';
     //$this->paradoxPDFExec = $this->pdf2pngExtensionDir.$fileSep.'bin'.$fileSep.'paradoxpdf.jar';
     $this->tmpDir = eZSys::rootDir() . $fileSep . 'var' . $fileSep . 'cache' . $fileSep . 'public' . $fileSep . 'pdf2png';
 }
Exemple #6
0
 /**
  * Loads an extension by adding it to ActiveExtensions setting,
  * clearing extensions cache and add ini dir (not extension siteaccess)
  *
  * Note: Does not check if extension exist on files system!
  *
  * @param string $extension Extension name to load
  * @return bool True on success, false if already loaded
  */
 public static function load($extension)
 {
     $ini = eZINI::instance();
     $activeExtensions = $ini->variable('ExtensionSettings', 'ActiveExtensions');
     if (in_array($extension, $activeExtensions, true)) {
         return false;
     }
     $activeExtensions[] = $extension;
     $ini->setVariable('ExtensionSettings', 'ActiveExtensions', $activeExtensions);
     $extensionDirectory = eZExtension::baseDirectory();
     $ini->prependOverrideDir($extensionDirectory . '/' . $extension . '/settings', true, 'extension:' . $extension, 'extension');
     eZExtension::clearActiveExtensionsMemoryCache();
     return true;
 }
 static function executeHandlerFunction($functionName, $params)
 {
     $result = array();
     $contentINI = eZINI::instance('content.ini');
     foreach (array_unique($contentINI->variable('EditSettings', 'ExtensionDirectories')) as $extensionDirectory) {
         $fileName = eZExtension::baseDirectory() . '/' . $extensionDirectory . '/content/' . $extensionDirectory . 'handler.php';
         if (file_exists($fileName)) {
             include_once $fileName;
             $className = $extensionDirectory . 'Handler';
             $inputHandler = new $className();
             $functionResult = call_user_func_array(array($inputHandler, $functionName), $params);
             $result[] = array('handler' => $className, 'function' => array('name' => $functionName, 'value' => $functionResult));
         }
     }
     return $result;
 }
 /**
  * @deprecated 4.3 No longer used as we rely on ezpExtension & autoloads
  * @return array list of directories used to search cluster file handlers for
  */
 static function searchPathArray()
 {
     if (!isset($GLOBALS['eZClusterFileHandler_search_path_array'])) {
         $fileINI = eZINI::instance('file.ini');
         $searchPathArray = array('kernel/classes/clusterfilehandlers', 'kernel/private/classes/clusterfilehandlers');
         if ($fileINI->hasVariable('ClusteringSettings', 'ExtensionDirectories')) {
             $extensionDirectories = $fileINI->variable('ClusteringSettings', 'ExtensionDirectories');
             $baseDirectory = eZExtension::baseDirectory();
             foreach ($extensionDirectories as $extensionDirectory) {
                 $customSearchPath = $baseDirectory . '/' . $extensionDirectory . '/clusterfilehandlers';
                 if (file_exists($customSearchPath)) {
                     $searchPathArray[] = $customSearchPath;
                 }
             }
         }
         $GLOBALS['eZClusterFileHandler_search_path_array'] = $searchPathArray;
     }
     return $GLOBALS['eZClusterFileHandler_search_path_array'];
 }
Exemple #9
0
 protected static function initialize($force = false)
 {
     if (self::$initialized && !$force) {
         return;
     }
     self::$originaltpls = array();
     $knowndirs = array('design');
     foreach ($knowndirs as $phpdir) {
         self::$originaltpls = array_merge(self::$originaltpls, self::scanDirFortpls($phpdir, true));
     }
     self::$extensiontpls = array();
     $extensionsdir = eZExtension::baseDirectory();
     $ini = eZINI::instance('design.ini');
     /// @todo take this from an ini too, to allow user to add more known php files dirs
     foreach ($ini->variable('ExtensionSettings', 'DesignExtensions') as $extdir) {
         self::$extensiontpls = array_merge(self::$extensiontpls, self::scanDirFortpls("{$extensionsdir}/{$extdir}/design", true));
     }
     self::$tpl = sysInfoTools::eZTemplateFactory();
     self::$initialized = true;
 }
 /**
  * Returns path to site access
  *
  * @param string $siteAccess
  * @return string|false Return path to siteacces or false if invalid
  */
 static function findPathToSiteAccess($siteAccess)
 {
     $ini = eZINI::instance();
     $siteAccessList = $ini->variable('SiteAccessSettings', 'AvailableSiteAccessList');
     if (!in_array($siteAccess, $siteAccessList)) {
         return false;
     }
     $currentPath = 'settings/siteaccess/' . $siteAccess;
     if (file_exists($currentPath)) {
         return $currentPath;
     }
     $activeExtensions = eZExtension::activeExtensions();
     $baseDir = eZExtension::baseDirectory();
     foreach ($activeExtensions as $extension) {
         $currentPath = $baseDir . '/' . $extension . '/settings/siteaccess/' . $siteAccess;
         if (file_exists($currentPath)) {
             return $currentPath;
         }
     }
     return 'settings/siteaccess/' . $siteAccess;
 }
Exemple #11
0
 protected static function initialize($force = false)
 {
     if (self::$initialized && !$force) {
         return;
     }
     self::$originalphps = array();
     $knowndirs = array('autoload', 'bin', 'cronjobs', 'kernel', 'lib', 'update');
     foreach ($knowndirs as $phpdir) {
         self::$originalphps = array_merge(self::$originalphps, self::scanDirForphps($phpdir, true));
     }
     self::$extensionphps = array();
     $extensionsdir = eZExtension::baseDirectory();
     $ini = eZINI::instance('site.ini');
     /// @todo take this from an ini too, to allow user to add more known php files dirs
     foreach ($ini->variable('ExtensionSettings', 'ActiveExtensions') as $extdir) {
         self::$extensionphps = array_merge(self::$extensionphps, self::scanDirForphps("{$extensionsdir}/{$extdir}", true));
     }
     $php = 'php';
     exec($php . ' -v', $output);
     if (count($output) && strpos($output[0], 'PHP') !== false) {
         self::$php = $php;
     }
     self::$initialized = true;
 }
if ($dataTypeName === null) {
    $cli->output("Error: The option --datatype is required. Add --help for more information.");
}
$allowedDatatypes = eZDataType::allowedTypes();
if ($dataTypeName !== null and in_array($dataTypeName, $allowedDatatypes)) {
    // Inserting data from the dba-data files of the datatypes
    eZDataType::loadAndRegisterAllTypes();
    $registeredDataTypes = eZDataType::registeredDataTypes();
    if (isset($registeredDataTypes[$dataTypeName])) {
        $dataType = $registeredDataTypes[$dataTypeName];
        if ($dataType->importDBDataFromDBAFile()) {
            $cli->output("The database is updated for the datatype: " . $cli->style('emphasize') . $dataType->DataTypeString . $cli->style('emphasize-end') . "\n" . 'dba-data is imported from the file: ' . $cli->style('emphasize') . $dataType->getDBAFilePath() . $cli->style('emphasize-end'));
        } else {
            $activeExtensions = eZExtension::activeExtensions();
            $errorString = "Failed importing datatype related data into database: \n" . '  datatype - ' . $dataType->DataTypeString . ", \n" . '  checked dba-data file - ' . $dataType->getDBAFilePath(false);
            foreach ($activeExtensions as $activeExtension) {
                $fileName = eZExtension::baseDirectory() . '/' . $activeExtension . '/datatypes/' . $dataType->DataTypeString . '/' . $dataType->getDBAFileName();
                $errorString .= "\n" . str_repeat(' ', 23) . ' - ' . $fileName;
                if (file_exists($fileName)) {
                    $errorString .= " (found, but not successfully imported)";
                }
            }
            $cli->error($errorString);
        }
    } else {
        $cli->error("Error: The datatype " . $dataTypeName . " does not exist.");
    }
} else {
    $cli->error("Error: The datatype " . $dataTypeName . " is not registered.");
}
$script->shutdown();
 /**
  * Creates a filter array from extended attribute filters
  *
  * The filter array includes tables, joins, columns and grouping information
  *
  * @param array $extendedAttributeFilter
  * @return array
  */
 static function createExtendedAttributeFilterSQLStrings(&$extendedAttributeFilter)
 {
     $filter = array('tables' => '', 'joins' => '', 'columns' => '', 'group_by' => '');
     if ($extendedAttributeFilter and count($extendedAttributeFilter) > 1) {
         $extendedAttributeFilterID = $extendedAttributeFilter['id'];
         $extendedAttributeFilterParams = $extendedAttributeFilter['params'];
         $filterINI = eZINI::instance('extendedattributefilter.ini');
         if (!$filterINI->hasGroup($extendedAttributeFilterID)) {
             eZDebug::writeError("Unable to find configuration for the extended attribute filter '{$extendedAttributeFilterID}', the filter will be ignored", __METHOD__);
             return $filter;
         }
         $filterClassName = $filterINI->variable($extendedAttributeFilterID, 'ClassName');
         $filterMethodName = $filterINI->variable($extendedAttributeFilterID, 'MethodName');
         if ($filterINI->hasVariable($extendedAttributeFilterID, 'FileName')) {
             $filterFile = $filterINI->variable($extendedAttributeFilterID, 'FileName');
             if ($filterINI->hasVariable($extendedAttributeFilterID, 'ExtensionName')) {
                 $extensionName = $filterINI->variable($extendedAttributeFilterID, 'ExtensionName');
                 include_once eZExtension::baseDirectory() . "/{$extensionName}/{$filterFile}";
             } else {
                 include_once $filterFile;
             }
         }
         if (!class_exists($filterClassName, true)) {
             eZDebug::writeError("Unable to find the PHP class '{$filterClassName}' associated with the extended attribute filter '{$extendedAttributeFilterID}', the filter will be ignored", __METHOD__);
             return $filter;
         }
         $classObject = new $filterClassName();
         $parameterArray = array($extendedAttributeFilterParams);
         $sqlResult = call_user_func_array(array($classObject, $filterMethodName), $parameterArray);
         $filter['tables'] = $sqlResult['tables'];
         $filter['joins'] = $sqlResult['joins'];
         $filter['columns'] = isset($sqlResult['columns']) ? $sqlResult['columns'] : '';
         if (isset($sqlResult['group_by'])) {
             $filter['group_by'] = $sqlResult['group_by'];
         }
     }
     return $filter;
 }
 function fetchNewsletterTypeList()
 {
     $extension = 'eznewsletter';
     $base = eZExtension::baseDirectory();
     $baseDir = "{$base}/{$extension}/classes/";
     return array('result' => eZNewsletterType::fetchList());
 }
 /**
  * Find the location on design bases on the disk
  *
  * @param $ini an eZINI object
  * @param $siteAccess Wether to use siteaccesses or not
  * @return array The list of design bases
  */
 private static function findDesignBase(eZINI $ini, $siteAccess = false)
 {
     if ($siteAccess) {
         $ini = eZSiteAccess::getIni($siteAccess, 'site.ini');
         $standardDesign = $ini->variable('DesignSettings', 'StandardDesign');
         $siteDesign = $ini->variable('DesignSettings', 'SiteDesign');
     } else {
         $ini = eZINI::instance();
         $standardDesign = eZTemplateDesignResource::designSetting('standard');
         $siteDesign = eZTemplateDesignResource::designSetting('site');
     }
     $siteDesignList = $ini->variable('DesignSettings', 'AdditionalSiteDesignList');
     array_unshift($siteDesignList, $siteDesign);
     $siteDesignList[] = $standardDesign;
     $siteDesignList = array_unique($siteDesignList);
     $designBaseList = array();
     $extensionDirectory = eZExtension::baseDirectory();
     $designStartPath = eZTemplateDesignResource::designStartPath();
     $extensions = eZTemplateDesignResource::designExtensions();
     foreach ($siteDesignList as $design) {
         foreach ($extensions as $extension) {
             $path = "{$extensionDirectory}/{$extension}/{$designStartPath}/{$design}";
             if (file_exists($path)) {
                 $designBaseList[] = $path;
             }
         }
         $path = "{$designStartPath}/{$design}";
         if (file_exists($path)) {
             $designBaseList[] = $path;
         }
     }
     return $designBaseList;
 }
Exemple #16
0
             }
             $result = $customActionModule->run($customActionViewName, array());
             if (isset($result['content']) && $result['content']) {
                 return $result;
             } else {
                 $module->setExitStatus($customActionModule->exitStatus());
                 $module->setRedirectURI($customActionModule->redirectURI());
                 return $result;
             }
         } else {
             return $module->run($customActionUrl);
         }
     }
 }
 // look for custom content action handlers
 $baseDirectory = eZExtension::baseDirectory();
 $contentINI = eZINI::instance('content.ini');
 $extensionDirectories = $contentINI->variable('ActionSettings', 'ExtensionDirectories');
 foreach ($extensionDirectories as $extensionDirectory) {
     $extensionPath = $baseDirectory . '/' . $extensionDirectory . '/actions/content_actionhandler.php';
     if (file_exists($extensionPath)) {
         include_once $extensionPath;
         $actionFunction = $extensionDirectory . '_ContentActionHandler';
         if (function_exists($actionFunction)) {
             $actionResult = $actionFunction($module, $http, $objectID);
             if ($actionResult) {
                 return $actionResult;
             }
         }
     }
 }
Exemple #17
0
    /**
     * Returns the extension informations
     * Uses extension.xml by default, then tries ezinfo.php for backwards compatibility
     *
     * @since 4.4
     * @return array|null array of extension informations, or null if no source exists
     */
    public function getInfo()
    {
        // try extension.xml first
        if ( is_readable( $XMLFilePath = eZExtension::baseDirectory() . "/{$this->name}/extension.xml" ) )
        {
            $infoFields = array( 'name', 'description', 'version', 'copyright', 'author', 'license', 'info_url' );

            libxml_use_internal_errors( true );
            $xml = simplexml_load_file( $XMLFilePath );
            // xml parsing error
            if ( $xml === false )
            {
                eZDebug::writeError( libxml_get_errors(), "ezpExtension({$this->name})::getInfo()" );
                return null;
            }
            $return = array();
            $metadataNode = $xml->metadata;

            // standard extension metadata
            foreach ( $infoFields as $field )
            {
                if ( (string)$metadataNode->$field !== '' )
                    $return[$field] = (string)$metadataNode->$field;
            }

            // 3rd party software
            if ( !$metadataNode->software->uses )
                return $return;

            $index = 1;
            foreach ( $metadataNode->software->uses as $software )
            {
                $label = "Includes the following third-party software";
                if ( $index > 1 )
                    $label .= " (" . $index . ")";

                foreach ( $infoFields as $field )
                {
                    if ( (string)$software->$field !== '' )
                        $return[$label][$field] = (string)$software->$field;
                }
                $index++;
            }

            return $return;
        }
        // then try ezinfo.php, for backwards compatibility
        elseif ( is_readable( $infoFilePath = eZExtension::baseDirectory() . "/{$this->name}/ezinfo.php" ) )
        {
            include_once( $infoFilePath );
            $className = $this->name . 'Info';
            if ( is_callable( array( $className, 'info' ) ) )
            {
                $result = call_user_func_array( array( $className, 'info' ), array() );
                if ( is_array( $result ) )
                {
                    return $result;
                }
            }
        }
        else
        {
            return null;
        }
    }
/**
 * Activates the file named \a $name in extension \a $extension
 * note This works similar to include_once() meaning that it's included one time.
 *
 * @deprecated Since 4.3
 */
function ext_class($extension, $name)
{
    $name = strtolower($name);
    $base = eZExtension::baseDirectory();
    $include = "{$base}/{$extension}/classes/{$name}.php";
    return include_once $include;
}
Exemple #19
0
 static function loadBasketInfoHandler()
 {
     $shopINI = eZINI::instance('shop.ini');
     if (!$shopINI->hasVariable('BasketInfoSettings', 'Handler')) {
         return true;
     }
     $handlerName = $shopINI->variable('BasketInfoSettings', 'Handler');
     $repositoryDirectories = $shopINI->variable('BasketInfoSettings', 'RepositoryDirectories');
     $extensionDirectories = $shopINI->variable('BasketInfoSettings', 'ExtensionDirectories');
     $baseDirectory = eZExtension::baseDirectory();
     foreach ($extensionDirectories as $extensionDirectory) {
         $extensionPath = $baseDirectory . '/' . $extensionDirectory . '/basketinfohandlers';
         if (file_exists($extensionPath)) {
             $repositoryDirectories[] = $extensionPath;
         }
     }
     $foundHandler = false;
     foreach ($repositoryDirectories as $repositoryDirectory) {
         $includeFile = "{$repositoryDirectory}/{$handlerName}basketinfohandler.php";
         if (file_exists($includeFile)) {
             $foundHandler = true;
             break;
         }
     }
     if (!$foundHandler) {
         eZDebug::writeError("Basketinfo handler '{$handlerName}' not found, " . "searched in these directories: " . implode(', ', $repositoryDirectories), 'eZShippingManager::loadBasketInfoHandler');
         return false;
     }
     require_once $includeFile;
     $className = $handlerName . 'BasketInfoHandler';
     if (!class_exists($className)) {
         eZDebug::writeError("Cannot instantiate non-existent class: '{$className}'", __METHOD__);
         return null;
     }
     return new $className();
 }
 /**
  * Returns the list of active module repositories, as defined in module.ini
  *
  * @param boolean $useExtensions
  *        If true, module.ini files in extensions will be scanned as well.
  *        If false, only the module.ini overrides in settings will be.
  *
  * @return array a path list of currently active modules
  */
 static function activeModuleRepositories($useExtensions = true)
 {
     $moduleINI = eZINI::instance('module.ini');
     $moduleRepositories = $moduleINI->variable('ModuleSettings', 'ModuleRepositories');
     if ($useExtensions) {
         $extensionRepositories = $moduleINI->variable('ModuleSettings', 'ExtensionRepositories');
         $extensionDirectory = eZExtension::baseDirectory();
         $activeExtensions = eZExtension::activeExtensions();
         $globalExtensionRepositories = array();
         foreach ($extensionRepositories as $extensionRepository) {
             $extPath = $extensionDirectory . '/' . $extensionRepository;
             $modulePath = $extPath . '/modules';
             if (!in_array($extensionRepository, $activeExtensions)) {
                 eZDebug::writeWarning("Extension '{$extensionRepository}' was reported to have modules but has not yet been activated.\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions\n" . "or make sure it is activated in the setting ExtensionSettings/ActiveExtensions in site.ini.");
             } else {
                 if (file_exists($modulePath)) {
                     $globalExtensionRepositories[] = $modulePath;
                 } else {
                     if (!file_exists($extPath)) {
                         eZDebug::writeWarning("Extension '{$extensionRepository}' was reported to have modules but the extension itself does not exist.\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extensions.\n" . "You should probably remove this extension from the list.");
                     } else {
                         eZDebug::writeWarning("Extension '{$extensionRepository}' does not have the subdirectory 'modules' allthough it reported it had modules.\n" . "Looked for directory '" . $modulePath . "'\n" . "Check the setting ModuleSettings/ExtensionRepositories in module.ini for your extension.");
                     }
                 }
             }
         }
         $moduleRepositories = array_merge($moduleRepositories, $globalExtensionRepositories);
     }
     return $moduleRepositories;
 }
Exemple #21
0
 static function nameFromPath( $path )
 {
     $path = eZDir::cleanPath( $path );
     $base = eZExtension::baseDirectory() . '/';
     $base = preg_quote( $base, '/' );
     $pattern = '/'.$base.'([^\/]+)/';
     if ( preg_match( $pattern, $path, $matches ) )
         return $matches[1];
     else
         false;
 }
 static function fieldMap($version = '2.0')
 {
     $fieldDefinition = eZRSSImport::rssFieldDefinition();
     $ini = eZINI::instance();
     foreach ($ini->variable('RSSSettings', 'ActiveExtensions') as $activeExtension) {
         if (file_exists(eZExtension::baseDirectory() . '/' . $activeExtension . '/rss/' . $activeExtension . 'rssimport.php')) {
             include_once eZExtension::baseDirectory() . '/' . $activeExtension . '/rss/' . $activeExtension . 'rssimport.php';
             $fieldDefinition = eZRSSImport::arrayMergeRecursive($fieldDefinition, call_user_func(array($activeExtension . 'rssimport', 'rssFieldDefinition'), array()));
         }
     }
     $returnArray = array();
     eZRSSImport::recursiveFieldMap($fieldDefinition, '', '', $returnArray, 0);
     return $returnArray;
 }
    /**
     * Prepends the extension path to $path if not already in $path
     *
     * @param string $path
     */
    protected function normalizeExtensionPath( $path )
    {
        if ( strpos( $path, eZExtension::baseDirectory() ) === false )
            $path = eZDir::path( array( eZExtension::baseDirectory(), $path ) );

        return $path;
    }
 static function handlerRepositories()
 {
     $extensions = eZCollaborationItemHandler::extensionRepositories();
     $repositories = eZCollaborationItemHandler::defaultRepositories();
     $extensionRoot = eZExtension::baseDirectory();
     foreach ($extensions as $extension) {
         $handlerPath = eZDir::path(array($extensionRoot, $extension, 'collaboration'));
         if (file_exists($handlerPath)) {
             $repositories[] = $handlerPath;
         }
     }
     return $repositories;
 }
 function fileExists(&$file, &$type, &$role, &$roleValue, &$design, &$triedFiles)
 {
     $triedFiles = array();
     switch ($type) {
         case 'file':
             if (file_exists($file)) {
                 return $file;
             }
             $triedFiles[] = $file;
             break;
         case 'dir':
             if (file_exists($file) and is_dir($file)) {
                 return $file;
             }
             $triedFiles[] = $file;
             break;
         case 'ini':
             $filePath = $file;
             if (file_exists($filePath)) {
                 $filePath = $this->iniMatch($filePath, $role, $roleValue, $file, $triedFiles);
                 if ($filePath) {
                     return $filePath;
                 }
             }
             break;
         case 'thumbnail':
             if (file_exists($file)) {
                 $filePath = $file;
                 //                     if ( preg_match( "#^(.+)/([^/]+)$#", $file, $matches ) )
                 //                     {
                 //                         $file = $matches[2];
                 //                     }
                 if (preg_match("#^(.+)\\.([^.]+)\$#", $file, $matches)) {
                     $file = 'thumbnail.' . $matches[2];
                 }
                 return $filePath;
             }
             $triedFiles[] = $file;
             break;
         case 'design':
             $roleFileName = false;
             switch ($role) {
                 case 'template':
                     $roleFileName = 'templates';
                     break;
                 case 'image':
                     $roleFileName = 'images';
                     break;
                 case 'stylesheet':
                     $roleFileName = 'stylesheets';
                     break;
                 case 'font':
                     $roleFileName = 'fonts';
                     break;
             }
             $designDirectories = array('design');
             $extensionBaseDirectory = eZExtension::baseDirectory();
             $ini = eZINI::instance('design.ini');
             $extensionDesigns = $ini->variable('ExtensionSettings', 'DesignExtensions');
             foreach ($extensionDesigns as $extensionDesign) {
                 $designDirectories[] = $extensionBaseDirectory . '/' . $extensionDesign . '/design';
             }
             if (file_exists($file)) {
                 $preg = '#^';
                 $i = 0;
                 foreach ($designDirectories as $designDirectory) {
                     if ($i > 0) {
                         $preg .= '|';
                     }
                     $preg .= '(?:' . $designDirectory . ')';
                     ++$i;
                 }
                 $preg .= '/([^/]+)/(.+)$#';
                 $realFile = $file;
                 if (preg_match($preg, $file, $matches)) {
                     $design = $matches[1];
                     if (preg_match('#^(template(?:s)|image(?:s)|stylesheet(?:s)|font(?:s))/(.+)$#', $matches[2], $matches)) {
                         $role = $matches[1];
                         $file = $matches[2];
                     } else {
                         $file = $matches[2];
                         $role = false;
                     }
                 } else {
                     $type = 'file';
                     $role = false;
                     $design = false;
                 }
                 return $realFile;
             }
             $triedFiles[] = $file;
             if (!$design) {
                 foreach ($designDirectories as $designDirectory) {
                     $filePath = $designDirectory . '/standard/' . $roleFileName . '/' . $file;
                     if (file_exists($filePath)) {
                         $design = 'standard';
                         return $filePath;
                     }
                     $triedFiles[] = $filePath;
                     if (!file_exists($designDirectory) or !is_dir($designDirectory)) {
                         continue;
                     }
                     $dirHandler = @opendir($designDirectory);
                     if (!$dirHandler) {
                         continue;
                     }
                     while (($designSubDirectory = @readdir($dirHandler)) !== false) {
                         if ($designSubDirectory == '.' or $designSubDirectory == '..') {
                             continue;
                         }
                         $filePath = $designDirectory . '/' . $designSubDirectory . '/' . $roleFileName . '/' . $file;
                         if (file_exists($filePath)) {
                             @closedir($dirHandler);
                             $design = $designSubDirectory;
                             return $filePath;
                         }
                         $triedFiles[] = $filePath;
                     }
                     @closedir($dirHandler);
                 }
             }
             foreach ($designDirectories as $designDirectory) {
                 if (!file_exists($designDirectory) or !is_dir($designDirectory)) {
                     continue;
                 }
                 $filePath = $designDirectory . '/' . $file;
                 if (file_exists($filePath)) {
                     if (preg_match("#^([^/]+)/(.+)\$#", $file, $matches)) {
                         $design = $matches[1];
                         $file = $matches[2];
                     } else {
                         $design = $file;
                         $file = false;
                     }
                     return $filePath;
                 }
                 $filePath = $designDirectory . '/' . $design . '/' . $roleFileName . '/' . $file;
                 if (file_exists($filePath)) {
                     return $filePath;
                 }
                 $triedFiles[] = $filePath;
             }
             break;
     }
     return false;
 }
    static function loadAndRegisterType( $type )
    {
        $types = $GLOBALS["eZNotificationEventTypes"];
        if ( isset( $types[$type] ) )
        {
            eZDebug::writeError( "Notification event type already registered: $type", __METHOD__ );
            return false;
        }

        $baseDirectory = eZExtension::baseDirectory();
        $notificationINI = eZINI::instance( 'notification.ini' );
        $repositoryDirectories = $notificationINI->variable( 'NotificationEventTypeSettings', 'RepositoryDirectories' );
        $extensionDirectories = $notificationINI->variable( 'NotificationEventTypeSettings', 'ExtensionDirectories' );
        foreach ( $extensionDirectories as $extensionDirectory )
        {
            $extensionPath = $baseDirectory . '/' . $extensionDirectory . '/notificationtypes';
            if ( file_exists( $extensionPath ) )
                $repositoryDirectories[] = $extensionPath;
        }
        $foundEventType = false;
        foreach ( $repositoryDirectories as $repositoryDirectory )
        {
            $includeFile = "$repositoryDirectory/$type/" . $type . "type.php";
            if ( file_exists( $includeFile ) )
            {
                $foundEventType = true;
                break;
            }
        }
        if ( !$foundEventType )
        {
            eZDebug::writeError( "Notification event type not found: $type, searched in these directories: " . implode( ', ', $repositoryDirectories ), __METHOD__ );
            return false;
        }
        include_once( $includeFile );
        return true;
    }
function checkSiteaccess($siteAccess, $bailOutOnError = false)
{
    $extensionBaseDir = eZExtension::baseDirectory();
    $extensionNameArray = eZExtension::activeExtensions();
    $siteAccessSettingsDir = '/settings/siteaccess/';
    $siteAccessExists = false;
    if (file_exists('settings/siteaccess/' . $siteAccess)) {
        $siteAccessExists = true;
    } else {
        // Not found, check if it exists in extensions
        foreach ($extensionNameArray as $extensionName) {
            $extensionSiteaccessPath = $extensionBaseDir . '/' . $extensionName . $siteAccessSettingsDir . $siteAccess;
            if (file_exists($extensionSiteaccessPath)) {
                $siteAccessExists = true;
                break;
            }
        }
    }
    if (!$siteAccessExists && $bailOutOnError) {
        showError("Siteaccess '" . $siteAccess . "' does not exist. Exiting...");
    }
    return $siteAccessExists;
}
    function handleAddParameters( $packageType, $package, $cli, $arguments )
    {
        $arguments = array_unique( $arguments );
        $extensionsToAdd = array();

        $extensionList = eZDir::findSubItems( eZExtension::baseDirectory(), 'dl' );

        foreach ( $arguments as $argument )
        {
            if ( in_array( $argument, $extensionList ) )
            {
                $extensionsToAdd[] = $argument;
            }
            else
            {
                $cli->error( 'Extension ' . $cli->style( 'dir' ) . $argument .  $cli->style( 'dir-end' ) . ' not found.' );
                return false;
            }
        }

        return $extensionsToAdd;
    }
 function getDBAExtensionFilePath()
 {
     $activeExtensions = eZExtension::activeExtensions();
     $dataTypeString = $this->DataTypeString;
     $dbaFileName = $this->getDBAFileName();
     $fileName = false;
     foreach ($activeExtensions as $activeExtension) {
         $extesionFileName = eZExtension::baseDirectory() . '/' . $activeExtension . '/datatypes/' . $dataTypeString . '/' . $dbaFileName;
         if (file_exists($extesionFileName)) {
             $fileName = $extesionFileName;
             break;
         }
     }
     return $fileName;
 }
Exemple #30
0
 function importPackage()
 {
     $surveyINI = eZINI::instance('ezsurvey.ini');
     $packageName = $surveyINI->variable('PackageSettings', 'PackageName');
     $packagePath = $surveyINI->variable('PackageSettings', 'PackagePath');
     $fileName = $surveyINI->variable('PackageSettings', 'PackageFileName');
     $path = eZExtension::baseDirectory() . '/' . $packagePath . '/';
     $file = $path . $fileName;
     if (file_exists($file)) {
         $package = eZPackage::import($file, $packageName);
         if (is_object($package)) {
             $status = $this->installPackage($package);
         } else {
             if ($package == eZPackage::STATUS_ALREADY_EXISTS) {
                 $package = eZPackage::fetch($packageName);
                 if (is_object($package)) {
                     $status = $this->installPackage($package);
                 } else {
                     eZDebug::writeError("Could not fetch package: {$packageName}", 'eZSurveyWizard::importPackage');
                 }
             } else {
                 eZDebug::writeError("Uploaded file is not an eZ Publish package", 'eZSurveyWizard::importPackage');
             }
         }
     } else {
         eZDebug::writeWarning('File "' . $file . '" does not exist', 'eZSurveyWizard::importPackage');
     }
 }