2013-04-13 13:45:21 -04:00
|
|
|
#Yii session offset
|
|
|
|
snippet yse
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->session['${0}'];
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii renderDynamic
|
|
|
|
snippet yrd
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->renderDynamic('${0:callback}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii set cache
|
|
|
|
snippet ycas
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->cache->set('${1:key}', ${2:value}, ${3:expire}, new C${4:}CacheDependency(${0}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Add cache
|
|
|
|
snippet ycad
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->cache->add('${1:key}', ${2:value}, ${3:expire}, new C${4}CacheDependency(${0}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii register CSS file
|
|
|
|
snippet yregcf
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->clientScript->registerCssFile('${0:file}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii requestType
|
|
|
|
snippet yreqtype
|
2013-07-17 19:06:05 -04:00
|
|
|
Yii::app()->request->requestType
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii isAjaxRequest
|
|
|
|
snippet yisajax
|
2013-07-17 19:06:05 -04:00
|
|
|
Yii::app()->request->isAjaxRequest
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii translate
|
|
|
|
snippet yt
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::t('${1:category}', '${2:message}',array(${0}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii register CSS
|
|
|
|
snippet yregc
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->clientScript->registerCss('${1:id}', '${0}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii log
|
|
|
|
snippet ylog
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::log('${1:msg}', '${0:info}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii userHostAddress
|
|
|
|
snippet yuserip
|
2013-07-17 19:06:05 -04:00
|
|
|
YYii::app()->request->userHostAddress
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii register script file
|
|
|
|
snippet yregsf
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->clientScript->registerScriptFile('${1:scriptUrl}', CClientScript::POS_${0:END});
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii CLinkPager
|
|
|
|
snippet ylinkpager
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->widget('CLinkPager', array('pages'=>$pages,'header'=>'${0}'}))
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii CJSON::encode
|
|
|
|
snippet yjec
|
2013-11-16 14:45:48 -05:00
|
|
|
CJSON::encode(${0:text});
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#CActiveDataProvider
|
|
|
|
snippet yadp
|
|
|
|
$dataProvider = new CActiveDataProvider('${1}', array(
|
|
|
|
'criteria' => array(
|
|
|
|
'condition' => '${2}',
|
|
|
|
'order' => '${3}',
|
|
|
|
'with' => array('${4}')
|
|
|
|
),
|
|
|
|
//'pagination' => false,
|
|
|
|
'pagination' => array(
|
|
|
|
'pageSize'=>${5},
|
|
|
|
),
|
|
|
|
));
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
// $dataProvider->getData() will return a list of Post objects
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii renderDynamic internal
|
|
|
|
snippet yrdi
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->renderDynamic('${1:callback}', array('${2:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii register script
|
|
|
|
snippet yregs
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->clientScript->registerScript('${1:id}', '${2}', CClientScript::POS_${0:READY});
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Flush cache
|
|
|
|
snippet ycaf
|
2013-07-17 19:06:05 -04:00
|
|
|
Yii::app()->cache->flush();
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Yii::app()->request->cookies
|
|
|
|
snippet yco
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->request->cookies['${0}']
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii user->
|
|
|
|
snippet yuser
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->user->
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii refresh
|
|
|
|
snippet yrf
|
2013-07-17 19:06:05 -04:00
|
|
|
$this->refresh();
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii import
|
|
|
|
snippet yimp
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::import('${0}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii trace
|
|
|
|
snippet ytrace
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::trace('${0:msg}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii params
|
|
|
|
snippet ypar
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->params['${0}']
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii isPostRequest
|
|
|
|
snippet yispost
|
2013-07-17 19:06:05 -04:00
|
|
|
Yii::app()->request->isPostRequest
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii IF isAjaxRequest
|
|
|
|
snippet yifisajax
|
|
|
|
if(Yii::app()->request->isAjaxRequest == TRUE)
|
|
|
|
{
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-07-17 19:06:05 -04:00
|
|
|
}
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Yii::app()->cache->delete
|
|
|
|
snippet ydelcache
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->cache->delete('${0:key}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii render view
|
|
|
|
snippet yr
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->render('${1:view}',array('${2:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii redirect
|
|
|
|
snippet yre
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->redirect(array('${1:controller}/${0:action}'));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Get cache
|
|
|
|
snippet ycag
|
2013-11-16 14:45:48 -05:00
|
|
|
Yii::app()->cache->get('${0:key}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii render text
|
|
|
|
snippet yrt
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->renderText('${0}');
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii render partial
|
|
|
|
snippet yrp
|
2013-11-16 14:45:48 -05:00
|
|
|
$this->renderPartial('${1:view}',array('${2:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#----------------Yii Model-----------------------------
|
|
|
|
#Yii Model count
|
|
|
|
snippet ycountm
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->count(${2:condition}, array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model countBySql
|
|
|
|
snippet ycountbs
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->countBySql(${2:sql},array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model updateAll
|
|
|
|
snippet yupdatea
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->updateAll(${2:array('attributes')}, ${3:condition},array('${4:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model updateByPk
|
|
|
|
snippet yupdatebp
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->updateByPk(${2:pk}, ${3:array('attributes')}, ${4:condition},array('${5:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model deleteAll
|
|
|
|
snippet ydela
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->deleteAll(${2:condition},array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model deleteByPk
|
|
|
|
snippet ydelbp
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->deleteByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model find
|
|
|
|
snippet yfind
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->find(${2:condition},array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model findAll
|
|
|
|
snippet yfinda
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->findAll(${2:condition},array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model findByPk
|
|
|
|
snippet yfindbp
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->findByPk(${2:pk}, ${3:condition}, array('${4:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model findAllByPk
|
|
|
|
snippet yfindabp
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->findAllByPk(${2:pk}, ${3:condition},array('${4:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model findBySql
|
|
|
|
snippet yfindbs
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->findBySql(${2:sql}, array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model findAllByAttributes
|
|
|
|
snippet yfindaba
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->findAllByAttributes(array('${2:attributeName}'=>${3:attributeValue}), ${4:condition}, array('${5:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Model exists
|
|
|
|
snippet yexists
|
2013-11-16 14:45:48 -05:00
|
|
|
${1:ModelName}::model()->exists(${2:condition}, array('${3:key}'=>${0:value}));
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Create model class
|
|
|
|
snippet ymodel
|
|
|
|
<?php
|
|
|
|
|
|
|
|
class ${1:ModelName} extends ${2:CActiveRecord}
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Returns the static model of the specified AR class.
|
|
|
|
* @return CActiveRecord the static model class
|
|
|
|
*/
|
|
|
|
public static function model($className=__CLASS__)
|
|
|
|
{
|
|
|
|
return parent::model($className);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return string the associated database table name
|
|
|
|
*/
|
|
|
|
public function tableName()
|
|
|
|
{
|
2013-11-16 14:45:48 -05:00
|
|
|
return '${0:table_name}';
|
2013-04-13 13:45:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array validation rules for model attributes.
|
|
|
|
*/
|
|
|
|
public function rules()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array relational rules.
|
|
|
|
*/
|
|
|
|
public function relations()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array customized attribute labels (name=>label)
|
|
|
|
*/
|
|
|
|
public function attributeLabels()
|
|
|
|
{
|
|
|
|
return array(
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-17 19:06:05 -04:00
|
|
|
#------------Yii Controller------------------------------------
|
2013-04-13 13:45:21 -04:00
|
|
|
|
|
|
|
#Yii Create controller class
|
|
|
|
snippet ycontroller
|
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ${1:}
|
|
|
|
*/
|
|
|
|
class ${2:Site}Controller extends ${3:CController}
|
|
|
|
{
|
|
|
|
public function action${4:Index}()
|
|
|
|
{
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-04-13 13:45:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// -----------------------------------------------------------
|
|
|
|
// Uncomment the following methods and override them if needed
|
|
|
|
/*
|
|
|
|
public function filters()
|
|
|
|
{
|
|
|
|
// return the filter configuration for this controller, e.g.:
|
|
|
|
return array(
|
|
|
|
'inlineFilterName',
|
|
|
|
array(
|
|
|
|
'class'=>'path.to.FilterClass',
|
|
|
|
'propertyName'=>'propertyValue',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function actions()
|
|
|
|
{
|
|
|
|
// return external action classes, e.g.:
|
|
|
|
return array(
|
|
|
|
'action1'=>'path.to.ActionClass',
|
|
|
|
'action2'=>array(
|
|
|
|
'class'=>'path.to.AnotherActionClass',
|
|
|
|
'propertyName'=>'propertyValue',
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
}
|
|
|
|
|
|
|
|
#Yii Create controller action method
|
|
|
|
snippet yact
|
|
|
|
public function action${1:Index}(${2:params})
|
|
|
|
{
|
2013-11-16 14:45:48 -05:00
|
|
|
${0}
|
2013-04-13 13:45:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|