本文整理汇总了PHP中skeeks\cms\helpers\UrlHelper类的典型用法代码示例。如果您正苦于以下问题:PHP UrlHelper类的具体用法?PHP UrlHelper怎么用?PHP UrlHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UrlHelper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: run
/**
* @inheritdoc
*/
public function run()
{
try {
$this->_initAndValidate();
$valueArray = [];
$trees = [];
$valueSingle = "";
$select = "";
$singleInput = "";
if (in_array($this->mode, [self::MOD_COMBO, self::MOD_MULTI])) {
$valueArray = Html::getAttributeValue($this->model, $this->attribute);
$select = Html::activeListBox($this->model, $this->attribute, ['16' => "16"], ['multiple' => true, 'class' => 'sx-controll-element', 'style' => 'display: none;']);
$trees = Tree::find()->where(['id' => $valueArray])->all();
}
if (in_array($this->mode, [self::MOD_COMBO, self::MOD_SINGLE])) {
$singleInput = Html::activeInput("hidden", $this->model, $this->attributeSingle, ['class' => 'sx-single']);
$valueSingle = Html::getAttributeValue($this->model, $this->attributeSingle);
}
$src = UrlHelper::construct('/cms/admin-tree')->set('mode', $this->mode)->set('s', $valueArray)->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->setSystemParam(Module::SYSTEM_QUERY_NO_ACTIONS_MODEL, 'true')->enableAdmin()->toString();
$id = "sx-id-" . md5(serialize([$this->clientOptions, $this->mode, $this->attributeMulti, $this->attributeSingle]));
$selected = [];
foreach ($trees as $tree) {
$selected[] = $tree->id;
}
return $this->render('widget', ['widget' => $this, 'id' => $id, 'select' => $select, 'src' => $src, 'valueSingle' => $valueSingle, 'singleInput' => $singleInput, 'clientOptions' => Json::encode(['src' => $src, 'name' => $id, 'id' => $id, 'selected' => $selected, 'valueSingle' => $valueSingle])]);
//$this->registerClientScript();
} catch (Exception $e) {
echo $e->getMessage();
}
}
示例2: run
/**
* Подготовка данных для шаблона
* @return $this
*/
public function run()
{
if (!$this->user) {
return '-';
}
return (new AdminImagePreviewWidget(['image' => $this->user ? $this->user->image : null, 'maxWidth' => "25px"]))->run() . " " . Html::a($this->user->displayName, \skeeks\cms\helpers\UrlHelper::construct(['/shop/admin-buyer-user/update', 'pk' => $this->user->id])->enableAdmin(), ['data-pjax' => 0]);
}
示例3: renderDataCellContent
/**
* @inheritdoc
*/
protected function renderDataCellContent($model, $key, $index)
{
$userId = (int) $model->{$this->attribute};
$user = User::findOne($userId);
if ($user) {
if (!($srcImage = $user->getAvatarSrc())) {
$srcImage = \Yii::$app->cms->moduleAdmin->noImage;
}
$this->grid->view->registerCss(<<<CSS
.sx-user-preview
{
}
.sx-user-preview .sx-user-preview-controll
{
display: none;
}
.sx-user-preview:hover .sx-user-preview-controll
{
display: inline;
}
CSS
);
return "<div class='sx-user-preview'>" . Html::img($srcImage, ['width' => 25, 'style' => 'margin-right: 5px;']) . $user->getDisplayName() . "\n <div class='sx-user-preview-controll'>" . Html::a("<i class='glyphicon glyphicon-pencil' title='Редактировать'></i>", UrlHelper::construct(['/cms/admin-user/update', 'pk' => $user->id])->enableAdmin()->toString(), ['class' => 'btn btn-xs btn-default', 'data-pjax' => 0]) . '</div></div>';
} else {
return null;
}
}
示例4: create
public function create()
{
$rr = new RequestResponse();
$modelClass = $this->modelClassName;
$model = new $modelClass();
$model->loadDefaultValues();
if ($post = \Yii::$app->request->post()) {
$model->load($post);
}
$handler = $model->handler;
if ($handler) {
if ($post = \Yii::$app->request->post()) {
$handler->load($post);
}
}
if ($rr->isRequestPjaxPost()) {
if (!\Yii::$app->request->post($this->notSubmitParam)) {
$model->component_settings = $handler->toArray();
$handler->load(\Yii::$app->request->post());
if ($model->load(\Yii::$app->request->post()) && $model->validate() && $handler->validate()) {
$model->save();
\Yii::$app->getSession()->setFlash('success', \Yii::t('skeeks/cms', 'Saved'));
return $this->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->requestPkParamName => $model->{$this->modelPkAttribute}])->toString());
} else {
\Yii::error(Json::encode($model->errors), self::className());
\Yii::$app->getSession()->setFlash('error', \Yii::t('skeeks/cms', 'Could not save'));
}
}
}
return $this->render('_form', ['model' => $model, 'handler' => $handler]);
}
示例5: run
/**
* @inheritdoc
*/
public function run()
{
if ($this->hasModel()) {
$name = Html::getInputName($this->model, $this->attribute);
$value = null;
if (is_array($this->model->{$this->attribute})) {
$value = StringHelper::base64EncodeUrl(serialize((array) $this->model->{$this->attribute}));
} else {
if (is_string($this->model->{$this->attribute})) {
$value = $this->model->{$this->attribute};
}
}
$this->options['id'] = Html::getInputId($this->model, $this->attribute);
//$element = Html::activeHiddenInput($this->model, $this->attribute, $this->options);
$element = Html::hiddenInput($name, $value, $this->options);
} else {
$element = Html::hiddenInput($this->name, $this->value, $this->options);
}
$this->registerPlugin();
$this->clientOptions['componentSelectId'] = $this->componentSelectId;
$this->clientOptions['componentSettingsId'] = Html::getInputId($this->model, $this->attribute);
$this->clientOptions['id'] = $this->id;
$this->clientOptions['backend'] = UrlHelper::construct('/cms/admin-universal-component-settings/index')->setSystemParam(Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->enableAdmin()->toString();
return $this->render('element', ['widget' => $this, 'element' => $element]);
}
示例6: sendEmail
/**
* Sends an email with a link, for resetting the password.
*
* @return boolean whether the email was send
*/
public function sendEmail()
{
/* @var $user \common\models\User */
$identityClassName = \Yii::$app->user->identityClass;
$user = $identityClassName::findByUsernameOrEmail($this->identifier);
//$user = $identityClassName::
if ($user) {
if (!$identityClassName::isPasswordResetTokenValid($user->password_reset_token)) {
$user->generatePasswordResetToken();
}
if ($user->save()) {
if (!$user->email) {
return false;
}
if ($this->isAdmin) {
$resetLink = \skeeks\cms\helpers\UrlHelper::construct('admin/auth/reset-password', ['token' => $user->password_reset_token])->enableAbsolute()->enableAdmin();
} else {
$resetLink = \skeeks\cms\helpers\UrlHelper::construct('cms/auth/reset-password', ['token' => $user->password_reset_token])->enableAbsolute();
}
$message = \Yii::$app->mailer->compose('@skeeks/cms/mail/passwordResetToken', ['user' => $user, 'resetLink' => $resetLink])->setFrom([\Yii::$app->cms->adminEmail => \Yii::$app->cms->appName])->setTo($user->email)->setSubject(\Yii::t('app', 'The request to change the password for') . \Yii::$app->cms->appName);
return $message->send();
}
}
return false;
}
示例7: init
public function init()
{
parent::init();
if ($this->backendUrl === null) {
$this->backendUrl = UrlHelper::construct('cms/admin-storage-files/link-to-models')->enableAdmin()->toString();
}
}
示例8: run
public function run()
{
$modelClassName = $this->controller->modelClassName;
$model = new $modelClassName();
$scenarios = $model->scenarios();
if ($scenarios && $this->modelScenario) {
if (isset($scenarios[$this->modelScenario])) {
$model->scenario = $this->modelScenario;
}
}
$rr = new RequestResponse();
if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax) {
return $rr->ajaxValidateForm($model);
}
if ($rr->isRequestPjaxPost()) {
if ($model->load(\Yii::$app->request->post()) && $model->save($this->modelValidate)) {
\Yii::$app->getSession()->setFlash('success', \Yii::t('app', 'Saved'));
if (\Yii::$app->request->post('submit-btn') == 'apply') {
return $this->controller->redirect(UrlHelper::constructCurrent()->setCurrentRef()->enableAdmin()->setRoute($this->controller->modelDefaultAction)->normalizeCurrentRoute()->addData([$this->controller->requestPkParamName => $model->{$this->controller->modelPkAttribute}])->toString());
} else {
return $this->controller->redirect($this->controller->indexUrl);
}
} else {
\Yii::$app->getSession()->setFlash('error', \Yii::t('app', 'Could not save'));
}
}
$this->viewParams = ['model' => $model];
return parent::run();
}
示例9: run
public function run()
{
if ($this->parentModel->isNewRecord) {
return "";
}
/**
* @var $controller AdminModelEditorController
*/
$controller = \Yii::$app->createController($this->controllerRoute)[0];
$rerlation = [];
foreach ($this->relation as $relationLink => $parent) {
if ($this->parentModel->getAttribute($parent)) {
$rerlation[$relationLink] = $this->parentModel->{$parent};
} else {
$rerlation[$relationLink] = $parent;
}
}
$createUrl = \skeeks\cms\helpers\UrlHelper::construct($this->controllerRoute . '/' . $this->controllerCreateAction, $rerlation)->setSystemParam(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->setSystemParam(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_NO_ACTIONS_MODEL, 'true')->enableAdmin()->toString();
$sortableUrl = \skeeks\cms\helpers\UrlHelper::construct($this->controllerRoute . '/' . $this->controllerSortableAction)->enableAdmin()->toString();
$search = new \skeeks\cms\models\Search($controller->modelClassName);
$search->getDataProvider()->query->where($rerlation);
if (isset($this->sort['defaultOrder'])) {
$search->getDataProvider()->sort->defaultOrder = $this->sort['defaultOrder'];
}
if ($this->dataProviderCallback && is_callable($this->dataProviderCallback)) {
$function = $this->dataProviderCallback;
$function($search->getDataProvider());
}
$pjaxId = "sx-table-" . md5($this->label . $this->hint . $this->parentModel->className());
$gridOptions = ArrayHelper::merge(['pjaxOptions' => ['id' => $pjaxId], "sortableOptions" => ['backend' => $sortableUrl], 'dataProvider' => $search->getDataProvider(), 'layout' => "\n{beforeTable}\n{items}\n{afterTable}\n{pager}", 'columns' => [['class' => \skeeks\cms\modules\admin\grid\ActionColumn::className(), 'controller' => $controller, 'isOpenNewWindow' => true]]], (array) $this->gridViewOptions);
return $this->render('related-models-grid', ['widget' => $this, 'createUrl' => $createUrl, 'controller' => $controller, 'gridOptions' => $gridOptions, 'pjaxId' => $pjaxId]);
}
示例10: __construct
public function __construct($config = [])
{
$this->validationUrl = \skeeks\cms\helpers\UrlHelper::construct('form2/backend/validate')->toString();
$this->action = \skeeks\cms\helpers\UrlHelper::construct('form2/backend/submit')->toString();
$this->enableAjaxValidation = true;
parent::__construct($config);
}
示例11: isRequestOnValidateAjaxForm
/**
* Запрос пришел на валидацию ajax формы?
* @return bool
*/
public function isRequestOnValidateAjaxForm()
{
if (\Yii::$app->request->isAjax && !\Yii::$app->request->isPjax && UrlHelper::getCurrent()->issetSystemParam(static::VALIDATION_AJAX_FORM_SYSTEM_NAME)) {
return true;
}
return false;
}
示例12: init
public function init()
{
parent::init();
if (!$this->selectUrl) {
$additionalData = [];
$additionalData['callbackEvent'] = $this->getCallbackEvent();
$this->selectUrl = \skeeks\cms\helpers\UrlHelper::construct($this->baseRoute, $additionalData)->setSystemParam(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->enableAdmin()->toString();
}
}
示例13: run
/**
* @return static
*/
public function run()
{
Yii::$app->user->logout();
if ($ref = UrlHelper::getCurrent()->getRef()) {
return Yii::$app->getResponse()->redirect($ref);
} else {
return Yii::$app->getResponse()->redirect(Yii::$app->getUser()->getReturnUrl());
}
}
示例14: init
public function init()
{
$additionalData = [];
if ($this->relatedModel && ($this->relatedModel instanceof ActiveRecord && !$this->relatedModel->isNewRecord)) {
$additionalData = ['className' => $this->relatedModel->className(), 'pk' => $this->relatedModel->primaryKey];
}
$this->clientOptions['filebrowserImageBrowseUrl'] = UrlHelper::construct('cms/admin-tools/select-file', $additionalData)->setSystemParam(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->enableAdmin()->toString();
parent::init();
}
示例15: init
public function init()
{
if ($this->model && \Yii::$app->cmsToolbar) {
$controller = \Yii::$app->createController('cms/admin-cms-content-element')[0];
$adminControllerRoute = ['cms/admin-cms-content-element/update', $controller->requestPkParamName => $this->model->{$controller->modelPkAttribute}];
$urlEditModel = UrlHelper::construct($adminControllerRoute)->enableAdmin()->setSystemParam(\skeeks\cms\modules\admin\Module::SYSTEM_QUERY_EMPTY_LAYOUT, 'true')->toString();
\Yii::$app->cmsToolbar->editUrl = $urlEditModel;
}
parent::init();
}