Permalink
Browse files

merge from 1.0

  • Loading branch information...
1 parent 7313c6e commit 2aaa9cecf630d5838e1d6f9d433efbc3b7b1a18c qiang.xue committed Feb 18, 2009
Showing with 82 additions and 28 deletions.
  1. +5 −0 CHANGELOG
  2. +18 −6 README
  3. +2 −1 docs/blog/comment.create.txt
  4. +1 −1 docs/blog/final.url.txt
  5. +1 −1 docs/blog/post.model.txt
  6. +1 −1 docs/blog/prototype.auth.txt
  7. +1 −1 docs/blog/toc.txt
  8. +0 −3 docs/guide/quickstart.first-app.txt
  9. +1 −1 framework/cli/commands/WebAppCommand.php
  10. +1 −1 framework/cli/commands/shell/ModelCommand.php
  11. +2 −2 framework/cli/views/shell/crud/controller.php
  12. 0 {testdrive → framework/cli/views/webapp}/assets/.yii
  13. BIN {testdrive → framework/cli/views/webapp}/css/bg.gif
  14. 0 {testdrive → framework/cli/views/webapp}/css/form.css
  15. 0 {testdrive → framework/cli/views/webapp}/css/main.css
  16. 0 {testdrive → framework/cli/views/webapp}/images/.yii
  17. 0 {testdrive → framework/cli/views/webapp}/index.php
  18. 0 {testdrive → framework/cli/views/webapp}/protected/.htaccess
  19. 0 {testdrive → framework/cli/views/webapp}/protected/commands/shell/.yii
  20. 0 {testdrive → framework/cli/views/webapp}/protected/components/MainMenu.php
  21. 0 {testdrive → framework/cli/views/webapp}/protected/components/UserIdentity.php
  22. 0 {testdrive → framework/cli/views/webapp}/protected/components/views/mainMenu.php
  23. 0 {testdrive → framework/cli/views/webapp}/protected/config/console.php
  24. 0 {testdrive → framework/cli/views/webapp}/protected/config/main.php
  25. 0 {testdrive → framework/cli/views/webapp}/protected/controllers/SiteController.php
  26. 0 {testdrive → framework/cli/views/webapp}/protected/extensions/.yii
  27. 0 {testdrive → framework/cli/views/webapp}/protected/messages/.yii
  28. 0 {testdrive → framework/cli/views/webapp}/protected/models/ContactForm.php
  29. 0 {testdrive → framework/cli/views/webapp}/protected/models/LoginForm.php
  30. 0 {testdrive → framework/cli/views/webapp}/protected/runtime/.yii
  31. 0 {testdrive → framework/cli/views/webapp}/protected/views/layouts/main.php
  32. 0 {testdrive → framework/cli/views/webapp}/protected/views/site/contact.php
  33. 0 {testdrive → framework/cli/views/webapp}/protected/views/site/index.php
  34. 0 {testdrive → framework/cli/views/webapp}/protected/views/site/login.php
  35. 0 {testdrive → framework/cli/views/webapp}/protected/views/system/.yii
  36. 0 {testdrive → framework/cli/views/webapp}/protected/yiic
  37. 0 {testdrive → framework/cli/views/webapp}/protected/yiic.bat
  38. 0 {testdrive → framework/cli/views/webapp}/protected/yiic.php
  39. 0 {testdrive → framework/cli/views/webapp}/themes/classic/views/.htaccess
  40. 0 {testdrive → framework/cli/views/webapp}/themes/classic/views/layouts/.yii
  41. 0 {testdrive → framework/cli/views/webapp}/themes/classic/views/site/.yii
  42. 0 {testdrive → framework/cli/views/webapp}/themes/classic/views/system/.yii
  43. +4 −4 framework/web/CController.php
  44. +8 −1 framework/web/CSort.php
  45. +37 −5 framework/web/helpers/CHtml.php
  46. 0 framework/yiic
View
@@ -10,12 +10,17 @@ Version 1.0.3 to be released
----------------------------
- Bug #127: CUploadedFile is using an undefined variable (Qiang)
- Bug #132: CMysqlSchema has a typo (Qiang)
+- Bug #133: CSort should properly quote the columns to be sorted (Qiang)
+- Bug #135: CSort::link() does not work well with labels with special chars (Qiang)
+- Bug #145: When layout property of CController is false, main layout is still applied (Qiang)
- Bug: CHttpRequest.hostInfo may give wrong port number (Qiang)
- Bug: CHtml::activeListBox does not work when multiple selection is needed (Qiang)
- Bug: Inconsistency in timezone of log messages for different log routes (Qiang)
- Bug: Script file registered for POS_BEGIN is rendered twice (Qiang)
- New #117: Added count() support to relational AR (Qiang)
- New #136: Added support to CWebUser to allow directly accessing persistent properties (Qiang)
+- New #137: yiic model command should only set a column as required when it does not have default value (Qiang)
+- New #138: Added support to specify additional attributes for OPTION tags (Qiang)
- New: Upgraded jquery to 1.3.1 (Qiang)
- New: Upgraded jquery star rating to 2.61 (Qiang)
- New: Added skeleton application and refactored 'yiic webapp' command (Qiang)
View
24 README
@@ -1,19 +1,18 @@
-
- Yii Web Programming Framework
- =============================
+Yii Web Programming Framework
+=============================
Thank you for choosing Yii - a high-performance component-based PHP framework.
INSTALLATION
------------
+
Please make sure the release file is unpacked under a Web-accessible
directory. You shall see the following files and directories:
demos/ demos
framework/ framework source files
requirements/ requirement checker
- testdrive/ a skeleton Yii application
CHANGELOG describing changes in every Yii release
LICENSE license of Yii
README this file
@@ -22,6 +21,7 @@ directory. You shall see the following files and directories:
REQUIREMENTS
------------
+
The minimum requirement by Yii is that your Web server supports
PHP 5.1.0 or above. Yii has been tested with Apache HTTP server
on Windows and Linux operating systems.
@@ -34,15 +34,27 @@ the requirements by Yii, assuming "YiiPath" is where Yii is installed:
QUICK START
-----------
-Yii comes with a skeleton application located under the directory
-"testdrive". It is a good starting point for your application.
+
+Yii comes with a command line tool called "yiic" that can create
+a skeleton Yii application for you to start with.
+
+On command line, type in the following commands:
+
+ $ cd YiiPath/framework (Linux)
+ cd YiiPath\framework (Windows)
+
+ $ ./yiic webapp ../testdrive (Linux)
+ yiic webapp ..\testdrive (Windows)
+
+The new Yii application will be created at "YiiPath/testdrive".
You can access it with the following URL:
http://hostname/YiiPath/testdrive/index.php
WHAT's NEXT
-----------
+
Please visit the project website for tutorials, class reference
and join discussions with other Yii users.
@@ -59,7 +59,8 @@ protected function newComment($post)
$comment->validate('insert');
else if(isset($_POST['submitComment']) && $comment->save())
{
- Yii::app()->user->setFlash('commentSubmitted','Thank you...'); $this->refresh();
+ Yii::app()->user->setFlash('commentSubmitted','Thank you...');
+ $this->refresh();
}
}
return $comment;
View
@@ -7,7 +7,7 @@ The URLs linking various pages of our blog application currently look ugly. For
/index.php?r=post/show&id=1
~~~
-In this section, we describe how to beautifying these URLs and make them SEO-friendly. We goal is to be able to use the following URLs in the application:
+In this section, we describe how to beautifying these URLs and make them SEO-friendly. Our goal is to be able to use the following URLs in the application:
* `/index.php/tag/yii`: leads to the page showing a list of posts with tag `yii`;
* `/index.php/posts`: leads to the page showing the latest posts;
View
@@ -31,7 +31,7 @@ public function rules()
}
~~~
-In the above, we specify that the `title`, `length` and `max` attributes are required; the length of `title` should not exceed 128; the `status` attribute value should be 0 (draft), 1 (published) or 2 (archived); and the `tags` attribute should only contain word characters and commas. All other attributes (e.g. `id`, `createTime`) will not be validated because their values do not come from user input.
+In the above, we specify that the `title`, `content` and `status` attributes are required; the length of `title` should not exceed 128; the `status` attribute value should be 0 (draft), 1 (published) or 2 (archived); and the `tags` attribute should only contain word characters and commas. All other attributes (e.g. `id`, `createTime`) will not be validated because their values do not come from user input.
After making these changes, we can visit the post creation page again to verify that the new validation rules are taking effect.
@@ -79,6 +79,6 @@ switch($identity->errorCode)
> Info: People often get confused about identity and the `user` application component. The former represents a way of performing authentication, while the latter is used to represent the information related with the current user. An application can only have one `user` component, but it can have one or several identity classes, depending on what kind of authentication it supports. Once authenticated, an identity instance may pass its state information to the `user` component so that they are globally accessible via `user`.
-To test the modified `UserIdentity` class, we can browse the URL `http://www.example.com/blog/index.php` and try logging in with the username and password that we store in the `User` table. If we use the database provided by the [blog demo](http://www.yiiframework.com/demos/blog/], we should be able to login with username `demo` and password `demo`. Note that this blog system does not provide the user management feature. As a result, a user cannot change his account or create a new one through the Web interface. The user management feature may be considered as a future enhancement to the blog application.
+To test the modified `UserIdentity` class, we can browse the URL `http://www.example.com/blog/index.php` and try logging in with the username and password that we store in the `User` table. If we use the database provided by the [blog demo](http://www.yiiframework.com/demos/blog/), we should be able to login with username `demo` and password `demo`. Note that this blog system does not provide the user management feature. As a result, a user cannot change his account or create a new one through the Web interface. The user management feature may be considered as a future enhancement to the blog application.
<div class="revision">$Id$</div>
View
@@ -21,7 +21,7 @@
- [Creating and Displaying Comments](comment.create)
- [Managing Comments](comment.admin)
-* Porlets
+* Portlets
- [Establishing Portlet Architecture](portlet.base)
- [Creating User Menu Portlet](portlet.menu)
- [Creating Login Portlet](portlet.login)
@@ -26,9 +26,6 @@ This will create a skeleton Yii application under the directory
`WebRoot/testdrive`. The application has a directory structure that is
is needed by most Yii applications.
-> Tip: Starting from version 1.0.3, a testdrive application is included
-> directly under the directory `YiiRoot/testdrive`.
-
Without writing a single line of code, we can test drive our first Yii
application by accessing the following URL in a Web browser:
@@ -54,7 +54,7 @@ public function run($args)
echo "Create a Web application under '$path'? [Yes|No] ";
if(!strncasecmp(trim(fgets(STDIN)),'y',1))
{
- $sourceDir=realpath(dirname(__FILE__).'/../../../testdrive');
+ $sourceDir=realpath(dirname(__FILE__).'/../views/webapp');
if($sourceDir===false)
die('Unable to locate the source directory.');
$list=$this->buildFileList($sourceDir,$path);
@@ -101,7 +101,7 @@ public function generateModel($source,$params)
{
if($column->isPrimaryKey && $table->sequenceName!==null || $column->isForeignKey)
continue;
- if(!$column->allowNull)
+ if(!$column->allowNull && $column->defaultValue!==null)
$required[]=$column->name;
if($column->type==='integer')
$integers[]=$column->name;
@@ -113,7 +113,7 @@ public function actionList()
{
$criteria=new CDbCriteria;
- $pages=new CPagination({ModelClass}::model()->count());
+ $pages=new CPagination({ModelClass}::model()->count($criteria));
$pages->pageSize=self::PAGE_SIZE;
$pages->applyLimit($criteria);
@@ -134,7 +134,7 @@ public function actionAdmin()
$criteria=new CDbCriteria;
- $pages=new CPagination({ModelClass}::model()->count());
+ $pages=new CPagination({ModelClass}::model()->count($criteria));
$pages->pageSize=self::PAGE_SIZE;
$pages->applyLimit($criteria);
File renamed without changes.
File renamed without changes
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -70,9 +70,9 @@ class CController extends CBaseController
const STATE_INPUT_NAME='YII_PAGE_STATE';
/**
- * @var mixed the name of the layout to be applied to this controller's views.
+ * @var string the name of the layout to be applied to this controller's views.
* Defaults to null, meaning the {@link CWebApplication::layout application layout}
- * is used. If false, no layout will be applied.
+ * is used. If it is an empty string, no layout will be applied.
*/
public $layout;
/**
@@ -509,7 +509,7 @@ public function render($view,$data=null,$return=false)
{
$output=$this->renderPartial($view,$data,true);
- if(($layout=$this->layout)==null)
+ if(($layout=$this->layout)===null)
$layout=Yii::app()->layout;
if(!empty($layout) && ($layoutFile=$this->getLayoutFile($layout))!==false)
@@ -533,7 +533,7 @@ public function render($view,$data=null,$return=false)
*/
public function renderText($text,$return=false)
{
- if(($layout=$this->layout)==null)
+ if(($layout=$this->layout)===null)
$layout=Yii::app()->layout;
if(!empty($layout) && ($layoutFile=$this->getLayoutFile($layout))!==false)
View
@@ -122,9 +122,16 @@ public function applyOrder($criteria)
$order=$this->defaultOrder;
else
{
+ $schema=CActiveRecord::model($this->modelClass)->getDbConnection()->getSchema();
$orders=array();
foreach($directions as $attribute=>$descending)
+ {
+ if(($pos=strpos($attribute,'.'))!==false)
+ $attribute=$schema->quoteTableName(substr($attribute,0,$pos)).'.'.$schema->quoteColumnName(substr($attribute,$pos+1));
+ else
+ $attribute=$schema->quoteColumnName($attribute);
$orders[]=$descending?$attribute.' DESC':$attribute;
+ }
$order=implode(', ',$orders);
}
@@ -280,6 +287,6 @@ protected function validateAttribute($attribute)
*/
protected function createLink($attribute,$label,$url,$htmlOptions)
{
- return CHtml::link(CHtml::encode($label),$url,$htmlOptions);
+ return CHtml::link($label,$url,$htmlOptions);
}
}
@@ -546,7 +546,9 @@ public static function checkBox($name,$checked=false,$htmlOptions=array())
* Generates a drop down list.
* @param string the input name
* @param string the selected value
- * @param array data for generating the list options (value=>display)
+ * @param array data for generating the list options (value=>display).
+ * You may use {@link listData} to generate this data.
+ * Please refer to {@link listOptions} on how this data is used to generate the list options.
* @param array additional HTML attributes. Besides normal HTML attributes, a few special
* attributes are also recognized (see {@link clientChange} for more details.)
* @return string the generated drop down list
@@ -569,6 +571,8 @@ public static function dropDownList($name,$select,$data,$htmlOptions=array())
* @param string the input name
* @param string the selected value
* @param array data for generating the list options (value=>display)
+ * You may use {@link listData} to generate this data.
+ * Please refer to {@link listOptions} on how this data is used to generate the list options.
* @param array additional HTML attributes. Besides normal HTML attributes, a few special
* attributes are also recognized (see {@link clientChange} for more details.)
* @return string the generated list box
@@ -1024,6 +1028,8 @@ public static function activeCheckBox($model,$attribute,$htmlOptions=array())
* @param CModel the data model
* @param string the attribute
* @param array data for generating the list options (value=>display)
+ * You may use {@link listData} to generate this data.
+ * Please refer to {@link listOptions} on how this data is used to generate the list options.
* @param array additional HTML attributes. Besides normal HTML attributes, a few special
* attributes are also recognized (see {@link clientChange} for more details.)
* @return string the generated drop down list
@@ -1054,6 +1060,8 @@ public static function activeDropDownList($model,$attribute,$data,$htmlOptions=a
* @param CModel the data model
* @param string the attribute
* @param array data for generating the list options (value=>display)
+ * You may use {@link listData} to generate this data.
+ * Please refer to {@link listOptions} on how this data is used to generate the list options.
* @param array additional HTML attributes. Besides normal HTML attributes, a few special
* attributes are also recognized (see {@link clientChange} for more details.)
* @return string the generated list box
@@ -1288,10 +1296,21 @@ protected static function activeInputField($type,$model,$attribute,$htmlOptions)
* <ul>
* <li>prompt: string, specifies the prompt text shown as the first list option. Its value is empty.</li>
* <li>empty: string, specifies the text corresponding to empty selection. Its value is empty.</li>
+ * <li>options: array, specifies additional attributes for each OPTION tag.
+ * The array keys must be the option values, and the array values are the extra
+ * OPTION tag attributes in the name-value pairs. For example,
+ * <pre>
+ * array(
+ * 'value1'=>array('disabled'=>true, 'label'=>'value 1'),
+ * 'value2'=>array('label'=>'value 2'),
+ * );
+ * </pre>
+ * This option has been available since version 1.0.3.
+ * </li>
* </ul>
* @return string the generated list options
*/
- protected static function listOptions($selection,$listData,&$htmlOptions)
+ public static function listOptions($selection,$listData,&$htmlOptions)
{
$content='';
if(isset($htmlOptions['prompt']))
@@ -1305,6 +1324,14 @@ protected static function listOptions($selection,$listData,&$htmlOptions)
unset($htmlOptions['empty']);
}
+ if(isset($htmlOptions['options']))
+ {
+ $options=$htmlOptions['options'];
+ unset($htmlOptions['options']);
+ }
+ else
+ $options=array();
+
foreach($listData as $key=>$value)
{
if(is_array($value))
@@ -1314,10 +1341,15 @@ protected static function listOptions($selection,$listData,&$htmlOptions)
$content.=self::listOptions($selection,$value,$dummy);
$content.='</optgroup>'."\n";
}
- else if(!is_array($selection) && !strcmp($key,$selection) || is_array($selection) && in_array($key,$selection))
- $content.='<option value="'.self::encode((string)$key).'" selected="selected">'.self::encode((string)$value)."</option>\n";
else
- $content.='<option value="'.self::encode((string)$key).'">'.self::encode((string)$value)."</option>\n";
+ {
+ $attributes=array('value'=>(string)$key);
+ if(!is_array($selection) && !strcmp($key,$selection) || is_array($selection) && in_array($key,$selection))
+ $attributes['selected']='selected';
+ if(isset($options[$key]))
+ $attributes=array_merge($attributes,$options[$key]);
+ $content.=CHtml::tag('option',$attributes,self::encode((string)$value))."\n";
+ }
}
return $content;
}
View
0 framework/yiic 100644 → 100755
No changes.

0 comments on commit 2aaa9ce

Please sign in to comment.