Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • Yii
  • YiiBase
  • Overview
  • Package
  • Class
  • Tree
  1: <?php
  2: /**
  3:  * YiiBase class file.
  4:  *
  5:  * @author Qiang Xue <qiang.xue@gmail.com>
  6:  * @link http://www.yiiframework.com/
  7:  * @copyright 2008-2013 Yii Software LLC
  8:  * @license http://www.yiiframework.com/license/
  9:  * @package system
 10:  * @since 1.0
 11:  */
 12: 
 13: /**
 14:  * Gets the application start timestamp.
 15:  */
 16: defined('YII_BEGIN_TIME') or define('YII_BEGIN_TIME',microtime(true));
 17: /**
 18:  * This constant defines whether the application should be in debug mode or not. Defaults to false.
 19:  */
 20: defined('YII_DEBUG') or define('YII_DEBUG',false);
 21: /**
 22:  * This constant defines how much call stack information (file name and line number) should be logged by Yii::trace().
 23:  * Defaults to 0, meaning no backtrace information. If it is greater than 0,
 24:  * at most that number of call stacks will be logged. Note, only user application call stacks are considered.
 25:  */
 26: defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',0);
 27: /**
 28:  * This constant defines whether exception handling should be enabled. Defaults to true.
 29:  */
 30: defined('YII_ENABLE_EXCEPTION_HANDLER') or define('YII_ENABLE_EXCEPTION_HANDLER',true);
 31: /**
 32:  * This constant defines whether error handling should be enabled. Defaults to true.
 33:  */
 34: defined('YII_ENABLE_ERROR_HANDLER') or define('YII_ENABLE_ERROR_HANDLER',true);
 35: /**
 36:  * Defines the Yii framework installation path.
 37:  */
 38: defined('YII_PATH') or define('YII_PATH',dirname(__FILE__));
 39: /**
 40:  * Defines the Zii library installation path.
 41:  */
 42: defined('YII_ZII_PATH') or define('YII_ZII_PATH',YII_PATH.DIRECTORY_SEPARATOR.'zii');
 43: 
 44: /**
 45:  * YiiBase is a helper class serving common framework functionalities.
 46:  *
 47:  * Do not use YiiBase directly. Instead, use its child class {@link Yii} where
 48:  * you can customize methods of YiiBase.
 49:  *
 50:  * @author Qiang Xue <qiang.xue@gmail.com>
 51:  * @package system
 52:  * @since 1.0
 53:  */
 54: class YiiBase
 55: {
 56:     /**
 57:      * @var array class map used by the Yii autoloading mechanism.
 58:      * The array keys are the class names and the array values are the corresponding class file paths.
 59:      * @since 1.1.5
 60:      */
 61:     public static $classMap=array();
 62:     /**
 63:      * @var boolean whether to rely on PHP include path to autoload class files. Defaults to true.
 64:      * You may set this to be false if your hosting environment doesn't allow changing the PHP
 65:      * include path, or if you want to append additional autoloaders to the default Yii autoloader.
 66:      * @since 1.1.8
 67:      */
 68:     public static $enableIncludePath=true;
 69: 
 70:     protected static $_aliases=array('system'=>YII_PATH,'zii'=>YII_ZII_PATH); // alias => path
 71:     protected static $_imports=array();                 // alias => class name or directory
 72:     protected static $_includePaths;                        // list of include paths
 73:     protected static $_app;
 74:     protected static $_logger;
 75: 
 76: 
 77: 
 78:     /**
 79:      * @return string the version of Yii framework
 80:      */
 81:     public static function getVersion()
 82:     {
 83:         return '1.1.16';
 84:     }
 85: 
 86:     /**
 87:      * Creates a Web application instance.
 88:      * @param mixed $config application configuration.
 89:      * If a string, it is treated as the path of the file that contains the configuration;
 90:      * If an array, it is the actual configuration information.
 91:      * Please make sure you specify the {@link CApplication::basePath basePath} property in the configuration,
 92:      * which should point to the directory containing all application logic, template and data.
 93:      * If not, the directory will be defaulted to 'protected'.
 94:      * @return CWebApplication
 95:      */
 96:     public static function createWebApplication($config=null)
 97:     {
 98:         return self::createApplication('CWebApplication',$config);
 99:     }
100: 
101:     /**
102:      * Creates a console application instance.
103:      * @param mixed $config application configuration.
104:      * If a string, it is treated as the path of the file that contains the configuration;
105:      * If an array, it is the actual configuration information.
106:      * Please make sure you specify the {@link CApplication::basePath basePath} property in the configuration,
107:      * which should point to the directory containing all application logic, template and data.
108:      * If not, the directory will be defaulted to 'protected'.
109:      * @return CConsoleApplication
110:      */
111:     public static function createConsoleApplication($config=null)
112:     {
113:         return self::createApplication('CConsoleApplication',$config);
114:     }
115: 
116:     /**
117:      * Creates an application of the specified class.
118:      * @param string $class the application class name
119:      * @param mixed $config application configuration. This parameter will be passed as the parameter
120:      * to the constructor of the application class.
121:      * @return mixed the application instance
122:      */
123:     public static function createApplication($class,$config=null)
124:     {
125:         return new $class($config);
126:     }
127: 
128:     /**
129:      * Returns the application singleton or null if the singleton has not been created yet.
130:      * @return CApplication the application singleton, null if the singleton has not been created yet.
131:      */
132:     public static function app()
133:     {
134:         return self::$_app;
135:     }
136: 
137:     /**
138:      * Stores the application instance in the class static member.
139:      * This method helps implement a singleton pattern for CApplication.
140:      * Repeated invocation of this method or the CApplication constructor
141:      * will cause the throw of an exception.
142:      * To retrieve the application instance, use {@link app()}.
143:      * @param CApplication $app the application instance. If this is null, the existing
144:      * application singleton will be removed.
145:      * @throws CException if multiple application instances are registered.
146:      */
147:     public static function setApplication($app)
148:     {
149:         if(self::$_app===null || $app===null)
150:             self::$_app=$app;
151:         else
152:             throw new CException(Yii::t('yii','Yii application can only be created once.'));
153:     }
154: 
155:     /**
156:      * @return string the path of the framework
157:      */
158:     public static function getFrameworkPath()
159:     {
160:         return YII_PATH;
161:     }
162: 
163:     /**
164:      * Creates an object and initializes it based on the given configuration.
165:      *
166:      * The specified configuration can be either a string or an array.
167:      * If the former, the string is treated as the object type which can
168:      * be either the class name or {@link YiiBase::getPathOfAlias class path alias}.
169:      * If the latter, the 'class' element is treated as the object type,
170:      * and the rest of the name-value pairs in the array are used to initialize
171:      * the corresponding object properties.
172:      *
173:      * Any additional parameters passed to this method will be
174:      * passed to the constructor of the object being created.
175:      *
176:      * @param mixed $config the configuration. It can be either a string or an array.
177:      * @return mixed the created object
178:      * @throws CException if the configuration does not have a 'class' element.
179:      */
180:     public static function createComponent($config)
181:     {
182:         if(is_string($config))
183:         {
184:             $type=$config;
185:             $config=array();
186:         }
187:         elseif(isset($config['class']))
188:         {
189:             $type=$config['class'];
190:             unset($config['class']);
191:         }
192:         else
193:             throw new CException(Yii::t('yii','Object configuration must be an array containing a "class" element.'));
194: 
195:         if(!class_exists($type,false))
196:             $type=Yii::import($type,true);
197: 
198:         if(($n=func_num_args())>1)
199:         {
200:             $args=func_get_args();
201:             if($n===2)
202:                 $object=new $type($args[1]);
203:             elseif($n===3)
204:                 $object=new $type($args[1],$args[2]);
205:             elseif($n===4)
206:                 $object=new $type($args[1],$args[2],$args[3]);
207:             else
208:             {
209:                 unset($args[0]);
210:                 $class=new ReflectionClass($type);
211:                 // Note: ReflectionClass::newInstanceArgs() is available for PHP 5.1.3+
212:                 // $object=$class->newInstanceArgs($args);
213:                 $object=call_user_func_array(array($class,'newInstance'),$args);
214:             }
215:         }
216:         else
217:             $object=new $type;
218: 
219:         foreach($config as $key=>$value)
220:             $object->$key=$value;
221: 
222:         return $object;
223:     }
224: 
225:     /**
226:      * Imports a class or a directory.
227:      *
228:      * Importing a class is like including the corresponding class file.
229:      * The main difference is that importing a class is much lighter because it only
230:      * includes the class file when the class is referenced the first time.
231:      *
232:      * Importing a directory is equivalent to adding a directory into the PHP include path.
233:      * If multiple directories are imported, the directories imported later will take
234:      * precedence in class file searching (i.e., they are added to the front of the PHP include path).
235:      *
236:      * Path aliases are used to import a class or directory. For example,
237:      * <ul>
238:      *   <li><code>application.components.GoogleMap</code>: import the <code>GoogleMap</code> class.</li>
239:      *   <li><code>application.components.*</code>: import the <code>components</code> directory.</li>
240:      * </ul>
241:      *
242:      * The same path alias can be imported multiple times, but only the first time is effective.
243:      * Importing a directory does not import any of its subdirectories.
244:      *
245:      * Starting from version 1.1.5, this method can also be used to import a class in namespace format
246:      * (available for PHP 5.3 or above only). It is similar to importing a class in path alias format,
247:      * except that the dot separator is replaced by the backslash separator. For example, importing
248:      * <code>application\components\GoogleMap</code> is similar to importing <code>application.components.GoogleMap</code>.
249:      * The difference is that the former class is using qualified name, while the latter unqualified.
250:      *
251:      * Note, importing a class in namespace format requires that the namespace corresponds to
252:      * a valid path alias once backslash characters are replaced with dot characters.
253:      * For example, the namespace <code>application\components</code> must correspond to a valid
254:      * path alias <code>application.components</code>.
255:      *
256:      * @param string $alias path alias to be imported
257:      * @param boolean $forceInclude whether to include the class file immediately. If false, the class file
258:      * will be included only when the class is being used. This parameter is used only when
259:      * the path alias refers to a class.
260:      * @return string the class name or the directory that this alias refers to
261:      * @throws CException if the alias is invalid
262:      */
263:     public static function import($alias,$forceInclude=false)
264:     {
265:         if(isset(self::$_imports[$alias]))  // previously imported
266:             return self::$_imports[$alias];
267: 
268:         if(class_exists($alias,false) || interface_exists($alias,false))
269:             return self::$_imports[$alias]=$alias;
270: 
271:         if(($pos=strrpos($alias,'\\'))!==false) // a class name in PHP 5.3 namespace format
272:         {
273:             $namespace=str_replace('\\','.',ltrim(substr($alias,0,$pos),'\\'));
274:             if(($path=self::getPathOfAlias($namespace))!==false)
275:             {
276:                 $classFile=$path.DIRECTORY_SEPARATOR.substr($alias,$pos+1).'.php';
277:                 if($forceInclude)
278:                 {
279:                     if(is_file($classFile))
280:                         require($classFile);
281:                     else
282:                         throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias)));
283:                     self::$_imports[$alias]=$alias;
284:                 }
285:                 else
286:                     self::$classMap[$alias]=$classFile;
287:                 return $alias;
288:             }
289:             else
290:             {
291:                 // try to autoload the class with an autoloader
292:                 if (class_exists($alias,true))
293:                     return self::$_imports[$alias]=$alias;
294:                 else
295:                     throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory or file.',
296:                         array('{alias}'=>$namespace)));
297:             }
298:         }
299: 
300:         if(($pos=strrpos($alias,'.'))===false)  // a simple class name
301:         {
302:             // try to autoload the class with an autoloader if $forceInclude is true
303:             if($forceInclude && (Yii::autoload($alias,true) || class_exists($alias,true)))
304:                 self::$_imports[$alias]=$alias;
305:             return $alias;
306:         }
307: 
308:         $className=(string)substr($alias,$pos+1);
309:         $isClass=$className!=='*';
310: 
311:         if($isClass && (class_exists($className,false) || interface_exists($className,false)))
312:             return self::$_imports[$alias]=$className;
313: 
314:         if(($path=self::getPathOfAlias($alias))!==false)
315:         {
316:             if($isClass)
317:             {
318:                 if($forceInclude)
319:                 {
320:                     if(is_file($path.'.php'))
321:                         require($path.'.php');
322:                     else
323:                         throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file and the file is readable.',array('{alias}'=>$alias)));
324:                     self::$_imports[$alias]=$className;
325:                 }
326:                 else
327:                     self::$classMap[$className]=$path.'.php';
328:                 return $className;
329:             }
330:             else  // a directory
331:             {
332:                 if(self::$_includePaths===null)
333:                 {
334:                     self::$_includePaths=array_unique(explode(PATH_SEPARATOR,get_include_path()));
335:                     if(($pos=array_search('.',self::$_includePaths,true))!==false)
336:                         unset(self::$_includePaths[$pos]);
337:                 }
338: 
339:                 array_unshift(self::$_includePaths,$path);
340: 
341:                 if(self::$enableIncludePath && set_include_path('.'.PATH_SEPARATOR.implode(PATH_SEPARATOR,self::$_includePaths))===false)
342:                     self::$enableIncludePath=false;
343: 
344:                 return self::$_imports[$alias]=$path;
345:             }
346:         }
347:         else
348:             throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing directory or file.',
349:                 array('{alias}'=>$alias)));
350:     }
351: 
352:     /**
353:      * Translates an alias into a file path.
354:      * Note, this method does not ensure the existence of the resulting file path.
355:      * It only checks if the root alias is valid or not.
356:      * @param string $alias alias (e.g. system.web.CController)
357:      * @return mixed file path corresponding to the alias, false if the alias is invalid.
358:      */
359:     public static function getPathOfAlias($alias)
360:     {
361:         if(isset(self::$_aliases[$alias]))
362:             return self::$_aliases[$alias];
363:         elseif(($pos=strpos($alias,'.'))!==false)
364:         {
365:             $rootAlias=substr($alias,0,$pos);
366:             if(isset(self::$_aliases[$rootAlias]))
367:                 return self::$_aliases[$alias]=rtrim(self::$_aliases[$rootAlias].DIRECTORY_SEPARATOR.str_replace('.',DIRECTORY_SEPARATOR,substr($alias,$pos+1)),'*'.DIRECTORY_SEPARATOR);
368:             elseif(self::$_app instanceof CWebApplication)
369:             {
370:                 if(self::$_app->findModule($rootAlias)!==null)
371:                     return self::getPathOfAlias($alias);
372:             }
373:         }
374:         return false;
375:     }
376: 
377:     /**
378:      * Create a path alias.
379:      * Note, this method neither checks the existence of the path nor normalizes the path.
380:      * @param string $alias alias to the path
381:      * @param string $path the path corresponding to the alias. If this is null, the corresponding
382:      * path alias will be removed.
383:      */
384:     public static function setPathOfAlias($alias,$path)
385:     {
386:         if(empty($path))
387:             unset(self::$_aliases[$alias]);
388:         else
389:             self::$_aliases[$alias]=rtrim($path,'\\/');
390:     }
391: 
392:     /**
393:      * Class autoload loader.
394:      * This method is provided to be invoked within an __autoload() magic method.
395:      * @param string $className class name
396:      * @param bool $classMapOnly whether to load classes via classmap only
397:      * @return boolean whether the class has been loaded successfully
398:      * @throws CException When class name does not match class file in debug mode.
399:      */
400:     public static function autoload($className,$classMapOnly=false)
401:     {
402:         // use include so that the error PHP file may appear
403:         if(isset(self::$classMap[$className]))
404:             include(self::$classMap[$className]);
405:         elseif(isset(self::$_coreClasses[$className]))
406:             include(YII_PATH.self::$_coreClasses[$className]);
407:         elseif($classMapOnly)
408:             return false;
409:         else
410:         {
411:             // include class file relying on include_path
412:             if(strpos($className,'\\')===false)  // class without namespace
413:             {
414:                 if(self::$enableIncludePath===false)
415:                 {
416:                     foreach(self::$_includePaths as $path)
417:                     {
418:                         $classFile=$path.DIRECTORY_SEPARATOR.$className.'.php';
419:                         if(is_file($classFile))
420:                         {
421:                             include($classFile);
422:                             if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php')
423:                                 throw new CException(Yii::t('yii','Class name "{class}" does not match class file "{file}".', array(
424:                                     '{class}'=>$className,
425:                                     '{file}'=>$classFile,
426:                                 )));
427:                             break;
428:                         }
429:                     }
430:                 }
431:                 else
432:                     include($className.'.php');
433:             }
434:             else  // class name with namespace in PHP 5.3
435:             {
436:                 $namespace=str_replace('\\','.',ltrim($className,'\\'));
437:                 if(($path=self::getPathOfAlias($namespace))!==false)
438:                     include($path.'.php');
439:                 else
440:                     return false;
441:             }
442:             return class_exists($className,false) || interface_exists($className,false);
443:         }
444:         return true;
445:     }
446: 
447:     /**
448:      * Writes a trace message.
449:      * This method will only log a message when the application is in debug mode.
450:      * @param string $msg message to be logged
451:      * @param string $category category of the message
452:      * @see log
453:      */
454:     public static function trace($msg,$category='application')
455:     {
456:         if(YII_DEBUG)
457:             self::log($msg,CLogger::LEVEL_TRACE,$category);
458:     }
459: 
460:     /**
461:      * Logs a message.
462:      * Messages logged by this method may be retrieved via {@link CLogger::getLogs}
463:      * and may be recorded in different media, such as file, email, database, using
464:      * {@link CLogRouter}.
465:      * @param string $msg message to be logged
466:      * @param string $level level of the message (e.g. 'trace', 'warning', 'error'). It is case-insensitive.
467:      * @param string $category category of the message (e.g. 'system.web'). It is case-insensitive.
468:      */
469:     public static function log($msg,$level=CLogger::LEVEL_INFO,$category='application')
470:     {
471:         if(self::$_logger===null)
472:             self::$_logger=new CLogger;
473:         if(YII_DEBUG && YII_TRACE_LEVEL>0 && $level!==CLogger::LEVEL_PROFILE)
474:         {
475:             $traces=debug_backtrace();
476:             $count=0;
477:             foreach($traces as $trace)
478:             {
479:                 if(isset($trace['file'],$trace['line']) && strpos($trace['file'],YII_PATH)!==0)
480:                 {
481:                     $msg.="\nin ".$trace['file'].' ('.$trace['line'].')';
482:                     if(++$count>=YII_TRACE_LEVEL)
483:                         break;
484:                 }
485:             }
486:         }
487:         self::$_logger->log($msg,$level,$category);
488:     }
489: 
490:     /**
491:      * Marks the beginning of a code block for profiling.
492:      * This has to be matched with a call to {@link endProfile()} with the same token.
493:      * The begin- and end- calls must also be properly nested, e.g.,
494:      * <pre>
495:      * Yii::beginProfile('block1');
496:      * Yii::beginProfile('block2');
497:      * Yii::endProfile('block2');
498:      * Yii::endProfile('block1');
499:      * </pre>
500:      * The following sequence is not valid:
501:      * <pre>
502:      * Yii::beginProfile('block1');
503:      * Yii::beginProfile('block2');
504:      * Yii::endProfile('block1');
505:      * Yii::endProfile('block2');
506:      * </pre>
507:      * @param string $token token for the code block
508:      * @param string $category the category of this log message
509:      * @see endProfile
510:      */
511:     public static function beginProfile($token,$category='application')
512:     {
513:         self::log('begin:'.$token,CLogger::LEVEL_PROFILE,$category);
514:     }
515: 
516:     /**
517:      * Marks the end of a code block for profiling.
518:      * This has to be matched with a previous call to {@link beginProfile()} with the same token.
519:      * @param string $token token for the code block
520:      * @param string $category the category of this log message
521:      * @see beginProfile
522:      */
523:     public static function endProfile($token,$category='application')
524:     {
525:         self::log('end:'.$token,CLogger::LEVEL_PROFILE,$category);
526:     }
527: 
528:     /**
529:      * @return CLogger message logger
530:      */
531:     public static function getLogger()
532:     {
533:         if(self::$_logger!==null)
534:             return self::$_logger;
535:         else
536:             return self::$_logger=new CLogger;
537:     }
538: 
539:     /**
540:      * Sets the logger object.
541:      * @param CLogger $logger the logger object.
542:      * @since 1.1.8
543:      */
544:     public static function setLogger($logger)
545:     {
546:         self::$_logger=$logger;
547:     }
548: 
549:     /**
550:      * Returns a string that can be displayed on your Web page showing Powered-by-Yii information
551:      * @return string a string that can be displayed on your Web page showing Powered-by-Yii information
552:      */
553:     public static function powered()
554:     {
555:         return Yii::t('yii','Powered by {yii}.', array('{yii}'=>'<a href="http://www.yiiframework.com/" rel="external">Yii Framework</a>'));
556:     }
557: 
558:     /**
559:      * Translates a message to the specified language.
560:      * This method supports choice format (see {@link CChoiceFormat}),
561:      * i.e., the message returned will be chosen from a few candidates according to the given
562:      * number value. This feature is mainly used to solve plural format issue in case
563:      * a message has different plural forms in some languages.
564:      * @param string $category message category. Please use only word letters. Note, category 'yii' is
565:      * reserved for Yii framework core code use. See {@link CPhpMessageSource} for
566:      * more interpretation about message category.
567:      * @param string $message the original message
568:      * @param array $params parameters to be applied to the message using <code>strtr</code>.
569:      * The first parameter can be a number without key.
570:      * And in this case, the method will call {@link CChoiceFormat::format} to choose
571:      * an appropriate message translation.
572:      * Starting from version 1.1.6 you can pass parameter for {@link CChoiceFormat::format}
573:      * or plural forms format without wrapping it with array.
574:      * This parameter is then available as <code>{n}</code> in the message translation string.
575:      * @param string $source which message source application component to use.
576:      * Defaults to null, meaning using 'coreMessages' for messages belonging to
577:      * the 'yii' category and using 'messages' for the rest messages.
578:      * @param string $language the target language. If null (default), the {@link CApplication::getLanguage application language} will be used.
579:      * @return string the translated message
580:      * @see CMessageSource
581:      */
582:     public static function t($category,$message,$params=array(),$source=null,$language=null)
583:     {
584:         if(self::$_app!==null)
585:         {
586:             if($source===null)
587:                 $source=($category==='yii'||$category==='zii')?'coreMessages':'messages';
588:             if(($source=self::$_app->getComponent($source))!==null)
589:                 $message=$source->translate($category,$message,$language);
590:         }
591:         if($params===array())
592:             return $message;
593:         if(!is_array($params))
594:             $params=array($params);
595:         if(isset($params[0])) // number choice
596:         {
597:             if(strpos($message,'|')!==false)
598:             {
599:                 if(strpos($message,'#')===false)
600:                 {
601:                     $chunks=explode('|',$message);
602:                     $expressions=self::$_app->getLocale($language)->getPluralRules();
603:                     if($n=min(count($chunks),count($expressions)))
604:                     {
605:                         for($i=0;$i<$n;$i++)
606:                             $chunks[$i]=$expressions[$i].'#'.$chunks[$i];
607: 
608:                         $message=implode('|',$chunks);
609:                     }
610:                 }
611:                 $message=CChoiceFormat::format($message,$params[0]);
612:             }
613:             if(!isset($params['{n}']))
614:                 $params['{n}']=$params[0];
615:             unset($params[0]);
616:         }
617:         return $params!==array() ? strtr($message,$params) : $message;
618:     }
619: 
620:     /**
621:      * Registers a new class autoloader.
622:      * The new autoloader will be placed before {@link autoload} and after
623:      * any other existing autoloaders.
624:      * @param callback $callback a valid PHP callback (function name or array($className,$methodName)).
625:      * @param boolean $append whether to append the new autoloader after the default Yii autoloader.
626:      * Be careful using this option as it will disable {@link enableIncludePath autoloading via include path}
627:      * when set to true. After this the Yii autoloader can not rely on loading classes via simple include anymore
628:      * and you have to {@link import} all classes explicitly.
629:      */
630:     public static function registerAutoloader($callback, $append=false)
631:     {
632:         if($append)
633:         {
634:             self::$enableIncludePath=false;
635:             spl_autoload_register($callback);
636:         }
637:         else
638:         {
639:             spl_autoload_unregister(array('YiiBase','autoload'));
640:             spl_autoload_register($callback);
641:             spl_autoload_register(array('YiiBase','autoload'));
642:         }
643:     }
644: 
645:     /**
646:      * @var array class map for core Yii classes.
647:      * NOTE, DO NOT MODIFY THIS ARRAY MANUALLY. IF YOU CHANGE OR ADD SOME CORE CLASSES,
648:      * PLEASE RUN 'build autoload' COMMAND TO UPDATE THIS ARRAY.
649:      */
650:     protected static $_coreClasses=array(
651:         'CApplication' => '/base/CApplication.php',
652:         'CApplicationComponent' => '/base/CApplicationComponent.php',
653:         'CBehavior' => '/base/CBehavior.php',
654:         'CComponent' => '/base/CComponent.php',
655:         'CErrorEvent' => '/base/CErrorEvent.php',
656:         'CErrorHandler' => '/base/CErrorHandler.php',
657:         'CException' => '/base/CException.php',
658:         'CExceptionEvent' => '/base/CExceptionEvent.php',
659:         'CHttpException' => '/base/CHttpException.php',
660:         'CModel' => '/base/CModel.php',
661:         'CModelBehavior' => '/base/CModelBehavior.php',
662:         'CModelEvent' => '/base/CModelEvent.php',
663:         'CModule' => '/base/CModule.php',
664:         'CSecurityManager' => '/base/CSecurityManager.php',
665:         'CStatePersister' => '/base/CStatePersister.php',
666:         'CApcCache' => '/caching/CApcCache.php',
667:         'CCache' => '/caching/CCache.php',
668:         'CDbCache' => '/caching/CDbCache.php',
669:         'CDummyCache' => '/caching/CDummyCache.php',
670:         'CEAcceleratorCache' => '/caching/CEAcceleratorCache.php',
671:         'CFileCache' => '/caching/CFileCache.php',
672:         'CMemCache' => '/caching/CMemCache.php',
673:         'CRedisCache' => '/caching/CRedisCache.php',
674:         'CWinCache' => '/caching/CWinCache.php',
675:         'CXCache' => '/caching/CXCache.php',
676:         'CZendDataCache' => '/caching/CZendDataCache.php',
677:         'CCacheDependency' => '/caching/dependencies/CCacheDependency.php',
678:         'CChainedCacheDependency' => '/caching/dependencies/CChainedCacheDependency.php',
679:         'CDbCacheDependency' => '/caching/dependencies/CDbCacheDependency.php',
680:         'CDirectoryCacheDependency' => '/caching/dependencies/CDirectoryCacheDependency.php',
681:         'CExpressionDependency' => '/caching/dependencies/CExpressionDependency.php',
682:         'CFileCacheDependency' => '/caching/dependencies/CFileCacheDependency.php',
683:         'CGlobalStateCacheDependency' => '/caching/dependencies/CGlobalStateCacheDependency.php',
684:         'CAttributeCollection' => '/collections/CAttributeCollection.php',
685:         'CConfiguration' => '/collections/CConfiguration.php',
686:         'CList' => '/collections/CList.php',
687:         'CListIterator' => '/collections/CListIterator.php',
688:         'CMap' => '/collections/CMap.php',
689:         'CMapIterator' => '/collections/CMapIterator.php',
690:         'CQueue' => '/collections/CQueue.php',
691:         'CQueueIterator' => '/collections/CQueueIterator.php',
692:         'CStack' => '/collections/CStack.php',
693:         'CStackIterator' => '/collections/CStackIterator.php',
694:         'CTypedList' => '/collections/CTypedList.php',
695:         'CTypedMap' => '/collections/CTypedMap.php',
696:         'CConsoleApplication' => '/console/CConsoleApplication.php',
697:         'CConsoleCommand' => '/console/CConsoleCommand.php',
698:         'CConsoleCommandBehavior' => '/console/CConsoleCommandBehavior.php',
699:         'CConsoleCommandEvent' => '/console/CConsoleCommandEvent.php',
700:         'CConsoleCommandRunner' => '/console/CConsoleCommandRunner.php',
701:         'CHelpCommand' => '/console/CHelpCommand.php',
702:         'CDbCommand' => '/db/CDbCommand.php',
703:         'CDbConnection' => '/db/CDbConnection.php',
704:         'CDbDataReader' => '/db/CDbDataReader.php',
705:         'CDbException' => '/db/CDbException.php',
706:         'CDbMigration' => '/db/CDbMigration.php',
707:         'CDbTransaction' => '/db/CDbTransaction.php',
708:         'CActiveFinder' => '/db/ar/CActiveFinder.php',
709:         'CActiveRecord' => '/db/ar/CActiveRecord.php',
710:         'CActiveRecordBehavior' => '/db/ar/CActiveRecordBehavior.php',
711:         'CDbColumnSchema' => '/db/schema/CDbColumnSchema.php',
712:         'CDbCommandBuilder' => '/db/schema/CDbCommandBuilder.php',
713:         'CDbCriteria' => '/db/schema/CDbCriteria.php',
714:         'CDbExpression' => '/db/schema/CDbExpression.php',
715:         'CDbSchema' => '/db/schema/CDbSchema.php',
716:         'CDbTableSchema' => '/db/schema/CDbTableSchema.php',
717:         'CCubridColumnSchema' => '/db/schema/cubrid/CCubridColumnSchema.php',
718:         'CCubridSchema' => '/db/schema/cubrid/CCubridSchema.php',
719:         'CCubridTableSchema' => '/db/schema/cubrid/CCubridTableSchema.php',
720:         'CMssqlColumnSchema' => '/db/schema/mssql/CMssqlColumnSchema.php',
721:         'CMssqlCommandBuilder' => '/db/schema/mssql/CMssqlCommandBuilder.php',
722:         'CMssqlPdoAdapter' => '/db/schema/mssql/CMssqlPdoAdapter.php',
723:         'CMssqlSchema' => '/db/schema/mssql/CMssqlSchema.php',
724:         'CMssqlSqlsrvPdoAdapter' => '/db/schema/mssql/CMssqlSqlsrvPdoAdapter.php',
725:         'CMssqlTableSchema' => '/db/schema/mssql/CMssqlTableSchema.php',
726:         'CMysqlColumnSchema' => '/db/schema/mysql/CMysqlColumnSchema.php',
727:         'CMysqlCommandBuilder' => '/db/schema/mysql/CMysqlCommandBuilder.php',
728:         'CMysqlSchema' => '/db/schema/mysql/CMysqlSchema.php',
729:         'CMysqlTableSchema' => '/db/schema/mysql/CMysqlTableSchema.php',
730:         'COciColumnSchema' => '/db/schema/oci/COciColumnSchema.php',
731:         'COciCommandBuilder' => '/db/schema/oci/COciCommandBuilder.php',
732:         'COciSchema' => '/db/schema/oci/COciSchema.php',
733:         'COciTableSchema' => '/db/schema/oci/COciTableSchema.php',
734:         'CPgsqlColumnSchema' => '/db/schema/pgsql/CPgsqlColumnSchema.php',
735:         'CPgsqlCommandBuilder' => '/db/schema/pgsql/CPgsqlCommandBuilder.php',
736:         'CPgsqlSchema' => '/db/schema/pgsql/CPgsqlSchema.php',
737:         'CPgsqlTableSchema' => '/db/schema/pgsql/CPgsqlTableSchema.php',
738:         'CSqliteColumnSchema' => '/db/schema/sqlite/CSqliteColumnSchema.php',
739:         'CSqliteCommandBuilder' => '/db/schema/sqlite/CSqliteCommandBuilder.php',
740:         'CSqliteSchema' => '/db/schema/sqlite/CSqliteSchema.php',
741:         'CChoiceFormat' => '/i18n/CChoiceFormat.php',
742:         'CDateFormatter' => '/i18n/CDateFormatter.php',
743:         'CDbMessageSource' => '/i18n/CDbMessageSource.php',
744:         'CGettextMessageSource' => '/i18n/CGettextMessageSource.php',
745:         'CLocale' => '/i18n/CLocale.php',
746:         'CMessageSource' => '/i18n/CMessageSource.php',
747:         'CNumberFormatter' => '/i18n/CNumberFormatter.php',
748:         'CPhpMessageSource' => '/i18n/CPhpMessageSource.php',
749:         'CGettextFile' => '/i18n/gettext/CGettextFile.php',
750:         'CGettextMoFile' => '/i18n/gettext/CGettextMoFile.php',
751:         'CGettextPoFile' => '/i18n/gettext/CGettextPoFile.php',
752:         'CChainedLogFilter' => '/logging/CChainedLogFilter.php',
753:         'CDbLogRoute' => '/logging/CDbLogRoute.php',
754:         'CEmailLogRoute' => '/logging/CEmailLogRoute.php',
755:         'CFileLogRoute' => '/logging/CFileLogRoute.php',
756:         'CLogFilter' => '/logging/CLogFilter.php',
757:         'CLogRoute' => '/logging/CLogRoute.php',
758:         'CLogRouter' => '/logging/CLogRouter.php',
759:         'CLogger' => '/logging/CLogger.php',
760:         'CProfileLogRoute' => '/logging/CProfileLogRoute.php',
761:         'CSysLogRoute' => '/logging/CSysLogRoute.php',
762:         'CWebLogRoute' => '/logging/CWebLogRoute.php',
763:         'CDateTimeParser' => '/utils/CDateTimeParser.php',
764:         'CFileHelper' => '/utils/CFileHelper.php',
765:         'CFormatter' => '/utils/CFormatter.php',
766:         'CLocalizedFormatter' => '/utils/CLocalizedFormatter.php',
767:         'CMarkdownParser' => '/utils/CMarkdownParser.php',
768:         'CPasswordHelper' => '/utils/CPasswordHelper.php',
769:         'CPropertyValue' => '/utils/CPropertyValue.php',
770:         'CTimestamp' => '/utils/CTimestamp.php',
771:         'CVarDumper' => '/utils/CVarDumper.php',
772:         'CBooleanValidator' => '/validators/CBooleanValidator.php',
773:         'CCaptchaValidator' => '/validators/CCaptchaValidator.php',
774:         'CCompareValidator' => '/validators/CCompareValidator.php',
775:         'CDateValidator' => '/validators/CDateValidator.php',
776:         'CDefaultValueValidator' => '/validators/CDefaultValueValidator.php',
777:         'CEmailValidator' => '/validators/CEmailValidator.php',
778:         'CExistValidator' => '/validators/CExistValidator.php',
779:         'CFileValidator' => '/validators/CFileValidator.php',
780:         'CFilterValidator' => '/validators/CFilterValidator.php',
781:         'CInlineValidator' => '/validators/CInlineValidator.php',
782:         'CNumberValidator' => '/validators/CNumberValidator.php',
783:         'CRangeValidator' => '/validators/CRangeValidator.php',
784:         'CRegularExpressionValidator' => '/validators/CRegularExpressionValidator.php',
785:         'CRequiredValidator' => '/validators/CRequiredValidator.php',
786:         'CSafeValidator' => '/validators/CSafeValidator.php',
787:         'CStringValidator' => '/validators/CStringValidator.php',
788:         'CTypeValidator' => '/validators/CTypeValidator.php',
789:         'CUniqueValidator' => '/validators/CUniqueValidator.php',
790:         'CUnsafeValidator' => '/validators/CUnsafeValidator.php',
791:         'CUrlValidator' => '/validators/CUrlValidator.php',
792:         'CValidator' => '/validators/CValidator.php',
793:         'CActiveDataProvider' => '/web/CActiveDataProvider.php',
794:         'CArrayDataProvider' => '/web/CArrayDataProvider.php',
795:         'CAssetManager' => '/web/CAssetManager.php',
796:         'CBaseController' => '/web/CBaseController.php',
797:         'CCacheHttpSession' => '/web/CCacheHttpSession.php',
798:         'CClientScript' => '/web/CClientScript.php',
799:         'CController' => '/web/CController.php',
800:         'CDataProvider' => '/web/CDataProvider.php',
801:         'CDataProviderIterator' => '/web/CDataProviderIterator.php',
802:         'CDbHttpSession' => '/web/CDbHttpSession.php',
803:         'CExtController' => '/web/CExtController.php',
804:         'CFormModel' => '/web/CFormModel.php',
805:         'CHttpCookie' => '/web/CHttpCookie.php',
806:         'CHttpRequest' => '/web/CHttpRequest.php',
807:         'CHttpSession' => '/web/CHttpSession.php',
808:         'CHttpSessionIterator' => '/web/CHttpSessionIterator.php',
809:         'COutputEvent' => '/web/COutputEvent.php',
810:         'CPagination' => '/web/CPagination.php',
811:         'CSort' => '/web/CSort.php',
812:         'CSqlDataProvider' => '/web/CSqlDataProvider.php',
813:         'CTheme' => '/web/CTheme.php',
814:         'CThemeManager' => '/web/CThemeManager.php',
815:         'CUploadedFile' => '/web/CUploadedFile.php',
816:         'CUrlManager' => '/web/CUrlManager.php',
817:         'CWebApplication' => '/web/CWebApplication.php',
818:         'CWebModule' => '/web/CWebModule.php',
819:         'CWidgetFactory' => '/web/CWidgetFactory.php',
820:         'CAction' => '/web/actions/CAction.php',
821:         'CInlineAction' => '/web/actions/CInlineAction.php',
822:         'CViewAction' => '/web/actions/CViewAction.php',
823:         'CAccessControlFilter' => '/web/auth/CAccessControlFilter.php',
824:         'CAuthAssignment' => '/web/auth/CAuthAssignment.php',
825:         'CAuthItem' => '/web/auth/CAuthItem.php',
826:         'CAuthManager' => '/web/auth/CAuthManager.php',
827:         'CBaseUserIdentity' => '/web/auth/CBaseUserIdentity.php',
828:         'CDbAuthManager' => '/web/auth/CDbAuthManager.php',
829:         'CPhpAuthManager' => '/web/auth/CPhpAuthManager.php',
830:         'CUserIdentity' => '/web/auth/CUserIdentity.php',
831:         'CWebUser' => '/web/auth/CWebUser.php',
832:         'CFilter' => '/web/filters/CFilter.php',
833:         'CFilterChain' => '/web/filters/CFilterChain.php',
834:         'CHttpCacheFilter' => '/web/filters/CHttpCacheFilter.php',
835:         'CInlineFilter' => '/web/filters/CInlineFilter.php',
836:         'CForm' => '/web/form/CForm.php',
837:         'CFormButtonElement' => '/web/form/CFormButtonElement.php',
838:         'CFormElement' => '/web/form/CFormElement.php',
839:         'CFormElementCollection' => '/web/form/CFormElementCollection.php',
840:         'CFormInputElement' => '/web/form/CFormInputElement.php',
841:         'CFormStringElement' => '/web/form/CFormStringElement.php',
842:         'CGoogleApi' => '/web/helpers/CGoogleApi.php',
843:         'CHtml' => '/web/helpers/CHtml.php',
844:         'CJSON' => '/web/helpers/CJSON.php',
845:         'CJavaScript' => '/web/helpers/CJavaScript.php',
846:         'CJavaScriptExpression' => '/web/helpers/CJavaScriptExpression.php',
847:         'CPradoViewRenderer' => '/web/renderers/CPradoViewRenderer.php',
848:         'CViewRenderer' => '/web/renderers/CViewRenderer.php',
849:         'CWebService' => '/web/services/CWebService.php',
850:         'CWebServiceAction' => '/web/services/CWebServiceAction.php',
851:         'CWsdlGenerator' => '/web/services/CWsdlGenerator.php',
852:         'CActiveForm' => '/web/widgets/CActiveForm.php',
853:         'CAutoComplete' => '/web/widgets/CAutoComplete.php',
854:         'CClipWidget' => '/web/widgets/CClipWidget.php',
855:         'CContentDecorator' => '/web/widgets/CContentDecorator.php',
856:         'CFilterWidget' => '/web/widgets/CFilterWidget.php',
857:         'CFlexWidget' => '/web/widgets/CFlexWidget.php',
858:         'CHtmlPurifier' => '/web/widgets/CHtmlPurifier.php',
859:         'CInputWidget' => '/web/widgets/CInputWidget.php',
860:         'CMarkdown' => '/web/widgets/CMarkdown.php',
861:         'CMaskedTextField' => '/web/widgets/CMaskedTextField.php',
862:         'CMultiFileUpload' => '/web/widgets/CMultiFileUpload.php',
863:         'COutputCache' => '/web/widgets/COutputCache.php',
864:         'COutputProcessor' => '/web/widgets/COutputProcessor.php',
865:         'CStarRating' => '/web/widgets/CStarRating.php',
866:         'CTabView' => '/web/widgets/CTabView.php',
867:         'CTextHighlighter' => '/web/widgets/CTextHighlighter.php',
868:         'CTreeView' => '/web/widgets/CTreeView.php',
869:         'CWidget' => '/web/widgets/CWidget.php',
870:         'CCaptcha' => '/web/widgets/captcha/CCaptcha.php',
871:         'CCaptchaAction' => '/web/widgets/captcha/CCaptchaAction.php',
872:         'CBasePager' => '/web/widgets/pagers/CBasePager.php',
873:         'CLinkPager' => '/web/widgets/pagers/CLinkPager.php',
874:         'CListPager' => '/web/widgets/pagers/CListPager.php',
875:     );
876: }
877: 
878: spl_autoload_register(array('YiiBase','autoload'));
879: require(YII_PATH.'/base/interfaces.php');
880: 
API documentation generated by ApiGen 2.8.0