当前位置: 首页>>代码示例>>PHP>>正文


PHP ConfigFile::factory方法代码示例

本文整理汇总了PHP中ConfigFile::factory方法的典型用法代码示例。如果您正苦于以下问题:PHP ConfigFile::factory方法的具体用法?PHP ConfigFile::factory怎么用?PHP ConfigFile::factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ConfigFile的用法示例。


在下文中一共展示了ConfigFile::factory方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

  function __construct() {
    // Load main configuration file
    $config = ConfigFile::factory('kurogo', 'project', ConfigFile::OPTION_IGNORE_MODE | ConfigFile::OPTION_IGNORE_LOCAL);
    $this->addConfig($config);

    define('CONFIG_MODE', $config->getVar('CONFIG_MODE'));
    define('CONFIG_IGNORE_LOCAL', $config->getVar('CONFIG_IGNORE_LOCAL'));

    //make sure active site is set    
    if (!$site = $this->getVar('ACTIVE_SITE')) {
        die("FATAL ERROR: ACTIVE_SITE not set");
    }
    
    //make sure site_dir is set and is a valid path
    if (!($siteDir = $this->getVar('SITE_DIR')) || !($siteDir = realpath_exists($siteDir))) {
        die("FATAL ERROR: Site Directory ". $this->getVar('SITE_DIR') . " not found for site " . $site);
    }
    
    // Set up defines relative to SITE_DIR
    define('SITE_DIR',             $siteDir);
    define('SITE_KEY',             md5($siteDir));
    define('SITE_LIB_DIR',         SITE_DIR.'/lib');
    define('SITE_APP_DIR',         SITE_DIR.'/app');
    define('SITE_MODULES_DIR',     SITE_DIR.'/app/modules');
    define('DATA_DIR',             SITE_DIR.'/data');
    define('CACHE_DIR',            SITE_DIR.'/cache');
    define('LOG_DIR',              SITE_DIR.'/logs');
    define('SITE_CONFIG_DIR',      SITE_DIR.'/config');

    //load in the site config file (required);
    $config = ConfigFile::factory('site', 'site');
    $this->addConfig($config);

    // Set up theme define
    if (!$theme = $this->getVar('ACTIVE_THEME')) {
        die("FATAL ERROR: ACTIVE_THEME not set");
    }
    
    define('THEME_DIR', SITE_DIR.'/themes/'.$theme);
  }
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:40,代码来源:SiteConfig.php

示例2: initializeForPage

  protected function initializeForPage() {
        $this->addJQuery();
        switch ($this->page)
        {
             case 'module':
                $moduleID = $this->getArg('moduleID');
                if (empty($moduleID)) {
                    $this->redirectTo('modules');
                }

                $module = WebModule::factory($moduleID);
                $moduleData = $module->getModuleData();
                $moduleSections = array();
                
                if ($section = $this->getArg('section')) {
                    
                    if ($section=='feeds' && $module->hasFeeds()) {
                        if (strlen($this->getArg('removeFeed'))>0) {
                            $index = $this->getArg('removeFeed');
                            $module->removeFeed($index);
                        }

                        if ($this->getArg('addFeed')) {
                            $feedData = $this->getArg('addFeedData');
                            if (!$module->addFeed($feedData, $error)) {
                                $this->assign('errorMessage', $error);
                            }
                        }

                        $moduleData['feeds'] = $module->loadFeedData();
                        if (!$moduleData['feeds']) {
                            $moduleData['feeds'] = array();
                        }
                        $this->assign('feedURL', $this->buildBreadcrumbURL('module', array(
                                'moduleID'=>$moduleID,
                                'section'=>$section),false
                            ));
                        $this->assign('feedFields', $module->getFeedFields());
                    } elseif (!isset($moduleData[$section])) {
                        $this->redirectTo('module', array('moduleID'=>$moduleID), false);
                    }
                }

                if ($this->getArg('submit')) {
                    $merge = $this->getArg('merge', true);
                    if ($merge) {
                        $moduleData = $this->prepareSubmitData('moduleData');
                        $moduleData = array_merge($module->getModuleDefaultData(), $moduleData);
                    } else {
                        $moduleData = $this->prepareSubmitData('moduleData');
                    }

                    if ($section) {
                        $moduleData = array($section=>$moduleData[$section]);
                    } else {
                        /* only include the scalar values since array values come from sections */
                        $_data = array();
                        foreach ($moduleData as $var=>$val) {
                            if (is_scalar($val)) {
                                $_data[$var] = $val;
                            }
                            $moduleData = $_data;
                        }
                    }

                    $module->saveConfig($moduleData, $section);
                    if ($section) {
                        $this->redirectTo('module', array('moduleID'=>$moduleID), false);
                    } else {
                        $this->redirectTo('modules', false, false);
                    }
                } 
                
                $this->setPageTitle(sprintf("Administering %s module", $moduleData['title']));
                $this->setBreadcrumbTitle($moduleData['title']);
                $this->setBreadcrumbLongTitle($moduleData['title']);
                
                
                $formListItems = array();

                if ($section) {
                    $moduleData = $moduleData[$section];
                } else {
                   $formListItems[] = $this->getModuleItemForKey('id', $moduleID);
                }
                
                foreach ($moduleData as $key=>$value) {
                    if (is_scalar($value)) {
                        $formListItems[] = $module->getModuleItemForKey($key, $value);
                    } else {
                        $moduleSections[$key] = $module->getSectionTitleForKey($key);
                    }
                }
                
                if (!$section) {
                    foreach ($moduleSections as $key=>$title) {
                        $formListItems[] = array(
                            'type'=>'url',
                            'name'=>$title,
                            'value'=>$this->buildBreadcrumbURL('module', array(
//.........这里部分代码省略.........
开发者ID:nicosiseng,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AdminWebModule.php

示例3: getSiteAccessControlLists

 public static function getSiteAccessControlLists()
 {
     $config = ConfigFile::factory('acls', 'site', ConfigFile::OPTION_CREATE_EMPTY);
     $acls = array();
     foreach ($config->getSectionVars() as $aclArray) {
         if ($acl = AccessControlList::createFromArray($aclArray)) {
             $acls[] = $acl;
         }
     }
     return $acls;
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:11,代码来源:Kurogo.php

示例4: getAuthorityConfigFile

 /**
  * Returns the authentication config file
  * @return ConfigFile
 */
 private static function getAuthorityConfigFile()
 {
     return ConfigFile::factory('authentication', 'site');
 }
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:8,代码来源:AuthenticationAuthority.php

示例5: loadSiteConfigFile

 protected function loadSiteConfigFile($name, $opts = 0)
 {
     $config = ConfigFile::factory($name, 'site', $opts);
     Kurogo::siteConfig()->addConfig($config);
     return $config->getSectionVars(true);
 }
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:6,代码来源:APIModule.php

示例6: initializeForCommand

 public function initializeForCommand()
 {
     $this->requiresAdmin();
     switch ($this->command) {
         case 'checkversion':
             $current = Kurogo::sharedInstance()->checkCurrentVersion();
             Kurogo::log(LOG_INFO, sprintf("Checking version. This site: %s Current Kurogo Version: %s", $current, KUROGO_VERSION), 'admin');
             $uptodate = version_compare(KUROGO_VERSION, $current, ">=");
             $messageKey = $uptodate ? 'KUROGO_VERSION_MESSAGE_UPTODATE' : 'KUROGO_VERSION_MESSAGE_NOTUPDATED';
             $data = array('current' => $current, 'local' => KUROGO_VERSION, 'uptodate' => $uptodate, 'message' => $this->getLocalizedString($messageKey, $current, KUROGO_VERSION));
             $this->setResponse($data);
             $this->setResponseVersion(1);
             break;
         case 'getlocalizedstring':
             $key = $this->getArg('key');
             $data = array();
             if (is_array($key)) {
                 foreach ($key as $k) {
                     $data[$k] = $this->getLocalizedString($k);
                 }
             } else {
                 $data[$key] = $this->getLocalizedString($key);
             }
             $this->setResponse($data);
             $this->setResponseVersion(1);
             break;
         case 'clearcaches':
             Kurogo::log(LOG_NOTICE, "Clearing Site Caches", 'admin');
             $result = Kurogo::sharedInstance()->clearCaches();
             if ($result === 0) {
                 $this->setResponse(true);
                 $this->setResponseVersion(1);
             } else {
                 $this->throwError(new KurogoError(1, "Error clearing caches", "There was an error ({$result}) clearing the caches"));
             }
             break;
         case 'upload':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             $subsection = null;
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $type = $module;
                     break;
                 case 'site':
                     break;
                 default:
                     throw new KurogoConfigurationException("Invalid type {$type}");
             }
             if (count($_FILES) == 0) {
                 throw new KurogoException("No files uploaded");
             }
             foreach ($_FILES as $key => $uploadData) {
                 $this->uploadFile($type, $section, $subsection, $key, $uploadData);
             }
             $this->setResponseVersion(1);
             $this->setResponse(true);
             break;
         case 'getconfigsections':
             $type = $this->getArg('type');
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $sections = $module->getModuleAdminSections();
                     break;
                 case 'site':
                     throw new KurogoConfigurationException("getconfigsections for site not handled yet");
             }
             $this->setResponse($sections);
             $this->setResponseVersion(1);
             break;
         case 'getconfigdata':
             $type = $this->getArg('type');
             $section = $this->getArg('section', '');
             switch ($type) {
                 case 'module':
                     $moduleID = $this->getArg('module', '');
                     $module = WebModule::factory($moduleID);
                     $adminData = $this->getAdminData($module, $section);
                     break;
                 case 'site':
                     $adminData = $this->getAdminData('site', $section);
                     break;
             }
             $this->setResponse($adminData);
             $this->setResponseVersion(1);
             break;
         case 'setconfigdata':
             $type = $this->getArg('type');
             $data = $this->getArg('data', array());
             $section = $this->getArg('section', '');
             $subsection = null;
             if (empty($data)) {
                 $data = array();
             } elseif (!is_array($data)) {
                 throw new KurogoConfigurationException("Invalid data for {$type} {$section}");
             }
//.........这里部分代码省略.........
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AdminAPIModule.php

示例7: loadSiteConfigFile

 protected function loadSiteConfigFile($name, $keyName = null, $opts = 0)
 {
     $config = ConfigFile::factory($name, 'site', $opts);
     Kurogo::siteConfig()->addConfig($config);
     if ($keyName === null) {
         $keyName = $name;
     }
     return $this->loadConfigFile($config, $keyName);
 }
开发者ID:rolandinsh,项目名称:Kurogo-Mobile-Web,代码行数:9,代码来源:WebModule.php

示例8: minifyGetThemeVars

function minifyGetThemeVars()
{
    static $themeVars = null;
    if (!isset($themeVars)) {
        $config = ConfigFile::factory('config', 'theme', ConfigFile::OPTION_CREATE_EMPTY);
        $pagetype = Kurogo::deviceClassifier()->getPagetype();
        $platform = Kurogo::deviceClassifier()->getPlatform();
        $sections = array('common', $pagetype, $pagetype . '-' . $platform);
        $themeVars = array();
        foreach ($sections as $section) {
            if ($sectionVars = $config->getOptionalSection($section)) {
                $themeVars = array_merge($themeVars, $sectionVars);
            }
        }
    }
    return $themeVars;
}
开发者ID:narenv,项目名称:Kurogo-Mobile-Web,代码行数:17,代码来源:minify.php

示例9: htmlColorForColorString

        }
        $result['title'] = $feature->getTitle();
    }
    return $result;
}
function htmlColorForColorString($colorString)
{
    return substr($colorString, strlen($colorString) - 6);
}
function isValidURL($urlString)
{
    // There is a bug in some versions of filter_var where it can't handle hyphens in hostnames
    return filter_var(strtr($urlString, '-', '.'), FILTER_VALIDATE_URL);
}
class MapsAdmin
{
    public static function getMapControllerClasses()
    {
        return array('MapDataController' => 'default', 'MapDBDataController' => 'database');
    }
    public static function getStaticMapClasses()
    {
        return array('GoogleStaticMap' => 'Google', 'ArcGISStaticMap' => 'ArcGIS', 'WMSStaticMap' => 'WMS');
    }
    public static function getDynamicControllerClasses()
    {
        return array('GoogleJSMap' => 'Google', 'ArcGISJSMap' => 'ArcGIS');
    }
}
$config = ConfigFile::factory('maps', 'site');
Kurogo::siteConfig()->addConfig($config);
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:31,代码来源:Maps.php

示例10: getPageConfig

 protected function getPageConfig($name, $opts) {
   $config = ConfigFile::factory($this->id, "page-$name", $opts);
   $GLOBALS['siteConfig']->addConfig($config);
   return $config;
 }
开发者ID:nicosiseng,项目名称:Kurogo-Mobile-Web,代码行数:5,代码来源:WebModule.php

示例11: getConfig

 protected function getConfig($name, $type, $opts=0) {
   $config = ConfigFile::factory($name, $type, $opts);
   $GLOBALS['siteConfig']->addConfig($config);
   return $config;
 }
开发者ID:rezalutions,项目名称:Kurogo-Mobile-Web,代码行数:5,代码来源:WebModule.php

示例12: __construct

 function __construct(&$path)
 {
     // Load main configuration file
     $config = ConfigFile::factory('kurogo', 'project', ConfigFile::OPTION_IGNORE_MODE | ConfigFile::OPTION_IGNORE_LOCAL);
     $this->addConfig($config);
     define('CONFIG_MODE', $config->getVar('CONFIG_MODE', 'kurogo'));
     Kurogo::log(LOG_DEBUG, "Setting config mode to " . (CONFIG_MODE ? CONFIG_MODE : '<empty>'), 'config');
     define('CONFIG_IGNORE_LOCAL', $config->getVar('CONFIG_IGNORE_LOCAL', 'kurogo'));
     //multi site currently only works with a url base of root "/"
     if ($this->getOptionalVar('MULTI_SITE', false, 'kurogo')) {
         // in scripts you can pass the site name to Kurogo::initialize()
         if (PHP_SAPI == 'cli') {
             $site = strlen($path) > 0 ? $path : $this->getVar('DEFAULT_SITE');
             $siteDir = implode(DIRECTORY_SEPARATOR, array(ROOT_DIR, 'site', $site));
             if (!file_exists(realpath($siteDir))) {
                 die("FATAL ERROR: Site Directory {$siteDir} not found for site {$path}");
             }
         } else {
             $paths = explode("/", $path);
             // this is url
             $sites = array();
             $siteDir = '';
             if (count($paths) > 1) {
                 $site = $paths[1];
                 if ($sites = $this->getOptionalVar('ACTIVE_SITES', array(), 'kurogo')) {
                     //see if the site is in the list of available sites
                     if (in_array($site, $sites)) {
                         $testPath = implode(DIRECTORY_SEPARATOR, array(ROOT_DIR, 'site', $site));
                         if (($siteDir = realpath($testPath)) && file_exists($siteDir)) {
                             $urlBase = '/' . $site . '/';
                             // this is a url
                         }
                     }
                 } elseif ($this->isValidSiteName($site)) {
                     $testPath = implode(DIRECTORY_SEPARATOR, array(ROOT_DIR, 'site', $site));
                     if (($siteDir = realpath($testPath)) && file_exists($siteDir)) {
                         $urlBase = '/' . $site . '/';
                         // this is a url
                     }
                 }
             }
             if (!$siteDir) {
                 $site = $this->getVar('DEFAULT_SITE');
                 array_splice($paths, 1, 1, array($site, $paths[1]));
                 $url = implode("/", $paths);
                 header("Location: {$url}");
                 die;
             }
         }
     } else {
         //make sure active site is set
         if (!($site = $this->getVar('ACTIVE_SITE'))) {
             die("FATAL ERROR: ACTIVE_SITE not set");
         }
         // make sure site_dir is set and is a valid path
         // Do not call realpath_exists here because until SITE_DIR define is set
         // it will not allow files and directories outside ROOT_DIR
         if (!($siteDir = $this->getVar('SITE_DIR')) || !(($siteDir = realpath($siteDir)) && file_exists($siteDir))) {
             die("FATAL ERROR: Site Directory " . $this->getVar('SITE_DIR') . " not found for site " . $site);
         }
         if (PHP_SAPI != 'cli') {
             //
             // Get URL base
             //
             if ($urlBase = $config->getOptionalVar('URL_BASE', '', 'kurogo')) {
                 $urlBase = rtrim($urlBase, '/') . '/';
             } else {
                 //extract the path parts from the url
                 $pathParts = array_values(array_filter(explode("/", $_SERVER['REQUEST_URI'])));
                 $testPath = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR;
                 $urlBase = '/';
                 //once the path equals the WEBROOT_DIR we've found the base. This only works with symlinks
                 if (realpath($testPath) != WEBROOT_DIR) {
                     foreach ($pathParts as $dir) {
                         $test = $testPath . $dir . DIRECTORY_SEPARATOR;
                         if (realpath_exists($test)) {
                             $testPath = $test;
                             $urlBase .= $dir . '/';
                             if (realpath($test) == WEBROOT_DIR) {
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     define('SITE_NAME', $site);
     if (PHP_SAPI == 'cli') {
         define('URL_BASE', null);
     } else {
         if (!isset($urlBase)) {
             throw new KurogoConfigurationException("URL base not set. Please report the configuration to see why this happened");
         }
         define('URL_BASE', $urlBase);
         Kurogo::log(LOG_DEBUG, "Setting site to {$site} with a base of {$urlBase}", 'kurogo');
         // Strips out the leading part of the url for sites where
         // the base is not located at the document root, ie.. /mobile or /m
         // Also strips off the leading slash (needed by device debug below)
         if (isset($path)) {
//.........这里部分代码省略.........
开发者ID:hxfnd,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:SiteConfig.php

示例13: initializeForCommand

    public function initializeForCommand() {  
        $this->requiresAdmin();
        
        switch ($this->command) {
            case 'checkversion':
                $data = array(
                    'current'=>Kurogo::sharedInstance()->checkCurrentVersion(),
                    'local'  =>KUROGO_VERSION
                );
                $this->setResponse($data);
                $this->setResponseVersion(1);
                
                break;
            
            case 'clearcaches':

                $result = Kurogo::sharedInstance()->clearCaches();
                if ($result===0) {
                    $this->setResponse(true);
                    $this->setResponseVersion(1);
                } else {
                    $this->throwError(KurogoError(1, "Error clearing caches", "There was an error ($result) clearing the caches"));
                }
                break;
                
            case 'getconfigsections':
                $type = $this->getArg('type');
                switch ($type) 
                {
                    case 'module':
                        $moduleID = $this->getArg('module','');
                        try {
                            $module = WebModule::factory($moduleID);
                        } catch (Exception $e) {
                            throw new Exception('Module ' . $moduleID . ' not found');
                        }
        
                        $sections = $module->getModuleAdminSections();
                        break;
                    case 'site':
                        throw new Exception("getconfigsections for site not handled yet");
                }
                
                $this->setResponse($sections);
                $this->setResponseVersion(1);
                break;
                
            case 'getconfigdata':
                $type = $this->getArg('type');
                $section = $this->getArg('section','');
                
                switch ($type) 
                {
                    case 'module':
                        $moduleID = $this->getArg('module','');
                        try {
                            $module = WebModule::factory($moduleID);
                        } catch (Exception $e) {
                            throw new Exception('Module ' . $moduleID . ' not found');
                        }
        
                        $adminData = $this->getAdminData($module, $section);
                        break;
                    case 'site':
                        $adminData = $this->getAdminData('site', $section);
                        break;
                }
                
                $this->setResponse($adminData);
                $this->setResponseVersion(1);
                break;
                
            case 'setconfigdata':
                $type = $this->getArg('type');
                $data = $this->getArg('data', array());
                $section = $this->getArg('section','');
                $subsection = null;
                if (empty($data)) {
                    $data = array();
                } elseif (!is_array($data)) {
                    throw new Exception("Invalid data for $type $section");
                }
                
                switch ($type)
                {
                    case 'module':
                    
                        if ($section == 'overview') {
                            foreach ($data as $moduleID=>$props) {
                                try {
                                    $module = WebModule::factory($moduleID);
                                } catch (Exception $e) {
                                    throw new Exception('Module ' . $moduleID . ' not found');
                                }
                                
                                if (!is_array($props)) {
                                    throw new Exception("Invalid properties for $type $section");
                                }
                                
                                $valid_props = array('protected','secure','disabled','search');
//.........这里部分代码省略.........
开发者ID:neoroman,项目名称:Kurogo-Mobile-Web,代码行数:101,代码来源:AdminAPIModule.php


注:本文中的ConfigFile::factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。