Example #1
0
 public static function getThemeVars()
 {
     if ($config = Kurogo::getThemeConfig()) {
         $pagetype = Kurogo::deviceClassifier()->getPagetype();
         $platform = Kurogo::deviceClassifier()->getPlatform();
         $browser = Kurogo::deviceClassifier()->getBrowser();
         $sections = array('common', $pagetype, "{$pagetype}-{$platform}", "{$pagetype}-{$platform}-{$browser}");
         $themeVars = array();
         foreach ($sections as $section) {
             if ($sectionVars = $config->getOptionalSection($section)) {
                 $themeVars = array_merge($themeVars, $sectionVars);
             }
         }
     }
     return $themeVars;
 }
Example #2
0
function getMinifyGroupsConfig()
{
    $minifyConfig = array();
    $key = $_GET['g'];
    // javascript and css search directory order
    $dirs = array(APP_DIR, SHARED_APP_DIR, SITE_APP_DIR, SHARED_THEME_DIR, THEME_DIR);
    //
    // Check for specific file request
    //
    if (strpos($key, MIN_FILE_PREFIX) === 0) {
        // file path relative to either templates or the theme (check theme first)
        $path = substr($key, strlen(MIN_FILE_PREFIX));
        $files = array();
        foreach ($dirs as $dir) {
            if ($dir) {
                $files[] = $dir . $path;
            }
        }
        $config = array('include' => 'all', 'files' => $files);
        return array($key => buildFileList($config));
    }
    //
    // Page request
    //
    $pageOnly = isset($_GET['pageOnly']) && $_GET['pageOnly'];
    $noCommon = $pageOnly || isset($_GET['noCommon']) && $_GET['noCommon'];
    // if this is a copied module also pull in files from that module
    $configModule = isset($_GET['config']) ? $_GET['config'] : '';
    list($ext, $module, $page, $pagetype, $platform, $browser, $pathHash) = explode('-', $key);
    $cache = new DiskCache(CACHE_DIR . '/minify', Kurogo::getOptionalSiteVar('MINIFY_CACHE_TIMEOUT', 30), true);
    $cacheName = "group_{$key}";
    $Kurogo = Kurogo::sharedInstance();
    $Kurogo->setCurrentModuleID($module);
    if ($configModule) {
        $Kurogo->setCurrentConfigModule($configModule);
        $cacheName .= "-{$configModule}";
    }
    if ($pageOnly) {
        $cacheName .= "-pageOnly";
    }
    if ($cache->isFresh($cacheName)) {
        $minifyConfig = $cache->read($cacheName);
    } else {
        if ($noCommon) {
            // Info module does not inherit from common files
            $subDirs = array('/modules/' . $module);
        } else {
            $subDirs = array('/common', '/modules/' . $module);
        }
        if ($configModule && $configModule !== $module) {
            $subDirs[] = '/modules/' . $configModule;
        }
        $checkFiles = array('css' => getFileConfigForDirs('css', 'css', $page, $pagetype, $platform, $browser, $dirs, $subDirs, $pageOnly), 'js' => getFileConfigForDirs('js', 'javascript', $page, $pagetype, $platform, $browser, $dirs, $subDirs, $pageOnly));
        //error_log(print_r($checkFiles, true));
        $minifyConfig[$key] = buildFileList($checkFiles[$ext]);
        //error_log(__FUNCTION__."($pagetype-$platform-$browser) scanned filesystem for $key");
        $cache->write($minifyConfig, $cacheName);
    }
    // Add minify source object for the theme config
    if ($ext == 'css') {
        $themeConfig = Kurogo::getThemeConfig();
        if ($themeConfig) {
            $minifyConfig[$key][] = new Minify_Source(array('id' => 'themeConfigModTimeChecker', 'getContentFunc' => 'minifyThemeConfigModTimeCheckerContent', 'minifier' => '', 'contentType' => Minify::TYPE_CSS, 'lastModified' => $themeConfig->getLastModified()));
        }
    }
    //error_log(__FUNCTION__."($pagetype-$platform-$browser) returning: ".print_r($minifyConfig, true));
    return $minifyConfig;
}