本文整理汇总了PHP中AdminHelper::generateUrlStr方法的典型用法代码示例。如果您正苦于以下问题:PHP AdminHelper::generateUrlStr方法的具体用法?PHP AdminHelper::generateUrlStr怎么用?PHP AdminHelper::generateUrlStr使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AdminHelper
的用法示例。
在下文中一共展示了AdminHelper::generateUrlStr方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeValidate
public function beforeValidate()
{
if ($this->isNewRecord && $this->keyword === null) {
$this->keyword = AdminHelper::generateUrlStr($this->alias, $this, 'keyword');
}
return parent::beforeValidate();
}
示例2: beforeSave
public function beforeSave()
{
$id = !$this->isNewRecord ? $this->primaryKey : null;
foreach (Yii::app()->languageManager->languages as $l => $lang) {
if ($l === Yii::app()->sourceLanguage) {
$suffix = '';
$language = null;
} else {
$suffix = '_' . $l;
$language = $l;
}
$this->{'title_url' . $suffix} = AdminHelper::generateUrlStr($this->{'title' . $suffix}, $this, 'title_url', $id, $language);
}
return parent::beforeSave();
}
示例3: beforeSave
/**
* Generate the filtered url string.
*/
public function beforeSave($event)
{
$owner = $this->getOwner();
$id = !$owner->isNewRecord ? $owner->primaryKey : null;
foreach (Yii::app()->languageManager->languages as $l => $lang) {
if ($l === Yii::app()->sourceLanguage) {
$suffix = '';
$language = null;
} else {
$suffix = '_' . $l;
$language = $l;
}
$owner->{$this->attribute . $suffix} = AdminHelper::generateUrlStr($owner->{$this->sourceAttribute . $suffix}, $owner, $this->attribute, $id, $language);
}
}
示例4: afterSave
/**
* Saving related Bloc entry.
*/
public function afterSave($event)
{
$owner = $this->getOwner();
if ($owner->isNewRecord) {
$contentBloc = new Bloc();
if (Yii::app()->languageManager->multilang) {
$contentBloc->multilang();
}
$contentBloc->parent_id = $owner->parent_id;
$contentBloc->bloc_type = mb_substr($owner->tableName(), 5);
$contentBloc->bloc_id = $owner->primaryKey;
} else {
if (Yii::app()->languageManager->multilang) {
$contentBloc = Bloc::model()->multilang()->findByAttributes(array('bloc_id' => $owner->primaryKey, 'bloc_type' => mb_substr($owner->tableName(), 5)));
} else {
$contentBloc = Bloc::model()->findByAttributes(array('bloc_id' => $owner->primaryKey, 'bloc_type' => mb_substr($owner->tableName(), 5)));
}
}
$contentBloc->rank = $owner->rank;
$contentBloc->title_anchor = $owner->title_anchor;
$contentBloc->title_page = $owner->title_page;
$contentBloc->unique_id = $owner->unique_id;
$contentBloc->last_modified = date('Y-m-d H:i:s');
foreach (Yii::app()->languageManager->languages as $l => $fullLanguage) {
if ($l === Yii::app()->sourceLanguage) {
$suffix = '';
} else {
$suffix = '_' . $l;
}
$contentBloc->{'title' . $suffix} = $owner->{'title' . $suffix};
if ($owner->isNewRecord) {
$contentBloc->{'title_url' . $suffix} = AdminHelper::generateUrlStr($owner->{'title' . $suffix}, $contentBloc, 'title_url', null, $l);
} else {
$contentBloc->{'title_url' . $suffix} = AdminHelper::generateUrlStr($owner->{'title' . $suffix}, $contentBloc, 'title_url', $contentBloc->id, $l);
}
}
$contentBloc->save(false);
}
示例5: actions
public function actions()
{
$formSettings = array('redirect' => $this->createUrl('admin'), 'forms' => array('id' => 'mainForm', 'varName' => 'contentPage', 'models' => 'ContentPage', 'forms' => array('id' => 'blocsForm', 'blocs' => 'content', 'varName' => 'blocs'), 'onAfterSetAttributes' => function ($event) {
if (Yii::app()->user->id != 'Admin-1' && isset($this->module->layouts)) {
$model = $event->params['model'];
if ($model->layout == '') {
foreach ($this->module->layouts as $layoutName => $layoutTitle) {
$model->layout = $layoutName;
break;
}
}
}
}, 'onBeforeSave' => function ($event) {
$model = $event->params['model'];
if ($model->isNewRecord) {
$alias = new CmsAlias();
foreach (Yii::app()->languageManager->languages as $language => $fullLanguage) {
if ($language === Yii::app()->sourceLanguage) {
$suffix = '';
} else {
$suffix = '_' . $language;
}
$alias->{'alias' . $suffix} = AdminHelper::generateUrlStr($model->{'title' . $suffix}, $alias, 'alias', null, $language);
$alias->{'title' . $suffix} = $model->{'title' . $suffix};
}
$alias->section_id = CmsSection::model()->findByAttributes(array('module' => 'content'))->id;
$alias->allow_children = 1;
$alias->attributes = $_POST['CmsAlias'];
$root = CmsAlias::model()->roots()->find();
$alias->appendTo($root);
$aliasRoute = new CmsAliasRoute();
$aliasRoute->route = 'content';
$aliasRoute->alias_id = $alias->primaryKey;
$aliasRoute->save();
$model->alias_id = $alias->primaryKey;
} else {
$alias = CmsAlias::model()->multilang()->findByPk($model->alias->id);
$alias->attributes = $_POST['CmsAlias'];
foreach (Yii::app()->languageManager->languages as $language => $fullLanguage) {
if ($language === Yii::app()->sourceLanguage) {
$suffix = '';
} else {
$suffix = '_' . $language;
}
$alias->{'alias' . $suffix} = AdminHelper::generateUrlStr($model->{'title' . $suffix}, $alias, 'alias', $alias->id, $language);
$alias->{'title' . $suffix} = $model->{'title' . $suffix};
}
}
if ($alias->location != 'nochange') {
$decode = CJSON::decode($_POST['CmsAlias']['location']);
$to = CmsAlias::model()->findByPk((int) $decode['to']);
$action = $decode['action'];
switch ($action) {
case 'child':
$alias->moveAsLast($to);
break;
case 'before':
if ($to->isRoot()) {
$alias->moveAsRoot();
} else {
$alias->moveBefore($to);
}
break;
case 'after':
if ($to->isRoot()) {
$alias->moveAsRoot();
} else {
$alias->moveAfter($to);
}
break;
}
} else {
$alias->saveNode();
}
}));
return array('create' => array('class' => 'application.components.actions.Create', 'formSettings' => $formSettings), 'update' => array('class' => 'application.components.actions.Update', 'formSettings' => $formSettings), 'delete' => array('class' => 'application.components.actions.Delete', 'modelClass' => 'ContentPage'), 'admin' => array('class' => 'application.components.actions.Admin', 'modelClass' => 'ContentPage'));
}