Skip to content

Commit

Permalink
Merge branch 'master' of git://github.com/yiisoft/yii into 1099-gii-m…
Browse files Browse the repository at this point in the history
…odel-generator-connections
  • Loading branch information
mdomba committed Aug 17, 2012
2 parents c78f445 + 910e950 commit 3352390
Show file tree
Hide file tree
Showing 39 changed files with 327 additions and 137 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Expand Up @@ -12,6 +12,6 @@ before_script:
- psql -q -c 'CREATE DATABASE yii WITH OWNER = test;' -U postgres
- psql -q -c 'GRANT ALL PRIVILEGES ON DATABASE yii TO test;' -U postgres
- echo 'y' | pecl install memcache > ~/memcache.log || ( echo "=== MEMCACHE BUILD FAILED ==="; cat ~/memcache.log )
- echo "extension=memcache.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`
- if [ $TRAVIS_PHP_VERSION \< 5.4 ]; then echo "extension=memcache.so" >> `php --ini | grep "Loaded Configuration" | sed -e "s|.*:\s*||"`; fi

script: phpunit --colors --coverage-text --exclude-group mssql framework
8 changes: 7 additions & 1 deletion CHANGELOG
Expand Up @@ -14,9 +14,15 @@ Version 1.1.12 work in progress
- Bug #1094: CGridView with enabled history used to clear page title in case sorting or paging performed (Opera and Firefox only) (resurtm)
- Bug #1109: Fixed "js:" encoding BC-break in CHtml::ajax() and related methods introduced in 1.1.11 (samdark)
- Bug #1120: Fixed duplicate events processing in CGridView when ENTER was pressed for filtering (mdomba)
- Bug #1192: CHttpCacheFilter failed to comply with RFC 2616, section 10.3.5 (DaSourcerer)
- Bug #1207: Fixed an issue in CHtml::resolveValue() which occurs when handling tabular data input (Qiang)
- Bug #1225: Fixed the bug that $.fn.yiiGridView.getChecked was not working always if a custom CGridView::template was used (mdomba)
- Bug #1243: Fixed the bug that when using CUrlManager::addRules with $append=false rules were added in reverse order (samdark)
- Enh #243: CWebService is now able to deal with the customized WSDL generator classes, was hardcoded to the CWsdlGenerator before, added CWebService::$generatorConfig property (resurtm)
- Enh #636: CManyManyRelation now parses foreign key for the junction table data internally, and provide public interface to access it (klimov-paul)
- Enh #1099: Improved the way Gii Model generator checks for connection strings (mdomba)
- Enh #1163: CGridview does not create empty class attributes anymore (cebe)
- Chg #1099: Changed connectionId dropdown to sticky text field in Gii model generator (mdomba)
- Chg #1167: Reverted back the change to CComponent::evaluateExpression() about global function support (Qiang)

Version 1.1.11 July 29, 2012
----------------------------
Expand Down
3 changes: 2 additions & 1 deletion docs/blog/ru/comment.create.txt
Expand Up @@ -75,7 +75,8 @@ protected function newComment($post)
if($post->addComment($comment))
{
if($comment->status==Comment::STATUS_PENDING)
Yii::app()->user->setFlash('commentSubmitted','Thank you for your comment. Your comment will be posted once it is approved.');
Yii::app()->user->setFlash('commentSubmitted','Thank you for your comment.
Your comment will be posted once it is approved.');
$this->refresh();
}
}
Expand Down
6 changes: 3 additions & 3 deletions docs/guide/ru/basics.namespace.txt
Expand Up @@ -156,7 +156,7 @@ return array(

Когда пользователь пытается загрузить любой из контроллеров, для которого есть
запись в `controllerMap`, Yii сразу же подгружает указанный в ней класс. В
случае `test` Yii будет подгужать класс `\mynamespace\controllers\TestController`,
случае `test` Yii будет подгружать класс `\mynamespace\controllers\TestController`,
располагающийся в `/var/www/common/mynamespace/controllers/TestController.php`.

Стоит отметить, что код контроллера должен быть в пространстве имён:
Expand All @@ -177,8 +177,8 @@ class TestController extends \CController
}
~~~

Модули в пространтвах имён
-------------------------
Модули в пространствах имён
---------------------------

Иногда удобно использовать пространство имён для целого модуля. К примерму,
если вам необходимо использовать пространство имён `\mynamespace\modules\testmodule`,
Expand Down
2 changes: 1 addition & 1 deletion docs/guide/ru/database.ar.txt
@@ -1,7 +1,7 @@
Active Record
=============

Хотя Yii DAO справляется практически с любыми задачами, касающимися работы с БД, почти наверняка
Хотя DAO Yii справляется практически с любыми задачами, касающимися работы с БД, почти наверняка
90% времени уйдёт на написание SQL запросов, реализующих общие операции CRUD (создание, чтение, обновление и удаление).
Кроме того, код, перемешанный с SQL выражениями, поддерживать проблематично.
Для решения этих проблем мы можем воспользоваться Active Record.
Expand Down
2 changes: 1 addition & 1 deletion framework/base/CComponent.php
Expand Up @@ -601,7 +601,7 @@ public function raiseEvent($name,$event)
*/
public function evaluateExpression($_expression_,$_data_=array())
{
if(is_string($_expression_) && !function_exists($_expression_))
if(is_string($_expression_))
{
extract($_data_);
return eval('return '.$_expression_.';');
Expand Down
4 changes: 2 additions & 2 deletions framework/db/ar/CActiveRecord.php
Expand Up @@ -462,13 +462,13 @@ public function primaryKey()
*
* Each kind of related objects is defined in this method as an array with the following elements:
* <pre>
* 'varName'=>array('relationType', 'className', 'foreign_key', ...additional options)
* 'varName'=>array('relationType', 'className', 'foreignKey', ...additional options)
* </pre>
* where 'varName' refers to the name of the variable/property that the related object(s) can
* be accessed through; 'relationType' refers to the type of the relation, which can be one of the
* following four constants: self::BELONGS_TO, self::HAS_ONE, self::HAS_MANY and self::MANY_MANY;
* 'className' refers to the name of the active record class that the related object(s) is of;
* and 'foreign_key' states the foreign key that relates the two kinds of active record.
* and 'foreignKey' states the foreign key that relates the two kinds of active record.
* Note, for composite foreign keys, they can be either listed together, separated by commas or specified as an array
* in format of array('key1','key2'). In case you need to specify custom PK->FK association you can define it as
* array('fk'=>'pk'). For composite keys it will be array('fk_c1'=>'pk_с1','fk_c2'=>'pk_c2').
Expand Down
2 changes: 1 addition & 1 deletion framework/db/schema/oci/COciColumnSchema.php
Expand Up @@ -9,7 +9,7 @@
*/

/**
* COciColumnSchema class describes the column meta data of a Oracle table.
* COciColumnSchema class describes the column meta data of an Oracle table.
*
* @author Ricardo Grana <rickgrana@yahoo.com.br>
* @version $Id$
Expand Down
2 changes: 1 addition & 1 deletion framework/db/schema/oci/COciTableSchema.php
Expand Up @@ -9,7 +9,7 @@
*/

/**
* COciTableSchema represents the metadata for a Oracle table.
* COciTableSchema represents the metadata for an Oracle table.
*
* @author Ricardo Grana <rickgrana@yahoo.com.br>
* @version $Id$
Expand Down
33 changes: 0 additions & 33 deletions framework/gii/CCodeGenerator.php
Expand Up @@ -165,37 +165,4 @@ protected function prepare()
}
return $model;
}

/**
* Provides autocomplete table names
* @param string $db the database connection component id
* @param string $q the user entered term for filtering tablenames
* @return string the json array of tablenames that contains the entered term $q
*/
public function actionGetTableNames($db, $q)
{
if(Yii::app()->getRequest()->getIsAjaxRequest())
{
if(empty($db) || Yii::app()->hasComponent($db)===false || !(Yii::app()->getComponent($db) instanceof CDbConnection))
throw new CHttpException(404,'The database component is not valid.');

$model=$this->prepare();
$all=array_keys(Yii::app()->{$db}->schema->getTables());

if($q!=='')
{
$filtered=array();
foreach($all as $table)
{
if(stripos($table, $q) !== false)
$filtered[]=$table;
}
echo json_encode($filtered);
}
else
echo json_encode($all);
}
else
throw new CHttpException(404,'The requested page does not exist.');
}
}
2 changes: 1 addition & 1 deletion framework/gii/generators/crud/templates/default/_view.php
Expand Up @@ -6,7 +6,7 @@
?>
<?php echo "<?php\n"; ?>
/* @var $this <?php echo $this->getControllerClass(); ?> */
/* @var $model <?php echo $this->getModelClass(); ?> */
/* @var $data <?php echo $this->getModelClass(); ?> */
?>

<div class="view">
Expand Down
4 changes: 2 additions & 2 deletions framework/gii/generators/model/ModelCode.php
Expand Up @@ -55,7 +55,7 @@ public function requiredTemplates()
public function init()
{
if(Yii::app()->{$this->connectionId}===null)
throw new CHttpException(500,'An active database connection is required to run this generator.');
throw new CHttpException(500,'A valid database connection is required to run this generator.');
$this->tablePrefix=Yii::app()->{$this->connectionId}->tablePrefix;
parent::init();
}
Expand Down Expand Up @@ -401,7 +401,7 @@ public function validateConnectionId($attribute, $params)
{
if(Yii::app()->hasComponent($this->connectionId)===false || !(Yii::app()->getComponent($this->connectionId) instanceof CDbConnection))
{
$this->addError('connectionId','An active database connection is required to run this generator.');
$this->addError('connectionId','A valid database connection is required to run this generator.');
}
}
}
33 changes: 33 additions & 0 deletions framework/gii/generators/model/ModelGenerator.php
Expand Up @@ -3,4 +3,37 @@
class ModelGenerator extends CCodeGenerator
{
public $codeModel='gii.generators.model.ModelCode';

/**
* Provides autocomplete table names
* @param string $db the database connection component id
* @param string $q the user entered term for filtering tablenames
* @return string the json array of tablenames that contains the entered term $q
*/
public function actionGetTableNames($db, $q)
{
if(Yii::app()->getRequest()->getIsAjaxRequest())
{
if(empty($db) || Yii::app()->hasComponent($db)===false || !(Yii::app()->getComponent($db) instanceof CDbConnection))
throw new CHttpException(404,'The database component is not valid.');

$model=$this->prepare();
$all=array_keys(Yii::app()->{$db}->schema->getTables());

if($q!=='')
{
$filtered=array();
foreach($all as $table)
{
if(stripos($table, $q) !== false)
$filtered[]=$table;
}
echo json_encode($filtered);
}
else
echo json_encode($all);
}
else
throw new CHttpException(404,'The requested page does not exist.');
}
}
8 changes: 4 additions & 4 deletions framework/gii/generators/model/templates/default/model.php
Expand Up @@ -61,16 +61,16 @@ public static function model($className=__CLASS__)
{
return parent::model($className);
}
<?php if($connectionId!='db'):?>
<?php if($connectionId!='db'):?>

/**
* @return CDbConnection database connection
*/
public function getDbConnection()
{
return Yii::app()-><?php echo $connectionId ?>;
}
<?php endif?>
return Yii::app()-><?php echo $connectionId ?>;
}
<?php endif?>

/**
* @return string the associated database table name
Expand Down
2 changes: 1 addition & 1 deletion framework/messages/fa_ir/yii.php
Expand Up @@ -145,7 +145,7 @@
'No counter columns are being updated for table "{table}".' => 'هیچ counter columns در حال آپدیت برای جدول counter columns نمی باشد',
'Object configuration must be an array containing a "class" element.' => 'پیکربندی abject باید آرایه ای شامل "class" باشد',
'"{path}" is not a valid directory.' => '"{path}" دایرکتوری معتبر نیست',
'Please fix the following input errors:' => ':لطفا خطاهای ورودی زیر را تصحیح کنید',
'Please fix the following input errors:' => 'لطفا خطاهای ورودی زیر را تصحیح کنید :',
'Property "{class}.{property}" is not defined.' => 'ویژگیهای "{class}.{property}" تعریف نشده است',
'Property "{class}.{property}" is read only.' => 'ویژگیهای "{class}.{property}" فقط قابل خواندن است',
'Queue data must be an array or an object implementing Traversable.' => 'Les données de la queue doivent être un tableau ou un objet qui implémente Traversable.',
Expand Down
2 changes: 1 addition & 1 deletion framework/web/CController.php
Expand Up @@ -43,7 +43,7 @@
* </pre>
* The above example declares three filters: accessControl, ajaxOnly, COutputCache. The first two
* are method-based filters (defined in CController), which refer to filtering methods in the controller class;
* while the last refers to a object-based filter whose class is 'system.web.widgets.COutputCache' and
* while the last refers to an object-based filter whose class is 'system.web.widgets.COutputCache' and
* the 'duration' property is initialized as 300 (s).
*
* For method-based filters, a method named 'filterXYZ($filterChain)' in the controller class
Expand Down
3 changes: 2 additions & 1 deletion framework/web/CUrlManager.php
Expand Up @@ -238,7 +238,7 @@ protected function processRules()
* they will be inserted at the beginning.
* @since 1.1.4
*/
public function addRules($rules, $append=true)
public function addRules($rules,$append=true)
{
if ($append)
{
Expand All @@ -247,6 +247,7 @@ public function addRules($rules, $append=true)
}
else
{
$rules=array_reverse($rules);
foreach($rules as $pattern=>$route)
array_unshift($this->_rules, $this->createUrlRule($route,$pattern));
}
Expand Down
24 changes: 19 additions & 5 deletions framework/web/filters/CHttpCacheFilter.php
Expand Up @@ -41,7 +41,8 @@ class CHttpCacheFilter extends CFilter
*/
public $etagSeedExpression;
/**
* Http cache control headers
* Http cache control headers. Set this to an empty string in order to keep this
* header from being sent entirely.
* @var string
*/
public $cacheControl = 'max-age=3600, public';
Expand All @@ -63,11 +64,15 @@ public function preFilter($filterChain)
if($etag===false&&$lastModified===false)
return true;

if($etag)
header('ETag: '.$etag);

if(isset($_SERVER['HTTP_IF_MODIFIED_SINCE'])&&isset($_SERVER['HTTP_IF_NONE_MATCH']))
{
if($this->checkLastModified($lastModified)&&$this->checkEtag($etag))
{
$this->send304Header();
$this->sendCacheControlHeader();
return false;
}
}
Expand All @@ -76,6 +81,7 @@ public function preFilter($filterChain)
if($this->checkLastModified($lastModified))
{
$this->send304Header();
$this->sendCacheControlHeader();
return false;
}
}
Expand All @@ -84,6 +90,7 @@ public function preFilter($filterChain)
if($this->checkEtag($etag))
{
$this->send304Header();
$this->sendCacheControlHeader();
return false;
}

Expand All @@ -92,10 +99,7 @@ public function preFilter($filterChain)
if($lastModified)
header('Last-Modified: '.date('r', $lastModified));

if($etag)
header('ETag: '.$etag);

header('Cache-Control: ' . $this->cacheControl);
$this->sendCacheControlHeader();
return true;
}

Expand Down Expand Up @@ -170,6 +174,16 @@ protected function send304Header()
{
header('HTTP/1.1 304 Not Modified');
}

/**
* Sends the cache control header to the client
* @see cacheControl
* @since 1.1.12
*/
protected function sendCacheControlHeader()
{
header('Cache-Control: '.$this->cacheControl, true);
}

/**
* Generates a quoted string out of the seed
Expand Down
2 changes: 1 addition & 1 deletion framework/web/form/CFormInputElement.php
Expand Up @@ -74,7 +74,7 @@ class CFormInputElement extends CFormElement

/**
* @var string the type of this input. This can be a widget class name, a path alias of a widget class name,
* or a input type alias (text, hidden, password, textarea, file, radio, checkbox, listbox, dropdownlist, checkboxlist, or radiolist).
* or an input type alias (text, hidden, password, textarea, file, radio, checkbox, listbox, dropdownlist, checkboxlist, or radiolist).
* If a widget class, it must extend from {@link CInputWidget} or (@link CJuiInputWidget).
*/
public $type;
Expand Down
4 changes: 2 additions & 2 deletions framework/web/helpers/CHtml.php
Expand Up @@ -2138,8 +2138,8 @@ public static function resolveValue($model,$attribute)
{
if($pos===0) // [a]name[b][c], should ignore [a]
{
if(preg_match('/\](.*)/',$attribute,$matches))
$attribute=$matches[1];
if(preg_match('/\](\w+(\[.+)?)/',$attribute,$matches))
$attribute=$matches[1]; // we get: name[b][c]
if(($pos=strpos($attribute,'['))===false)
return $model->$attribute;
}
Expand Down
6 changes: 3 additions & 3 deletions framework/web/widgets/CActiveForm.php
Expand Up @@ -596,7 +596,7 @@ public function emailField($model,$attribute,$htmlOptions=array())
}

/**
* Renders an number field for a model attribute.
* Renders a number field for a model attribute.
* This method is a wrapper of {@link CHtml::activeNumberField}.
* Please check {@link CHtml::activeNumberField} for detailed information
* about the parameters for this method.
Expand All @@ -612,7 +612,7 @@ public function numberField($model,$attribute,$htmlOptions=array())
}

/**
* Renders an number field for a model attribute.
* Generates a range field for a model attribute.
* This method is a wrapper of {@link CHtml::activeRangeField}.
* Please check {@link CHtml::activeRangeField} for detailed information
* about the parameters for this method.
Expand All @@ -628,7 +628,7 @@ public function rangeField($model,$attribute,$htmlOptions=array())
}

/**
* Renders an number field for a model attribute.
* Renders a date field for a model attribute.
* This method is a wrapper of {@link CHtml::activeDateField}.
* Please check {@link CHtml::activeDateField} for detailed information
* about the parameters for this method.
Expand Down
Expand Up @@ -360,7 +360,7 @@
if (column_id.substring(column_id.length - 2) !== '[]') {
column_id = column_id + '[]';
}
this.children('.' + settings.tableClass).children('tbody').children('tr').children('td').children('input[name="' + column_id + '"]').each(function (i) {
this.find('.' + settings.tableClass).children('tbody').children('tr').children('td').children('input[name="' + column_id + '"]').each(function (i) {
if (this.checked) {
checked.push(keys.eq(i).text());
}
Expand Down

0 comments on commit 3352390

Please sign in to comment.