Permalink
Browse files

merge from 1.0.

  • Loading branch information...
1 parent 8421cb2 commit a6be33eca57d245b7e5624d53c9091d61d353ada qiang.xue committed Jan 24, 2009
View
@@ -18,6 +18,8 @@ Version 1.0.2 to be released
- New #92: Empty error messages in models are handled better when being displayed (Qiang)
- New #93: Changed CLinkPager and CListPager so that the messages are internationalized (Qiang)
- New #95: Added an option to CHtml::activeCheckBox() to define default value if unchecked (Qiang)
+- New #98: Added support to translate messages in different plural forms. Added CChoiceFormat. (Qiang)
+- New #104: Added support to encode traversable objects using JSON (Qiang)
- New: Added CActiveRecord::getRelated() (Qiang)
- New: Added 'return' option to HTML options in CHtml (Qiang)
- New: Refactored CSS-dependent widgets by adding registerCssFile static methods (Qiang)
@@ -34,6 +36,7 @@ Version 1.0.2 to be released
- New: Added a set of new events to CActiveRecord and CFormModel (Qiang)
- New: Added CModel::getValidatorsForAttribute (Qiang)
- New: Added CHtml::activeLabelEx and added 'required' option to CHtml::label (Qiang)
+- New: Added array access support to CFormModel and CActiveRecord (Qiang)
Version 1.0.1 January 4, 2009
-----------------------------
View
@@ -0,0 +1 @@
+deny from all
@@ -88,7 +88,8 @@ protected function minifyYii($entryScript)
{
ob_start();
$this->runRequest($entryScript);
- $this->runRequest($entryScript,array('r'=>'post/list'));
+ $_SERVER['REQUEST_URI']='/index.php';
+ $this->runRequest($entryScript,array('r'=>'post'));
ob_end_clean();
}
catch(CException $e)
@@ -5,7 +5,7 @@ class PostController extends CController
/**
* @var string specifies the default action to be 'list'.
*/
- public $defaultAction='list';
+ public $defaultAction='create';
/**
* Specifies the action filters.
@@ -29,7 +29,7 @@ public function accessRules()
{
return array(
array('deny', // deny access to CUD for guest users
- 'actions'=>array('create', 'update', 'delete'),
+ 'actions'=>array('delete'),
'users'=>array('?'),
),
);
@@ -31,7 +31,7 @@ Using `yiilite.php`
When the [PHP APC extension](http://www.php.net/manual/en/book.apc.php) is
enabled, we can replace `yii.php` with a different Yii bootstrap file named
-`yiilite.php` to further boost the performance of an Yii-power application.
+`yiilite.php` to further boost the performance of an Yii-powered application.
The file `yiilite.php` comes with every Yii release. It is the result of
merging some commonly used Yii class files. Both comments and trace
@@ -41,7 +41,10 @@ execution of trace statements.
Note, using `yiilite.php` without APC may actually reduce performance,
because `yiilite.php` contains some classes that are not necessarily used
-in every request and would take extra parsing time.
+in every request and would take extra parsing time. It is observed that
+using `yiilite.php` is slower with some server configurations, even when
+APC is turned on. The best way to judge whether to use `yiilite.php` or not
+is to run a benchmark using the included `hello world` demo.
Using Caching Techniques
------------------------
View
@@ -380,11 +380,18 @@ public static function powered()
/**
* Translates a message to the {@link CApplication::getLanguage application language}.
+ * Starting from version 1.0.2, this method supports choice format (see {@link CChoiceFormat}),
+ * i.e., the message returned will be chosen from a few candidates according to the given
+ * number value. This feature is mainly used to solve plural format issue in case
+ * a message has different plural forms in some languages.
* @param string message category. Please use only word letters. Note, category 'yii' is
* reserved for Yii framework core code use. See {@link CPhpMessageSource} for
* more interpretation about message category.
* @param string the original message
* @param array parameters to be applied to the message using <code>strtr</code>.
+ * Starting from version 1.0.2, the first parameter can be a number without key.
+ * And in this case, the method will call {@link CChoiceFormat::format} to choose
+ * an appropriate message translation.
* @param string 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.
@@ -400,6 +407,13 @@ public static function t($category,$message,$params=array(),$source=null)
if(($source=self::$_app->getComponent($source))!==null)
$message=$source->translate($category,$message);
}
+ if($params===array())
+ return $message;
+ if(isset($params[0])) // number choice
+ {
+ $message=CChoiceFormat::format($message,$params[0]);
+ unset($params[0]);
+ }
return $params!==array() ? strtr($message,$params) : $message;
}
@@ -434,9 +448,13 @@ public static function t($category,$message,$params=array(),$source=null)
'CAttributeCollection' => '/collections/CAttributeCollection.php',
'CConfiguration' => '/collections/CConfiguration.php',
'CList' => '/collections/CList.php',
+ 'CListIterator' => '/collections/CListIterator.php',
'CMap' => '/collections/CMap.php',
+ 'CMapIterator' => '/collections/CMapIterator.php',
'CQueue' => '/collections/CQueue.php',
+ 'CQueueIterator' => '/collections/CQueueIterator.php',
'CStack' => '/collections/CStack.php',
+ 'CStackIterator' => '/collections/CStackIterator.php',
'CTypedList' => '/collections/CTypedList.php',
'CConsoleApplication' => '/console/CConsoleApplication.php',
'CConsoleCommand' => '/console/CConsoleCommand.php',
@@ -465,6 +483,7 @@ public static function t($category,$message,$params=array(),$source=null)
'CSqliteColumnSchema' => '/db/schema/sqlite/CSqliteColumnSchema.php',
'CSqliteCommandBuilder' => '/db/schema/sqlite/CSqliteCommandBuilder.php',
'CSqliteSchema' => '/db/schema/sqlite/CSqliteSchema.php',
+ 'CChoiceFormat' => '/i18n/CChoiceFormat.php',
'CDateFormatter' => '/i18n/CDateFormatter.php',
'CDbMessageSource' => '/i18n/CDbMessageSource.php',
'CGettextMessageSource' => '/i18n/CGettextMessageSource.php',
@@ -486,6 +505,7 @@ public static function t($category,$message,$params=array(),$source=null)
'CDateParser' => '/utils/CDateParser.php',
'CFileHelper' => '/utils/CFileHelper.php',
'CMarkdownParser' => '/utils/CMarkdownParser.php',
+ 'CPropertyValue' => '/utils/CPropertyValue.php',
'CTimestamp' => '/utils/CTimestamp.php',
'CVarDumper' => '/utils/CVarDumper.php',
'CCaptchaValidator' => '/validators/CCaptchaValidator.php',
@@ -515,6 +535,7 @@ public static function t($category,$message,$params=array(),$source=null)
'CHttpCookie' => '/web/CHttpCookie.php',
'CHttpRequest' => '/web/CHttpRequest.php',
'CHttpSession' => '/web/CHttpSession.php',
+ 'CHttpSessionIterator' => '/web/CHttpSessionIterator.php',
'COutputEvent' => '/web/COutputEvent.php',
'CPagination' => '/web/CPagination.php',
'CSort' => '/web/CSort.php',
@@ -69,6 +69,13 @@
* the language that the messages and view files are in. Defaults to 'en_us' (US English).
*/
public $sourceLanguage='en_us';
+ /**
+ * @var array the behaviors that should be attached to the application.
+ * The behaviors will be attached to the application when {@link init} is called.
+ * Please refer to {@link CModel::behaviors} on how to specify the value of this property.
+ * @since 1.0.2
+ */
+ public $behaviors=array();
private $_id;
private $_basePath;
@@ -116,6 +123,7 @@ public function __construct($config=null)
*/
protected function init()
{
+ $this->attachBehaviors($this->behaviors);
$this->preloadComponents();
}
@@ -89,15 +89,15 @@ class CComponent
private $_m;
/**
- * Returns a property value or an event handler list by property or event name.
+ * Returns a property value, an event handler list or a behavior based on its name.
* Do not call this method. This is a PHP magic method that we override
* to allow using the following syntax to read a property or obtain event handlers:
* <pre>
* $value=$component->propertyName;
* $handlers=$component->eventName;
* </pre>
* @param string the property name or event name
- * @return mixed the property value or event handlers attached to the event
+ * @return mixed the property value, event handlers attached to the event, or the named behavior (since version 1.0.2)
* @throws CException if the property or event is not defined
* @see __set
*/
@@ -114,6 +114,8 @@ public function __get($name)
$this->_e[$name]=new CList;
return $this->_e[$name];
}
+ else if(isset($this->_m[$name]))
+ return $this->_m[$name];
else
throw new CException(Yii::t('yii','Property "{class}.{property}" is not defined.',
array('{class}'=>get_class($this), '{property}'=>$name)));
@@ -212,10 +214,20 @@ public function __call($name,$parameters)
return call_user_func_array(array($object,$name),$parameters);
}
}
- throw new CException('yii','{class} does not have a method named {name}.',
- array('{class}'=>get_class($this), '{name}'=>$name));
+ throw new CException(Yii::t('yii','{class} does not have a method named "{name}".',
+ array('{class}'=>get_class($this), '{name}'=>$name)));
}
+ /**
+ * Returns the named behavior object.
+ * @param string the behavior name
+ * @return IBehavior the behavior object, or null if the behavior does not exist
+ * @since 1.0.2
+ */
+ public function asa($behavior)
+ {
+ return isset($this->_m[$behavior]) ? $this->_m[$behavior] : null;
+ }
/**
* Attaches a list of behaviors to the component.
@@ -582,153 +594,3 @@ public function __construct($sender=null)
class CEnumerable
{
}
-
-
-/**
- * CPropertyValue is a helper class that provides static methods to convert component property values to specific types.
- *
- * CPropertyValue is commonly used in component setter methods to ensure
- * the new property value is of the specific type.
- * For example, a boolean-typed property setter method would be as follows,
- * <pre>
- * public function setPropertyName($value)
- * {
- * $value=CPropertyValue::ensureBoolean($value);
- * // $value is now of boolean type
- * }
- * </pre>
- *
- * Properties can be of the following types with specific type conversion rules:
- * <ul>
- * <li>string: a boolean value will be converted to 'true' or 'false'.</li>
- * <li>boolean: string 'true' (case-insensitive) will be converted to true,
- * string 'false' (case-insensitive) will be converted to false.</li>
- * <li>integer</li>
- * <li>float</li>
- * <li>array: string starting with '(' and ending with ')' will be considered as
- * as an array expression and will be evaluated. Otherwise, an array
- * with the value to be ensured is returned.</li>
- * <li>object</li>
- * <li>enum: enumerable type, represented by an array of strings.</li>
- * </ul>
- *
- * @author Qiang Xue <qiang.xue@gmail.com>
- * @version $Id$
- * @package system.base
- * @since 1.0
- */
-class CPropertyValue
-{
- /**
- * Converts a value to boolean type.
- * Note, string 'true' (case-insensitive) will be converted to true,
- * string 'false' (case-insensitive) will be converted to false.
- * If a string represents a non-zero number, it will be treated as true.
- * @param mixed the value to be converted.
- * @return boolean
- */
- public static function ensureBoolean($value)
- {
- if (is_string($value))
- return !strcasecmp($value,'true') || $value!=0;
- else
- return (boolean)$value;
- }
-
- /**
- * Converts a value to string type.
- * Note, a boolean value will be converted to 'true' if it is true
- * and 'false' if it is false.
- * @param mixed the value to be converted.
- * @return string
- */
- public static function ensureString($value)
- {
- if (is_bool($value))
- return $value?'true':'false';
- else
- return (string)$value;
- }
-
- /**
- * Converts a value to integer type.
- * @param mixed the value to be converted.
- * @return integer
- */
- public static function ensureInteger($value)
- {
- return (integer)$value;
- }
-
- /**
- * Converts a value to float type.
- * @param mixed the value to be converted.
- * @return float
- */
- public static function ensureFloat($value)
- {
- return (float)$value;
- }
-
- /**
- * Converts a value to array type. If the value is a string and it is
- * in the form (a,b,c) then an array consisting of each of the elements
- * will be returned. If the value is a string and it is not in this form
- * then an array consisting of just the string will be returned. If the value
- * is not a string then
- * @param mixed the value to be converted.
- * @return array
- */
- public static function ensureArray($value)
- {
- if(is_string($value))
- {
- $value = trim($value);
- $len = strlen($value);
- if ($len >= 2 && $value[0] == '(' && $value[$len-1] == ')')
- {
- eval('$array=array'.$value.';');
- return $array;
- }
- else
- return $len>0?array($value):array();
- }
- else
- return (array)$value;
- }
-
- /**
- * Converts a value to object type.
- * @param mixed the value to be converted.
- * @return object
- */
- public static function ensureObject($value)
- {
- return (object)$value;
- }
-
- /**
- * Converts a value to enum type.
- *
- * This method checks if the value is of the specified enumerable type.
- * A value is a valid enumerable value if it is equal to the name of a constant
- * in the specified enumerable type (class).
- * For more details about enumerable, see {@link CEnumerable}.
- *
- * @param string the enumerable value to be checked.
- * @param string the enumerable class name (make sure it is included before calling this function).
- * @return string the valid enumeration value
- * @throws CException if the value is not a valid enumerable value
- */
- public static function ensureEnum($value,$enumType)
- {
- static $types=array();
- if(!isset($types[$enumType]))
- $types[$enumType]=new ReflectionClass($enumType);
- if($types[$enumType]->hasConstant($value))
- return $value;
- else
- throw new CException(Yii::t('yii','Invalid enumerable value "{value}". Please make sure it is among ({enum}).',
- array('{value}'=>$value, '{enum}'=>implode(', ',$types[$enumType]->getConstants()))));
- }
-}
Oops, something went wrong.

0 comments on commit a6be33e

Please sign in to comment.