当前位置: 首页>>代码示例>>PHP>>正文


PHP Option::get方法代码示例

本文整理汇总了PHP中common\models\Option::get方法的典型用法代码示例。如果您正苦于以下问题:PHP Option::get方法的具体用法?PHP Option::get怎么用?PHP Option::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common\models\Option的用法示例。


在下文中一共展示了Option::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 /**
  * Creates a new Post model.
  * If creation is successful, the browser will be redirected to the 'update' page.
  *
  * @param integer $post_type post_type_id
  *
  * @throws \yii\web\ForbiddenHttpException
  * @throws \yii\web\NotFoundHttpException
  * @return mixed
  */
 public function actionCreate($post_type)
 {
     $model = new Post();
     $postType = $this->findPostType($post_type);
     $model->post_comment_status = Option::get('default_comment_status');
     if (!Yii::$app->user->can($postType->post_type_permission)) {
         throw new ForbiddenHttpException(Yii::t('writesdown', 'You are not allowed to perform this action.'));
     }
     if ($model->load(Yii::$app->request->post())) {
         $model->post_type = $postType->id;
         $model->post_date = Yii::$app->formatter->asDatetime($model->post_date, 'php:Y-m-d H:i:s');
         if ($model->save()) {
             if ($termIds = Yii::$app->request->post('termIds')) {
                 foreach ($termIds as $termId) {
                     $termRelationship = new TermRelationship();
                     $termRelationship->setAttributes(['term_id' => $termId, 'post_id' => $model->id]);
                     if ($termRelationship->save() && ($term = $this->findTerm($termId))) {
                         $term->updateAttributes(['term_count' => $term->term_count++]);
                     }
                 }
             }
             if ($meta = Yii::$app->request->post('meta')) {
                 foreach ($meta as $meta_name => $meta_value) {
                     $model->setMeta($meta_name, $meta_value);
                 }
             }
             Yii::$app->getSession()->setFlash('success', Yii::t('writesdown', '{post_type} successfully saved.', ['post_type' => $postType->post_type_sn]));
             return $this->redirect(['update', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model, 'postType' => $postType]);
 }
开发者ID:tampaphp,项目名称:app-cms,代码行数:42,代码来源:PostController.php

示例2: actionView

 /**
  * Displays a single User model.
  *
  * @param null $id
  * @param      $username
  *
  * @return mixed
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionView($id = null, $username = null)
 {
     $render = '/user/view';
     if ($id) {
         $model = $this->findModel($id);
     } else {
         if ($username) {
             $model = $this->findModelByUsername($username);
         } else {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     }
     $query = $model->getPosts()->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Option::get('posts_per_page')]);
     $query->offset($pages->offset)->limit($pages->limit);
     $posts = $query->all();
     if ($posts) {
         if (is_file($this->view->theme->basePath . '/user/view-' . $model->username . '.php')) {
             $render = 'view-' . $model->username . '.php';
         }
         return $this->render($render, ['user' => $model, 'posts' => $posts, 'pages' => isset($pages) ? $pages : null]);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
开发者ID:ochiem,项目名称:app-cms,代码行数:35,代码来源:UserController.php

示例3: actionIndex

 /**
  * @param int|null    $id        ID of post-type.
  * @param string|null $post_type Slug of post-type.
  *
  * @return string
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionIndex($id = null, $post_type = null)
 {
     $render = 'index';
     if ($id) {
         $postType = $this->findPostType($id);
     } else {
         if ($post_type) {
             $postType = $this->findPostTypeBySlug($post_type);
         } else {
             throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
         }
     }
     $query = $postType->getPosts()->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Option::get('posts_per_page')]);
     $query->offset($pages->offset)->limit($pages->limit);
     $posts = $query->all();
     if ($posts) {
         if (is_file($this->view->theme->basePath . '/post/index-' . $postType->post_type_slug . '.php')) {
             $render = 'index-' . $postType->post_type_slug . '.php';
         }
         return $this->render($render, ['postType' => $postType, 'posts' => $posts, 'pages' => $pages]);
     } else {
         throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
     }
 }
开发者ID:ochiem,项目名称:app-cms,代码行数:33,代码来源:PostController.php

示例4: actionIndex

 /**
  * @return string
  */
 public function actionIndex()
 {
     /* @var $lastPost \common\models\Post */
     $response = Yii::$app->response;
     $response->headers->set('Content-Type', 'text/xml; charset=UTF-8');
     $response->format = $response::FORMAT_RAW;
     $lastPost = Post::find()->where(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC])->one();
     return $this->renderPartial('index', ['title' => Option::get('sitetitle'), 'description' => Option::get('tagline'), 'link' => Yii::$app->request->absoluteUrl, 'lastBuildDate' => new \DateTime($lastPost->post_date, new \DateTimeZone(Option::get('time_zone'))), 'postTypes' => PostType::find()->all(), 'language' => Yii::$app->language, 'generator' => 'http://www.writesdown.com']);
 }
开发者ID:wozhen,项目名称:yii2-cms-writedown,代码行数:12,代码来源:FeedController.php

示例5: setTheme

 /**
  * Set theme params
  *
  * @param Application $app the application currently running
  */
 protected function setTheme($app)
 {
     /* THEME CONFIG */
     $paramsPath = Yii::getAlias('@themes/') . Option::get('theme') . '/config/params.php';
     if (is_file($paramsPath)) {
         $params = (require $paramsPath);
         if ($backendParams = ArrayHelper::getValue($params, 'backend')) {
             $app->params = ArrayHelper::merge($app->params, $backendParams);
         }
     }
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:16,代码来源:BackendBootstrap.php

示例6: actionIndex

 /**
  * Displaying feed.
  *
  * @return string
  */
 public function actionIndex()
 {
     /* @var $lastPost \common\models\Post */
     $response = Yii::$app->response;
     $response->headers->set('Content-Type', 'text/xml; charset=UTF-8');
     $response->format = $response::FORMAT_RAW;
     // Get first post and all posts
     $lastPost = Post::find()->where(['status' => Post::STATUS_PUBLISH])->andWhere(['<=', 'date', date('Y-m-d H:i:s')])->orderBy(['id' => SORT_DESC])->one();
     $posts = Post::find()->where(['status' => Post::STATUS_PUBLISH])->andWhere(['<=', 'date', date('Y-m-d H:i:s')])->limit(Option::get('posts_per_rss'))->orderBy(['id' => SORT_DESC])->all();
     return $this->renderPartial('index', ['title' => Option::get('sitetitle'), 'description' => Option::get('tagline'), 'link' => Yii::$app->request->absoluteUrl, 'lastBuildDate' => new \DateTime($lastPost->date, new \DateTimeZone(Option::get('time_zone'))), 'language' => Yii::$app->language, 'generator' => 'http://www.writesdown.com', 'posts' => $posts, 'rssUseExcerpt' => Option::get('rss_use_excerpt')]);
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:16,代码来源:DefaultController.php

示例7: setTheme

 /**
  * Set theme params
  *
  * @param Application $app the application currently running
  */
 protected function setTheme($app)
 {
     /* THEME CONFIG */
     $themeParamPath = Yii::getAlias('@themes/') . Option::get('theme') . '/config/params.php';
     if (is_file($themeParamPath)) {
         $themeParam = (require $themeParamPath);
         if (isset($themeParam['backend'])) {
             $app->params = ArrayHelper::merge($app->params, $themeParam['backend']);
         }
     }
 }
开发者ID:tampaphp,项目名称:app-cms,代码行数:16,代码来源:BackendBootstrap.php

示例8: init

 /**
  * @inheritdoc
  */
 public function init()
 {
     $theme = Option::get('theme');
     $searchForm = Yii::getAlias('@themes/' . $theme . '/layouts/search-form.php');
     if (is_file($searchForm)) {
         $this->_searchForm = $searchForm;
     } else {
         $this->_searchForm = __DIR__ . '/views/search-form.php';
     }
     parent::init();
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:14,代码来源:SearchWidget.php

示例9: setTheme

 /**
  * Set theme params
  *
  * @param Application $app the application currently running
  */
 protected function setTheme($app)
 {
     $app->view->theme->basePath = '@themes/' . Option::get('theme');
     $app->view->theme->baseUrl = '@web/themes/' . Option::get('theme');
     $app->view->theme->pathMap = ['@app/views' => '@themes/' . Option::get('theme'), '@app/views/post' => '@themes/' . Option::get('theme') . '/post'];
     $paramsPath = Yii::getAlias('@themes/') . Option::get('theme') . '/config/params.php';
     if (is_file($paramsPath)) {
         $params = (require $paramsPath);
         if ($frontendParams = ArrayHelper::getValue($params, 'frontend')) {
             $app->params = ArrayHelper::merge($app->params, $frontendParams);
         }
     }
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:18,代码来源:FrontendBootstrap.php

示例10: sendEmail

 /**
  * Sends an email with a link, for resetting the password.
  *
  * @return boolean whether the email was send
  */
 public function sendEmail()
 {
     /* @var $user User */
     $user = User::findOne(['status' => User::STATUS_ACTIVE, 'email' => $this->email]);
     if ($user) {
         if (!User::isPasswordResetTokenValid($user->password_reset_token)) {
             $user->generatePasswordResetToken();
         }
         if ($user->save()) {
             return Yii::$app->mailer->compose(['html' => 'passwordResetToken-html', 'text' => 'passwordResetToken-text'], ['user' => $user])->setFrom([Option::get('admin_email') => Yii::$app->name . ' robot'])->setTo($this->email)->setSubject('Password reset for ' . Yii::$app->name)->send();
         }
     }
     return false;
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:19,代码来源:PasswordResetRequestForm.php

示例11: actionIndex

 /**
  * Render option form for sitemap in backend.
  *
  * @return string
  */
 public function actionIndex()
 {
     $option = Option::get($this->_optionName);
     if (!$option) {
         return $this->redirect(['install']);
     }
     $postTypes = PostType::find()->all();
     $taxonomies = Taxonomy::find()->all();
     if ($post = Yii::$app->request->post('Option')) {
         if (Option::set($this->_optionName, $post['option_value'])) {
             return $this->redirect(['index']);
         }
     }
     return $this->render('index', ['option' => $option, 'postTypes' => $postTypes, 'taxonomies' => $taxonomies]);
 }
开发者ID:pramana08,项目名称:app-cms,代码行数:20,代码来源:DefaultController.php

示例12: signup

 /**
  * Signs user up.
  *
  * @return User|null the saved model or null if saving fails
  */
 public function signup()
 {
     if ($this->validate()) {
         $user = new User();
         $user->username = $this->username;
         $user->email = $this->email;
         $user->setPassword($this->password);
         $user->generateAuthKey();
         if ($user->save()) {
             Yii::$app->authManager->assign(Yii::$app->authManager->getRole(Option::get('default_role')), $user->id);
             return $user;
         }
     }
     return null;
 }
开发者ID:tampaphp,项目名称:app-cms,代码行数:20,代码来源:SignupForm.php

示例13: actionView

 /**
  * Displays a single Term model.
  *
  * @param integer $id Term ID
  * @param null $slug Term slug
  * @throws \yii\web\NotFoundHttpException
  * @return mixed
  */
 public function actionView($id = null, $slug = null)
 {
     $render = 'view';
     if ($id) {
         $model = $this->findModel($id);
     } elseif ($slug) {
         $model = $this->findModelBySlug($slug);
     } else {
         throw new NotFoundHttpException(Yii::t('writesdown', 'The requested page does not exist.'));
     }
     $query = $model->getPosts()->andWhere(['status' => 'publish'])->andWhere(['<=', 'date', date('Y-m-d H:i:s')])->orderBy(['date' => SORT_DESC]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Option::get('posts_per_page')]);
     $posts = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (is_file($this->view->theme->basePath . '/term/view-' . $model->taxonomy->name . '.php')) {
         $render = 'view-' . $model->taxonomy->name;
     }
     return $this->render($render, ['posts' => $posts, 'pages' => $pages, 'term' => $model]);
 }
开发者ID:writesdown,项目名称:app-cms,代码行数:27,代码来源:TermController.php

示例14: actionView

 /**
  * Displays a single Term model.
  *
  * @param integer $id
  * @param null    $term_slug
  *
  * @throws \yii\web\NotFoundHttpException
  * @return mixed
  */
 public function actionView($id = null, $term_slug = null)
 {
     $render = 'view';
     if ($id) {
         $model = $this->findModel($id);
     } else {
         if ($term_slug) {
             $model = $this->findModelBySlug($term_slug);
         } else {
             throw new NotFoundHttpException('The requested page does not exist.');
         }
     }
     $query = $model->getPosts()->andWhere(['post_status' => 'publish'])->orderBy(['id' => SORT_DESC]);
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => Option::get('posts_per_page')]);
     $posts = $query->offset($pages->offset)->limit($pages->limit)->all();
     if (is_file($this->getViewPath() . "/view-" . $model->taxonomy->taxonomy_slug . '.php')) {
         $render = 'view-' . $model->taxonomy->taxonomy_slug;
     }
     return $this->render($render, ['posts' => $posts, 'pages' => $pages, 'model' => $model]);
 }
开发者ID:wozhen,项目名称:yii2-cms-writedown,代码行数:30,代码来源:TermController.php

示例15: elseif

    ?>
        <?php 
    if (Option::get('comment_registration') && Yii::$app->user->isGuest) {
        ?>
            <h3>
                <?php 
        echo Yii::t('writesdown', 'You must login to leave a reply, ');
        ?>

                <?php 
        echo Html::a(Yii::t('writesdown', 'Login'), Yii::$app->urlManagerBack->createUrl(['site/login']));
        ?>

            </h3>
        <?php 
    } elseif (Option::get('close_comments_for_old_posts') && $dateInterval->d >= Option::get('close_comments_days_old')) {
        ?>
            <h3><?php 
        echo Yii::t('writesdown', 'Comments are closed');
        ?>
</h3>;
        <?php 
    } else {
        ?>
            <?php 
        echo $this->render('_form', ['model' => $comment, 'media' => $media]);
        ?>
        <?php 
    }
    ?>
    <?php 
开发者ID:writesdown,项目名称:app-cms,代码行数:31,代码来源:comments.php


注:本文中的common\models\Option::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。