The Yii framework continues to evolve in the most active way, and now a new version 1.1.3 has appeared. What kind of framework it is, and what it is eaten with - read here , and who in the course - get acquainted with the list of innovations.
Now, when creating a CActiveDataProvider class object , the first parameter to the constructor is to transfer not just the name of the AR class, but the AR finder object. For example, Post :: model (), Post :: model () -> published ().
From now on, the CActiveRecord :: beforeFind event will be triggered in all cases, including associated models with deferred (lazy) and eager (eager) loading.
Improved the performance of defaultParams in CUrlManager . This property was added back in 1.0.8 and is used in the description of the URL generation rules. When the rule is triggered, the parameters from this property are added to $ _GET. Now also when creating a link (for example, using CController :: createUrl () ), if a parameter is set that matches any parameter from defaultParams , then this parameter is not specified additionally in the created link.
When using parameterized host names , relative links (URLs) will now be created if the host name specified in the rule matches the current one.
CSecurityManager
The ability to specify an algorithm for encryption / decryption and hashing has been added to CSecurityManager . New properties hashAlgorithm and cryptAlgorithm are responsible for this. Now you can use not only the usual md5 or sha1, but many other algorithms.
CSort
The CSort :: defaultOrder property can now use the virtual attributes defined in CSort :: attributes . This should be done using an array, where the keys of the array are the names of the virtual attributes, and the values ββof the array are boolean values ββ(true or false), indicating whether the sorting should be decreasing.
Also in CSort :: attributes there is a new option 'default' (besides 'asc', 'desc' and 'label'), which dictates by ascending or descending order to be sorted when the user clicked on the appropriate sorting link for the first time. The option can be 'asc' or 'desc.
And in CSort :: attributes , next to other virtual attributes, you can insert the element '*', and all attributes of the AR-class specified in CSort :: modelClass will automatically become available for sorting.
CHtml
In the CHtml :: errorSummary () settings, the 'firstError' option has been added, which allows to display only the first error message for each attribute of the model.
And the form fields (in CHtml ) for entering text and password now automatically generate the maxlength attribute according to the model rules.
Themes and Skins
Now in the application configuration, you can customize default values ββfor widgets. Read more about this in the skins documentation .
Improved work with views to support the use of graphic themes of the application in the module. In this regard, a new syntax for the names of view-files:
"// layouts / main" refers to "protected / views / layouts / main.php" (if "protected" is the base directory of the application)
"/ layouts / main" indicates "protected / modules / abc / views / layouts / main.php" (if "abc" is the current working module. If not, then this is the same as "// layouts / main ")
βMainβ points to the view file located in the view directory of the current controller or in the directory of the current layout.
In CActiveForm :: clientOptions , the options beforeValidate, afterValidate, beforeValidateAttribute and afterValidateAttribute are added to specify the js functions that will be called before and after validating the form using ajax.
In the CFileHelper :: getMimeType () and getMimeTypeByExtension () functions, a second optional parameter was added that allows you to specify the path to the file that contains all the necessary information about MIME types.
Two new tokens {page} and {pages} have been added to CBaseListView :: summaryText , which are replaced by the current page number and the total number of pages respectively.
Added translation into Latvian. Now Yii includes translations into 20 (!) Languages.
Actions upon transition from version 1.1.2
If you are using skins for widgets, you must always set the property 'widgetFactory' to the property 'enableSkin' to true. Also, if you configured the 'widgets' property for the previous version, now you need to rename it to 'skinnableWidgets'.
CAutoComplete was abolished and now you need to use CJuiAutoComplete .
Now you can not reuse CActiveFinder . For example, if there is a code: $finder = Post::model()->with('comments'); $posts1 = $finder->findAll(); β¦ $posts2 = $finder->findAll(); then it needs to be rewritten as follows: $posts1 = Post::model()->with('comments'); β¦ $posts2 = Post::model()->with('comments');