Christoffer Niska avatar Christoffer Niska committed 4aa0311

upgraded to demo to use yii 1.1.11

Comments (0)

Files changed (1018)

demo/yii/YiiBase.php

  * @link http://www.yiiframework.com/
  * @copyright Copyright © 2008-2011 Yii Software LLC
  * @license http://www.yiiframework.com/license/
- * @version $Id: YiiBase.php 3564 2012-02-13 01:29:03Z qiang.xue $
+ * @version $Id$
  * @package system
  * @since 1.0
  */
  * you can customize methods of YiiBase.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: YiiBase.php 3564 2012-02-13 01:29:03Z qiang.xue $
+ * @version $Id$
  * @package system
  * @since 1.0
  */
 	 */
 	public static function getVersion()
 	{
-		return '1.1.10';
+		return '1.1.11';
 	}
 
 	/**
 					if(is_file($classFile))
 						require($classFile);
 					else
-						throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file.',array('{alias}'=>$alias)));
+						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)));
 					self::$_imports[$alias]=$alias;
 				}
 				else
 					if(is_file($path.'.php'))
 						require($path.'.php');
 					else
-						throw new CException(Yii::t('yii','Alias "{alias}" is invalid. Make sure it points to an existing PHP file.',array('{alias}'=>$alias)));
+						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)));
 					self::$_imports[$alias]=$className;
 				}
 				else
 						if(is_file($classFile))
 						{
 							include($classFile);
+							if(YII_DEBUG && basename(realpath($classFile))!==$className.'.php')
+								throw new CException(Yii::t('yii','Class name "{class}" does not match class file "{file}".', array(
+									'{class}'=>$className,
+									'{file}'=>$classFile,
+								)));
 							break;
 						}
 					}
 	 * an appropriate message translation.
 	 * Starting from version 1.1.6 you can pass parameter for {@link CChoiceFormat::format}
 	 * or plural forms format without wrapping it with array.
+	 * This parameter is then available as <code>{n}</code> in the message translation string.
 	 * @param string $source which message source application component to use.
 	 * Defaults to null, meaning using 'coreMessages' for messages belonging to
 	 * the 'yii' category and using 'messages' for the rest messages.
 		'CTypedMap' => '/collections/CTypedMap.php',
 		'CConsoleApplication' => '/console/CConsoleApplication.php',
 		'CConsoleCommand' => '/console/CConsoleCommand.php',
+		'CConsoleCommandBehavior' => '/console/CConsoleCommandBehavior.php',
+		'CConsoleCommandEvent' => '/console/CConsoleCommandEvent.php',
 		'CConsoleCommandRunner' => '/console/CConsoleCommandRunner.php',
 		'CHelpCommand' => '/console/CHelpCommand.php',
 		'CDbCommand' => '/db/CDbCommand.php',
 		'CWebUser' => '/web/auth/CWebUser.php',
 		'CFilter' => '/web/filters/CFilter.php',
 		'CFilterChain' => '/web/filters/CFilterChain.php',
+		'CHttpCacheFilter' => '/web/filters/CHttpCacheFilter.php',
 		'CInlineFilter' => '/web/filters/CInlineFilter.php',
 		'CForm' => '/web/form/CForm.php',
 		'CFormButtonElement' => '/web/form/CFormButtonElement.php',
 		'CHtml' => '/web/helpers/CHtml.php',
 		'CJSON' => '/web/helpers/CJSON.php',
 		'CJavaScript' => '/web/helpers/CJavaScript.php',
+		'CJavaScriptExpression' => '/web/helpers/CJavaScriptExpression.php',
 		'CPradoViewRenderer' => '/web/renderers/CPradoViewRenderer.php',
 		'CViewRenderer' => '/web/renderers/CViewRenderer.php',
 		'CWebService' => '/web/services/CWebService.php',

demo/yii/base/CApplication.php

  * @property string $homeUrl The homepage URL.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CApplication.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CApplicationComponent.php

  * @property boolean $isInitialized Whether this application component has been initialized (ie, {@link init()} is invoked).
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CApplicationComponent.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CBehavior.php

  * @property boolean $enabled Whether this behavior is enabled.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CBehavior.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  */
 class CBehavior extends CComponent implements IBehavior

demo/yii/base/CComponent.php

  * is attached to.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CComponent.php 3521 2011-12-29 22:10:57Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 	 */
 	public function evaluateExpression($_expression_,$_data_=array())
 	{
-		if(is_string($_expression_))
+		if(is_string($_expression_) && !function_exists($_expression_))
 		{
 			extract($_data_);
 			return eval('return '.$_expression_.';');
  * that are not invoked yet will not be invoked anymore.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CComponent.php 3521 2011-12-29 22:10:57Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * TextAlign::Right.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CComponent.php 3521 2011-12-29 22:10:57Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CErrorEvent.php

  * CErrorEvent represents the parameter for the {@link CApplication::onError onError} event.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CErrorEvent.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CErrorHandler.php

  * @property array $error The error details. Null if there is no error.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CErrorHandler.php 3540 2012-01-16 10:17:01Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 
 		if($this->discardOutput)
 		{
+			$gzHandler=false;
+			foreach(ob_list_handlers() as $h)
+			{
+				if(strpos($h,'gzhandler')!==false)
+					$gzHandler=true;
+			}
 			// the following manual level counting is to deal with zlib.output_compression set to On
+			// for an output buffer created by zlib.output_compression set to On ob_end_clean will fail
 			for($level=ob_get_level();$level>0;--$level)
 			{
-				@ob_end_clean();
+				if(!@ob_end_clean())
+					ob_clean();
+			}
+			// reset headers in case there was an ob_start("ob_gzhandler") before
+			if($gzHandler && !headers_sent() && ob_list_handlers()===array())
+			{
+				if(function_exists('header_remove')) // php >= 5.3
+				{
+					header_remove('Vary');
+					header_remove('Content-Encoding');
+				}
+				else
+				{
+					header('Vary:');
+					header('Content-Encoding:');
+				}
 			}
 		}
 
 			);
 
 			if(!headers_sent())
-				header("HTTP/1.0 {$data['code']} ".get_class($exception));
+				header("HTTP/1.0 {$data['code']} ".$this->getHttpHeader($data['code'], get_class($exception)));
 
 			if($exception instanceof CHttpException || !YII_DEBUG)
 				$this->render('error',$data);
 				'traces'=>$trace,
 			);
 			if(!headers_sent())
-				header("HTTP/1.0 500 PHP Error");
+				header("HTTP/1.0 500 Internal Server Error");
 			if($this->isAjaxRequest())
 				$app->displayError($event->code,$event->message,$event->file,$event->line);
 			else if(YII_DEBUG)
 		}
 		return '<div class="code"><pre>'.$output.'</pre></div>';
 	}
+	/**
+	 * Return correct message for each known http error code
+	 * @param integer $httpCode error code to map
+	 * @param string $replacement replacement error string that is returned if code is unknown
+	 * @return string the textual representation of the given error code or the replacement string if the error code is unknown
+	 */
+	protected function getHttpHeader($httpCode, $replacement='')
+	{
+		$httpCodes = array(
+			100 => 'Continue',
+			101 => 'Switching Protocols',
+			102 => 'Processing',
+			118 => 'Connection timed out',
+			200 => 'OK',
+			201 => 'Created',
+			202 => 'Accepted',
+			203 => 'Non-Authoritative',
+			204 => 'No Content',
+			205 => 'Reset Content',
+			206 => 'Partial Content',
+			207 => 'Multi-Status',
+			210 => 'Content Different',
+			300 => 'Multiple Choices',
+			301 => 'Moved Permanently',
+			302 => 'Found',
+			303 => 'See Other',
+			304 => 'Not Modified',
+			305 => 'Use Proxy',
+			307 => 'Temporary Redirect',
+			310 => 'Too many Redirect',
+			400 => 'Bad Request',
+			401 => 'Unauthorized',
+			402 => 'Payment Required',
+			403 => 'Forbidden',
+			404 => 'Not Found',
+			405 => 'Method Not Allowed',
+			406 => 'Not Acceptable',
+			407 => 'Proxy Authentication Required',
+			408 => 'Request Time-out',
+			409 => 'Conflict',
+			410 => 'Gone',
+			411 => 'Length Required',
+			412 => 'Precondition Failed',
+			413 => 'Request Entity Too Large',
+			414 => 'Request-URI Too Long',
+			415 => 'Unsupported Media Type',
+			416 => 'Requested range unsatisfiable',
+			417 => 'Expectation failed',
+			418 => 'I’m a teapot',
+			422 => 'Unprocessable entity',
+			423 => 'Locked',
+			424 => 'Method failure',
+			425 => 'Unordered Collection',
+			426 => 'Upgrade Required',
+			449 => 'Retry With',
+			450 => 'Blocked by Windows Parental Controls',
+			500 => 'Internal Server Error',
+			501 => 'Not Implemented',
+			502 => 'Bad Gateway ou Proxy Error',
+			503 => 'Service Unavailable',
+			504 => 'Gateway Time-out',
+			505 => 'HTTP Version not supported',
+			507 => 'Insufficient storage',
+			509 => 'Bandwidth Limit Exceeded',
+		);
+		if(isset($httpCodes[$httpCode]))
+			return $httpCodes[$httpCode];
+		else
+			return $replacement;
+	}
 }

demo/yii/base/CException.php

  * CException represents a generic exception for all purposes.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CException.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CExceptionEvent.php

  * CExceptionEvent represents the parameter for the {@link CApplication::onException onException} event.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CExceptionEvent.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CHttpException.php

  * Error handlers may use this status code to decide how to format the error page.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CHttpException.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CModel.php

  * @property CMapIterator $iterator An iterator for traversing the items in the list.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CModel.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 			if(is_array($error))
 			{
 				foreach($error as $e)
-					$this->_errors[$attribute][]=$e;
+					$this->addError($attribute, $e);
 			}
 			else
-				$this->_errors[$attribute][]=$error;
+				$this->addError($attribute, $error);
 		}
 	}
 

demo/yii/base/CModelBehavior.php

  * @property CModel $owner The owner model that this behavior is attached to.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CModelBehavior.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  */
 class CModelBehavior extends CBehavior

demo/yii/base/CModelEvent.php

  * CModelEvent represents the event parameters needed by events raised by a model.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CModelEvent.php 2799 2011-01-01 19:31:13Z qiang.xue $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 	 */
 	public $isValid=true;
 	/**
-	 * @var CDbCrireria the query criteria that is passed as a parameter to a find method of {@link CActiveRecord}.
+	 * @var CDbCriteria the query criteria that is passed as a parameter to a find method of {@link CActiveRecord}.
 	 * Note that this property is only used by {@link CActiveRecord::onBeforeFind} event.
 	 * This property could be null.
 	 * @since 1.1.5

demo/yii/base/CModule.php

  * </pre>.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CModule.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  */
 abstract class CModule extends CComponent

demo/yii/base/CSecurityManager.php

  * @property string $validation
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CSecurityManager.php 3555 2012-02-09 10:29:44Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/CStatePersister.php

  * page state persistent method based on cache.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CStatePersister.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */

demo/yii/base/interfaces.php

  * method of every loaded application component.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * This interface must be implemented by classes supporting caching feature.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.caching
  * @since 1.0
  */
  * Objects implementing this interface must be able to be serialized and unserialized.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.caching
  * @since 1.0
  */
  * This interface must be implemented by all state persister classes (such as
  * {@link CStatePersister}.
  *
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 /**
  * IFilter is the interface that must be implemented by action filters.
  *
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 /**
  * IAction is the interface that must be implemented by controller actions.
  *
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * If this interface is implemented, the provider instance will be able
  * to intercept the remote method invocation (e.g. for logging or authentication purpose).
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * implemented in {@link CBaseController}.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * used with the {@link CWebApplication::user user application component}.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * for the current user.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
 	 * @return boolean whether the operations can be performed by this user.
 	 */
 	public function checkAccess($operation,$params=array());
+	/**
+	 * Redirects the user browser to the login page.
+	 * Before the redirection, the current URL (if it's not an AJAX url) will be
+	 * kept in {@link returnUrl} so that the user browser may be redirected back
+	 * to the current page after successful login. Make sure you set {@link loginUrl}
+	 * so that the user browser can be redirected to the specified login URL after
+	 * calling this method.
+	 * After calling this method, the current request processing will be terminated.
+	 */
+	public function loginRequired();
 }
 
 
  * An auth manager is mainly responsible for providing role-based access control (RBAC) service.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  * @since 1.0
  */
  * are defined in the behavior class and not available in the component class.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.base
  */
 interface IBehavior
  * it will be used for creating the requested widget.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.web
  * @since 1.1
  */
  * Besides providing data, they also support pagination and sorting.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: interfaces.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.web
  * @since 1.1
  */
 	 * @return CPagination the pagination object. If this is false, it means the pagination is disabled.
 	 */
 	public function getPagination();
-}
+}
+
+
+/**
+ * ILogFilter is the interface that must be implemented by log filters.
+ *
+ * A log filter preprocesses the logged messages before they are handled by a log route.
+ * You can attach classes that implement ILogFilter to {@link CLogRoute::$filter}.
+ *
+ * @version $Id$
+ * @package system.logging
+ * @since 1.1.11
+ */
+interface ILogFilter
+{
+	/**
+	 * This method should be implemented to perform actual filtering of log messages
+	 * by working on the array given as the first parameter.
+	 * Implementation might reformat, remove or add information to logged messages.
+	 * @param array $logs list of messages. Each array element represents one message
+	 * with the following structure:
+	 * array(
+	 *   [0] => message (string)
+	 *   [1] => level (string)
+	 *   [2] => category (string)
+	 *   [3] => timestamp (float, obtained by microtime(true));
+	 */
+	public function filter(&$logs);
+}
+

demo/yii/caching/CApcCache.php

  * See {@link CCache} manual for common cache operations that are supported by CApcCache.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CApcCache.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.caching
  * @since 1.0
  */
 	/**
 	 * Initializes this application component.
 	 * This method is required by the {@link IApplicationComponent} interface.
-	 * It checks the availability of memcache.
+	 * It checks the availability of APC.
 	 * @throws CException if APC cache extension is not loaded or is disabled.
 	 */
 	public function init()

demo/yii/caching/CCache.php

  * <li>{@link setValue}</li>
  * <li>{@link addValue}</li>
  * <li>{@link deleteValue}</li>
- * <li>{@link flush} (optional)</li>
+ * <li>{@link flushValues} (optional)</li>
+ * <li>{@link serializeValue} (optional)</li>
+ * <li>{@link unserializeValue} (optional)</li>
  * </ul>
  *
  * CCache also implements ArrayAccess so that it can be used like an array.
  *
  * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id: CCache.php 3515 2011-12-28 12:29:24Z mdomba $
+ * @version $Id$
  * @package system.caching
  * @since 1.0
  */
 abstract class CCache extends CApplicationComponent implements ICache, ArrayAccess
 {
 	/**
-	 * @var string a string prefixed to every cache key so that it is unique. Defaults to {@link CApplication::getId() application ID}.
+	 * @var string a string prefixed to every cache key so that it is unique. Defaults to null which means
+	 * to use the {@link CApplication::getId() application ID}. If different applications need to access the same
+	 * pool of cached data, the same prefix should be set for each of the applications explicitly.
 	 */
 	public $keyPrefix;
+	/**
+	 * @var boolean whether to md5-hash the cache key for normalization purposes. Defaults to true. Setting this property to false makes sure the cache
+	 * key will not be tampered when calling the relevant methods {@link get()}, {@link set()}, {@link add()} and {@link delete()}. This is useful if a Yii
+	 * application as well as an external application need to access the same cache pool (also see description of {@link keyPrefix} regarding this use case).
+	 * However, without normalization you should make sure the affected cache backend does support the structure (charset, length, etc.) of all the provided
+	 * cache keys, otherwise there might be unexpected behavior.
+	 * @since 1.1.11
+	 **/
+	public $hashKey=true;
+	/**
+	 * @var array|boolean the functions used to serialize and unserialize cached data. Defaults to null, meaning
+	 * using the default PHP `serialize()` and `unserialize()` functions. If you want to use some more efficient
+	 * serializer (e.g. {@link http://pecl.php.net/package/igbinary igbinary}), you may configure this property with
+	 * a two-element array. The first element specifies the serialization function, and the second the deserialization
+	 * function. If this property is set false, data will be directly sent to and retrieved from the underlying
+	 * cache component without any serialization or deserialization. You should not turn off serialization if
+	 * you are using {@link CCacheDependency cache dependency}, because it relies on data serialization.
+	 */
+	public $serializer;
 
 	/**
 	 * Initializes the application component.