Ejemplo n.º 1
0
 public function testFindAllMainByExpressionAndObject()
 {
     $aMainPaths = ResourceFinder::findResourcesByExpressions(array('lib', 'main.php'));
     $this->assertSame(1, count($aMainPaths));
     $oFileRes = new FileResource(ArrayUtil::assocPeek($aMainPaths));
     $this->assertSame(array($oFileRes->getRelativePath() => MAIN_DIR . '/base/lib/main.php'), $aMainPaths);
 }
Ejemplo n.º 2
0
 public static function listModulesByType($sType, $bListEnabledOnly = true)
 {
     if ($sType === null) {
         $sType = ResourceFinder::ANY_NAME_OR_TYPE_PATTERN;
     }
     if (isset(self::$MODULE_LIST[$sType]) && !$bListEnabledOnly) {
         return self::$MODULE_LIST[$sType];
     }
     $aPaths = ResourceFinder::findResourcesByExpressions(array(DIRNAME_MODULES, $sType, ResourceFinder::ANY_NAME_OR_TYPE_PATTERN));
     $aResult = array();
     foreach ($aPaths as $sPath => $aAbsolutePath) {
         $aPathParts = explode("/", $sPath);
         $sName = $aPathParts[count($aPathParts) - 1];
         $sType = $aPathParts[count($aPathParts) - 2];
         $aModuleMetadata = self::getModuleMetadataByTypeAndName($sType, $sName);
         if (!$bListEnabledOnly || $aModuleMetadata['module_info']['enabled'] !== false) {
             $aResult[$sName] = $aModuleMetadata;
         }
     }
     if (!$bListEnabledOnly) {
         self::$MODULE_LIST[$sType] = $aResult;
     }
     ksort($aResult);
     return $aResult;
 }
 public function getMatchingCustomTemplates($aPostfix = array(self::CONTENT_TEMPLATE_SUFFIX, self::CSS_TEMPLATE_SUFFIX))
 {
     $aMatchingTemplates = array();
     $aTemplateList = ResourceFinder::findResourcesByExpressions(array(DIRNAME_TEMPLATES, self::NEWSLETTER_DIRNAME, '/.+.content.tmpl/'));
     foreach ($aTemplateList as $sTemplateShortPath => $sTemplatePath) {
         $sTemplateName = substr($sTemplateShortPath, 0, -strlen(self::CONTENT_TEMPLATE_SUFFIX . '.tmpl'));
         $sTemplateName = substr($sTemplateName, strlen(DIRNAME_TEMPLATES . '/' . self::NEWSLETTER_DIRNAME . '/'));
         if (ResourceFinder::findResource(array(DIRNAME_TEMPLATES, self::NEWSLETTER_DIRNAME, "{$sTemplateName}.css.tmpl")) !== null) {
             $aMatchingTemplates[$sTemplateName] = $sTemplateName;
         }
     }
     return $aMatchingTemplates;
 }