public function api_form($options = []) { $model = new FeedbackModel(); $settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings; $options = array_merge($this->_defaultFormOptions, $options); ob_start(); $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]); echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0])); echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1])); echo $form->field($model, 'name'); echo $form->field($model, 'email')->input('email'); if ($settings['enablePhone']) { echo $form->field($model, 'phone'); } if ($settings['enableTitle']) { echo $form->field($model, 'title'); } echo $form->field($model, 'text')->textarea(); if ($settings['enableCaptcha']) { echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className()); } echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']); ActiveForm::end(); return ob_get_clean(); }
public static function makeUrl($attr_id, $val_id) { // $get = Yii::$app->getRequest()->get(); // $so = isset($get['so']) ? $get['so'] . ',' : ''; $so = $attr_id . '_' . $val_id; return Url::current(['so' => $so]); }
public function run() { $model = new Comments(); if (!is_string($this->model)) { $model->post_id = $this->model->getPrimaryKey(); $model->module = get_class($this->model); $order = ''; } else { $model->post_id = 0; $model->module = $this->model; $order = 'DESC'; } // Получаем комментарии этого модуля и пост айди $models = Comments::getComments($model->module, $model->post_id, $order); // Получаем кол-во страниц комментариев для редиректа $page = $models['pages']->totalCount / $models['pages']->pageSize + 1; if ($model->load(Yii::$app->request->post())) { if ($model->save()) { Url::remember(Url::current()); Yii::$app->getSession()->setFlash('success', '<i class="fa fa-check fa-1x"></i> Good! '); if (!is_string($this->model)) { return Yii::$app->getResponse()->redirect('/post/' . $this->model->slug . '/' . $model->post_id . '?page=' . round($page) . '#' . $model->id); } else { return Yii::$app->getResponse()->refresh(); } } } return $this->render('widgetComment', ['model' => $model, 'models' => $models['models'], 'pages' => $models['pages'], 'options' => $this->options]); }
/** * Lists all Book models. * @return mixed */ public function actionIndex() { Url::remember(Url::current(), 'books'); $searchModel = new BookSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Create $this->seoPage by current url * @author Kravchuk Dmitry * @throws Exception */ private function __construct() { // find seo model by url $url = Url::current(); $actionId = Yii::$app->controller->action->uniqueId; $i = 1; $seoModelQuery = SeoModel::find()->select('*')->byUrl($url)->active(); $seoModelQuery->union(SeoModel::find()->byUrlRuleWithTableAlias('/' . trim($actionId, '/'), 'rule' . $i), true); $actionIdArray = explode('/', $actionId); if (is_array($actionIdArray)) { do { ++$i; array_pop($actionIdArray); $urlRule = empty($actionIdArray) ? '/*' : '/' . implode('/', $actionIdArray) . '/*'; $unionQuery = SeoModel::find()->byUrlRuleWithTableAlias($urlRule, 'rule' . $i); $seoModelQuery->union($unionQuery, true); } while (!empty($actionIdArray)); } $seoModel = $seoModelQuery->one(); if (!empty($seoModel)) { $category = $seoModel->category; $config = ['class' => $seoModel->seoPageClass, 'metaTitle' => !empty($category) && empty($seoModel->metaTitle) ? $category->metaTitle : $seoModel->metaTitle, 'metaKeyWords' => !empty($category) && empty($seoModel->metaKeywords) ? $category->metaKeywords : $seoModel->metaKeywords, 'metaDescription' => !empty($category) && empty($seoModel->metaDescription) ? $category->metaDescription : $seoModel->metaDescription, 'pageContent' => !empty($category) && empty($seoModel->pageContent) ? $category->pageContent : $seoModel->pageContent]; $seoPage = Yii::createObject($config); if (!empty($seoPage)) { if (!is_subclass_of($seoPage, 'kravchukdim\\yii2seo\\components\\SeoPageInterface')) { throw new Exception('Error, invalid seo page class'); } $this->seoPage = $seoPage; } } }
public function api_form($options = []) { $model = new FeedbackModel(); $settings = Yii::$app->getModule('admin')->activeModules['agencies']->settings; $options = array_merge($this->_defaultFormOptions, $options); ob_start(); $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send'])]); echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0])); echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1])); var_dump($model->getErrors()); echo ' <input type="text" placeholder="Title" class="form-control" name="Feedback[title]" > <input type="text" placeholder="Company Name" class="form-control" name="Feedback[name]" id="feedback-name"> <div class="help-block"></div> <input type="text" placeholder="Phone" class="form-control" name="Feedback[phone]" > <input type="text" placeholder="Email" class="form-control" name="Feedback[email]" > <textarea name="Feedback[text]" id="feedback-text" class="form-control msg" rows="5" placeholder="your message"></textarea> <div class="row"> <div class="col-md-12"> <button class="btn dry-btn center-block" type="submit">Send Request</button> </div> </div>'; // echo $form->field($model, 'name'); // echo $form->field($model, 'email')->input('email'); // // if($settings['enablePhone']) echo $form->field($model, 'phone'); // if($settings['enableTitle']) echo $form->field($model, 'title'); // // echo $form->field($model, 'text')->textarea(); // // if($settings['enableCaptcha']) echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className()); // // echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']); ActiveForm::end(); return ob_get_clean(); }
/** * @param int $characterID * * @return string * @throws \yii\web\NotFoundHttpException */ public function actionCreate($characterID) { Url::remember(Url::current(), self::REMEMBER_NAME); $character = $this->loadCharacter($characterID); $this->getView()->addBread(['label' => 'Demands', 'url' => ['demand/index', 'characterID' => $characterID]])->addBread(['label' => 'Create'])->setCharacter($character); $marketDemand = new MarketDemand(); $marketDemand->characterID = $characterID; $marketDemand->userID = \Yii::$app->user->id; if ($this->isAjax()) { $type = $this->get('sType'); if ($type == 'station') { $sql = '(SELECT sStation.stationID, sStation.stationName, sStation.stationTypeID FROM staStations as sStation WHERE sStation.stationName LIKE "%' . $_GET['q'] . '%") UNION (SELECT cStation.stationID, cStation.stationName, cStation.stationTypeID FROM api_eve_conquerableStation as cStation WHERE cStation.stationName LIKE "%' . $_GET['q'] . '%")'; } elseif ($type == 'item') { $sql = 'SELECT typeID, typeName FROM invTypes WHERE typeName LIKE "%' . $_GET['q'] . '%" AND published ="1" ORDER BY typeName'; } $return = \Yii::$app->db->createCommand($sql)->queryAll(); echo Json::encode($return); // @todo change response type \Yii::$app->end(); } elseif ($this->isPost() && $marketDemand->load($this->post())) { if ($marketDemand->save()) { UpdaterEveCentral::addType($marketDemand->typeID); return $this->redirect(['demand/list', 'characterID' => $characterID]); } } return $this->render('create', ['marketDemand' => $marketDemand]); }
/** * @return string */ public function actionList() { Url::remember(Url::current(), self::REMEMBER_NAME); $this->getView()->addBread('List'); $searchPrice = new SearchPrice(); return $this->render('list', ['searchPrice' => $searchPrice]); }
protected function isItemActive($item) { if (isset($item['url']) && is_string($item['url']) && $item['url'] === Url::current()) { return true; } return parent::isItemActive($item); }
public function api_form($options = []) { $model = new FeedbackModel(); $settings = Yii::$app->getModule('admin')->activeModules['awarness']->settings; $options = array_merge($this->_defaultFormOptions, $options); ob_start(); $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/awarness/send']), 'options' => ['class' => 'col-md-offset-4']]); echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0])); echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1])); echo ' <div class="form-group center-block col-md-6">'; ' <input class="form-control" placeholder="Name" name="Feedback[name]"> <input class="form-control" placeholder="Subject" name="Feedback[title]"> <input class="form-control" placeholder="Your Mail" name="Feedback[email]" > <textarea class="form-control" rows="3" placeholder="Your Message" name="Feedback[text]" id="feedback-text"></textarea> <button type="submit" class="btn dry-btn-3 center-block">Send Request</button> </div> '; // echo $form->field($model, 'name'); // echo $form->field($model, 'email')->input('email'); // // if($settings['enablePhone']) echo $form->field($model, 'phone'); // if($settings['enableTitle']) echo $form->field($model, 'title'); // // echo $form->field($model, 'text')->textarea(); // // if($settings['enableCaptcha']) echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className()); // // echo Html::submitButton(Yii::t('easyii', 'Send'), ['class' => 'btn btn-primary']); ActiveForm::end(); return ob_get_clean(); }
public function actionContent($links_id, $id = null) { $link = Links::findOne($links_id); if (Yii::$app->request->get('action')) { switch (Yii::$app->request->get('action')) { case "add": $content = new Contents(); $content->links_id = $link->id; $content->seq = $content->findLastSequence($link->id, $id) + 1; $content->save(); break; case "del": Contents::deleteAll(['id' => $id]); (new Contents())->reSort($link->id); break; } return $this->redirect(Url::current(['action' => null, 'id' => null])); } $contents = Contents::find()->where(['links_id' => $links_id])->orderBy(['seq' => SORT_ASC])->all(); if (Yii::$app->request->post()) { foreach ($contents as $index => $content) { if (Yii::$app->request->post('content-' . $index)) { $contents[$index]->load(Yii::$app->request->post()); $contents[$index]->text = Yii::$app->request->post('content-' . $index); $contents[$index]->save(); } } } return $this->render('content', ['link' => $link, 'contents' => $contents]); }
public function testCurrent() { $this->mockAction('page', 'view', null, []); \Yii::$app->request->setQueryParams(['id' => 10, 'name' => 'test']); $this->assertEquals('/base/index.php?r=page%2Fview&id=10&name=test', Url::current()); $this->assertEquals('/base/index.php?r=page%2Fview&id=20&name=test', Url::current(['id' => 20])); $this->assertEquals('/base/index.php?r=page%2Fview&name=test', Url::current(['id' => null])); }
public function run() { $header = Html::tag('span', 'План проспект'); $btnGroup = ButtonGroup::widget(['buttons' => array_map(function ($year) { return ['label' => ArrayHelper::getValue($this->yearLabels, $year), 'tagName' => 'a', 'options' => ['href' => Url::current(['god' => $year]), 'class' => ['active' => $year === $this->getGod() ? 'active' : null]]]; }, $this->years)]); return Html::tag('div', $header . $btnGroup); }
/** * @return \Generator */ public function getList() { $items = []; foreach ((array) $this->langs as $lang_id => $urlName) { $items[] = ['label' => $urlName, 'active' => $lang_id == $this->currentLang, 'url' => Yii::$app->getErrorHandler()->exception !== null ? Url::toRoute([Yii::$app->getHomeUrl(), $this->langAttribute => $lang_id]) : Url::current([$this->langAttribute => $lang_id])]; } return $items; }
/** * Lists all Books models. * @return mixed */ public function actionIndex() { $searchModel = new BooksSearch(); $dataProvider = $searchModel->search(Yii::$app->request->queryParams); // Save state of the current url Yii::$app->getUser()->setReturnUrl(Url::current()); return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
/** * Updates an existing Post model. * If update is successful, the browser will be redirected to the current page. * @param integer $id * @return mixed */ public function actionUpdate($id) { $model = $this->findModel($id); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(Url::current()); } else { return $this->render('update', ['model' => $model, 'langList' => Lang::getList()]); } }
/** * Renders the toggle data button * * @return string */ public function renderToggleDataNoContainer() { if (!$this->toggleData) { return ''; } $tag = $this->_isShowAll ? 'page' : 'all'; $url = Url::current([$this->_toggleDataKey => $tag]); $label = $this->toggleDataOptions[$tag]['label']; return Html::a($label, $url, $this->toggleDataOptions[$tag]); }
/** * @inheritdoc */ public function run() { $sortBy = Yii::$app->request->get('sort_by', 'new'); $items[] = ['label' => 'Активные', 'url' => Url::current(['sort_by' => 'new']), 'active' => $sortBy == 'new', 'options' => ['title' => 'Темы отсортированные по времени последнего сообщения']]; $items[] = ['label' => 'Без ответов', 'url' => Url::current(['sort_by' => 'unanwser']), 'active' => $sortBy == 'unanwser', 'options' => ['title' => 'Темы отсортированные по времени последнего сообщения и не содержащие ответов']]; if (!Yii::$app->getUser()->getIsGuest()) { $items[] = ['label' => 'Мои', 'url' => Url::current(['sort_by' => 'own']), 'active' => $sortBy == 'own', 'options' => ['title' => 'Темы отсортированные по времени последнего сообщения и не содержащие ответов']]; } return Menu::widget(['items' => $items, 'options' => ['class' => 'question-list-tabs']]); }
public function run() { $searchModel = $this->getSearchModelName(); $searchModel = new $searchModel(); $dataProvider = $searchModel->search(\Yii::$app->request->queryParams); if (\Yii::$app->request->isGet) { \Yii::$app->user->returnUrl = Url::current(); } return $this->render(['searchModel' => $searchModel, 'dataProvider' => $dataProvider]); }
public function actionManager($id = null) { $broadcast = new BroadcastForm(); if ($id) { $broadcast = BroadcastForm::findOne($id); } if ($broadcast->load(Yii::$app->request->post()) && $broadcast->save()) { Yii::$app->session->setFlash('success', 'Изменения приняты. Вы можете подготовить письмо к отправке.'); return $this->redirect(Url::current(['id' => $broadcast->id])); } return $this->render('manager', ['broadcast' => $broadcast]); }
public function registerJsApi() { $signData = ['jsapi_ticket' => $this->owner->getJsApiTicket(), 'timestamp' => time(), 'noncestr' => Yii::$app->security->generateRandomString(10), 'url' => Url::current([], true)]; $apiList = ['onMenuShareTimeline', 'onMenuShareAppMessage', 'onMenuShareQQ', 'onMenuShareWeibo', 'onMenuShareQZone', 'startRecord', 'stopRecord', 'onVoiceRecordEnd', 'playVoice', 'pauseVoice', 'stopVoice', 'onVoicePlayEnd', 'uploadVoice', 'downloadVoice', 'chooseImage', 'previewImage', 'uploadImage', 'downloadImage', 'translateVoice', 'getNetworkType', 'openLocation', 'getLocation', 'hideOptionMenu', 'showOptionMenu', 'hideMenuItems', 'showMenuItems', 'hideAllNonBaseMenuItem', 'showAllNonBaseMenuItem', 'closeWindow', 'scanQRCode', 'chooseWXPay', 'openProductSpecificView', 'addCard', 'chooseCard', 'openCard']; ksort($signData, SORT_STRING); $signStr = $this->owner->arrayToPaySignStr($signData); $sign = sha1($signStr); $jsApiList = implode("','", $apiList); $jsApiList = "'" . $jsApiList . "'"; Yii::$app->controller->view->registerJsFile('http://res.wx.qq.com/open/js/jweixin-1.0.0.js'); Yii::$app->controller->view->registerJs("wx.config({appId: '" . $this->owner->appID . "',timestamp: '" . $signData['timestamp'] . "',nonceStr: '" . $signData['noncestr'] . "',signature: '" . $sign . "',jsApiList: [" . $jsApiList . "]});"); }
/** * Возвращает путь к карточки объединения * @param array $row * * @return string */ private static function getUnionUrl($row) { $url = Url::current([], true); $oUrl = new \cs\services\Url($url); $arr = explode('/', $oUrl->path); if ($arr[1] == 'category') { $url = '/category/' . $arr[2] . '/' . $row['id']; } else { $url = '/category/' . $arr[1] . '/' . $row['id']; } return $url; }
public function actionMsg() { $this->layout = 'msg'; $msg = new Msg(); if (Yii::$app->request->isPost) { if ($msg->addMsg()) { $this->redirect(Url::current()); } } else { $data = $msg->getMsgs(); return $this->render('msg', $data); } }
public function actionUrl() { $urls = []; $urls[] = Url::base(); $urls[] = Url::current(); $urls[] = Url::previous(); // use before Url::remember() $urls[] = Url::home(); $urls[] = Url::to('/'); $urls[] = Url::to('/test'); $urls[] = Url::to(['book']); return VarDumper::dumpAsString($urls, 10, true); }
public function api_form($options = []) { $model = new Subscriber(); $options = array_merge($this->_defaultFormOptions, $options); ob_start(); $form = ActiveForm::begin(['enableAjaxValidation' => true, 'action' => Url::to(['/admin/subscribe/send']), 'layout' => 'inline']); echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0])); echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1])); echo $form->field($model, 'email')->input('email', ['placeholder' => 'E-mail']); echo Html::submitButton(Yii::t('easyii/subscribe/api', 'Subscribe'), ['class' => 'btn btn-primary', 'id' => 'subscriber-send']); ActiveForm::end(); return ob_get_clean(); }
public function actionSecret() { $admin = new Secret(['scenario' => 'mod']); if (Yii::$app->request->isPost) { if ($admin->updSecret()) { Yii::$app->session->destroy(); $this->redirect(Url::to(['log/index'])); } else { $this->redirect(Url::current()); } } else { return $this->render('secret', ['model' => $admin]); } }
protected function goOAuth() { $code = Yii::$app->request->get('code'); if (empty($code)) { $queryData = ['appid' => $this->owner->appID, 'redirect_uri' => Url::current([], true), 'response_type' => 'code', 'scope' => 'snsapi_login', 'state' => Yii::$app->security->generateRandomString()]; Yii::$app->controller->redirect('https://open.weixin.qq.com/connect/qrconnect?' . http_build_query($queryData) . '#wechat_redirect'); } else { if ($result = $this->owner->getAccessTokenByCode($code)) { return $result; } else { return false; } } }
public function run() { $languages = $this->languages; $current = $languages[Yii::$app->language]; unset($languages[Yii::$app->language]); $items = []; foreach ($languages as $code => $language) { $temp = []; $temp['label'] = $language; $temp['url'] = Url::current(['language' => $code]); array_push($items, $temp); } echo ButtonDropdown::widget(['label' => $current, 'dropdown' => ['items' => $items], 'containerOptions' => $this->container, 'options' => ['class' => 'btn btn-xs btn-warning', 'style' => 'margin-top: 1px;'], 'tagName' => 'button']); }
public function run() { $languages = $this->languages; $current = $languages[Yii::$app->language]; unset($languages[Yii::$app->language]); $items = []; foreach ($languages as $code => $language) { $temp = []; $temp['label'] = $language; $temp['url'] = Url::current(['language' => $code]); array_push($items, $temp); } echo ButtonDropdown::widget(['label' => $current, 'dropdown' => ['items' => $items]]); }
public function api_form($options = []) { $model = new FeedbackModel(); $settings = Yii::$app->getModule('admin')->activeModules['feedback']->settings; $options = array_merge($this->_defaultFormOptions, $options); ob_start(); $form = ActiveForm::begin(['enableClientValidation' => true, 'action' => Url::to(['/admin/feedback/send']), 'options' => ['class' => 'col form']]); echo '<p class="caption">' . Text::get('contact-page-leave-us-a-message') . '</p>'; echo Html::hiddenInput('errorUrl', $options['errorUrl'] ? $options['errorUrl'] : Url::current([self::SENT_VAR => 0])); echo Html::hiddenInput('successUrl', $options['successUrl'] ? $options['successUrl'] : Url::current([self::SENT_VAR => 1])); echo $form->field($model, 'name', ['options' => ['tag' => 'fieldset'], 'errorOptions' => ['class' => 'msg-error', 'tag' => 'p'], 'template' => '{input}{error}', 'selectors' => ['input' => '#input-001']])->input('text', ['id' => 'input-001', 'placeholder' => Yii::t('all', 'Name')]); echo $form->field($model, 'email', ['options' => ['tag' => 'fieldset'], 'errorOptions' => ['class' => 'msg-error', 'tag' => 'p'], 'template' => '{input}{error}', 'selectors' => ['input' => '#input-002']])->input('email', ['id' => 'input-002', 'placeholder' => Yii::t('all', 'Your e-mail')]); if ($settings['enablePhone']) { echo $form->field($model, 'phone'); } if ($settings['enableTitle']) { echo $form->field($model, 'title'); } echo $form->field($model, 'text', ['options' => ['tag' => 'fieldset'], 'errorOptions' => ['class' => 'msg-error', 'tag' => 'p'], 'template' => '{input}{error}', 'selectors' => ['input' => '#input-005']])->textArea(['rows' => '6', 'id' => 'input-005', 'placeholder' => Yii::t('all', 'Message text')]); if ($settings['enableCaptcha']) { echo $form->field($model, 'reCaptcha')->widget(ReCaptcha::className()); } echo Html::submitButton(Yii::t('all', 'send a message'), ['class' => 'btn btn-primary']); ActiveForm::end(); return ob_get_clean(); }