Beispiel #1
0
 /**
  * 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]);
 }
Beispiel #2
0
 /**
  * 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.');
     }
 }
Beispiel #3
0
 /**
  * @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.'));
     }
 }
Beispiel #4
0
 /**
  * 获取网站配置数组
  * @return array
  */
 public static function getOptions()
 {
     if (self::$_options == null) {
         $options = \common\models\Option::find()->asArray()->all();
         self::$_options = yii\helpers\ArrayHelper::map($options, 'name', 'value');
     }
     return self::$_options;
 }
Beispiel #5
0
 public function saveForm()
 {
     if (!$this->validate()) {
         return false;
     }
     Option::updateOption(ArrayHelper::toArray($this));
     return true;
 }
 /**
  * Deletes an existing Template model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     Option::deleteAll(['template_id' => $id]);
     $model->delete();
     Yii::$app->getSession()->setFlash('template-delete-success');
     return $this->redirect(['index']);
 }
Beispiel #7
0
 /**
  * @return bool
  * Динамическая валидация
  * @TODO  Углубленная валидация списков (с проверкой наличия базы), изображений
  */
 public function beforeValidate()
 {
     /** @var \common\models\Option $option */
     $option = Option::findOne($this->option_id);
     if ($option) {
         switch ($option->type) {
             case 1:
                 //число целое
             //число целое
             case 4:
                 //выключатель
             //выключатель
             case 8:
                 //список дочерних документов
             //список дочерних документов
             case 9:
                 //список потомков документа
             //список потомков документа
             case 10:
                 //список пользователей
                 $this->validators[] = Validator::createValidator('integer', $this, 'value');
                 break;
             case 2:
                 //число
                 $this->validators[] = Validator::createValidator('double', $this, 'value');
                 break;
             case 3:
                 //строка
             //строка
             case 5:
                 //текст
             //текст
             case 6:
                 //файл (выбор)
                 $this->validators[] = Validator::createValidator('string', $this, 'value');
                 break;
             case 7:
                 //изображение (загрузка)
                 $this->validators[] = Validator::createValidator('image', $this, 'file', ['minHeight' => 100, 'skipOnEmpty' => true]);
                 break;
             case 11:
                 //регулярное выражение
                 $pattern = $option->param ? $option->param : '\\w';
                 $this->validators[] = Validator::createValidator('match', $this, 'value', ['pattern' => $pattern]);
                 break;
         }
         if ($option->require) {
             if ($option->type == 7) {
                 if (!$this->value) {
                     $this->validators[] = Validator::createValidator('required', $this, 'file');
                 }
             } else {
                 $this->validators[] = Validator::createValidator('required', $this, 'value');
             }
         }
     }
     return true;
 }
 /**
  * @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']);
 }
 /**
  * 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);
         }
     }
 }
Beispiel #10
0
 /**
  * @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();
 }
Beispiel #11
0
 /**
  * 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']);
         }
     }
 }
 /**
  * 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')]);
 }
Beispiel #13
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OptionModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'value', $this->value])->andFilterWhere(['like', 'label', $this->label])->andFilterWhere(['like', 'group', $this->group]);
     return $dataProvider;
 }
 /**
  * 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);
         }
     }
 }
Beispiel #15
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = OptionModel::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id]);
     $query->andFilterWhere(['like', 'option_name', $this->option_name])->andFilterWhere(['like', 'option_value', $this->option_value])->andFilterWhere(['like', 'option_label', $this->option_label])->andFilterWhere(['like', 'option_group', $this->option_group]);
     return $dataProvider;
 }
 /**
  * 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;
 }
Beispiel #17
0
 public function testGroup(FunctionalTester $I)
 {
     $I->wantTo('ensure that setting works');
     $I->amOnPage(Url::to(['/setting/group', 'id' => 'general']));
     $I->see('General Settings', 'h1');
     $I->amGoingTo('update site title and tag line');
     $I->fillField('input[name="Option[sitetitle][option_value]"]', 'My New Website');
     $I->fillField('input[name="Option[tagline][option_value]"]', 'My New Website Tagline');
     $I->click('Save');
     $I->expectTo('see success message');
     $I->see('Settings successfully saved.');
     Option::up('sitetitle', 'WritesDown');
     Option::up('tagline', 'CMS Built with Yii Framework');
 }
Beispiel #18
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $this->scenario = 'search';
     $query = Option::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'template_id' => $this->template_id, 'multiple' => $this->multiple, 'require' => $this->require, 'type' => $this->type]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Beispiel #19
0
 /**
  * @param null $template_id
  * @return array
  */
 public static function getAll($template_id = null)
 {
     $options = [];
     if ($template_id) {
         $model = Option::find()->where(['template_id' => $template_id])->all();
     } else {
         $model = Option::find()->all();
     }
     if ($model) {
         foreach ($model as $m) {
             $options[$m->id] = $m->name;
         }
     }
     return $options;
 }
Beispiel #20
0
 /**
  * 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;
 }
Beispiel #21
0
 /**
  * @param AcceptanceTester $I
  */
 public function testIndex(AcceptanceTester $I)
 {
     $I->wantTo('ensure that index theme works');
     $I->amOnPage(Url::to(['/theme/index']));
     $I->see('Themes', 'h1');
     $I->seeLink('Available Themes');
     $I->seeLink('Add New Theme');
     if (method_exists($I, 'acceptPopup') && method_exists($I, 'wait')) {
         $I->amGoingTo('activate theme');
         $I->click('a[href="' . Url::to(['/theme/install', 'theme' => 'writesdown']) . '"]');
         $I->acceptPopup();
         $I->wait(3);
         $I->expectTo('see theme installed');
         $I->see('Installed');
         Option::up('theme', 'default');
     }
 }
Beispiel #22
0
 /**
  * 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]);
 }
 /**
  * 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]);
 }
 /**
  * Returns the maximum number of allowed requests and the window size.
  * @param \yii\web\Request $request the current request
  * @param \yii\base\Action $action the action to be executed
  * @return array an array of two elements. The first element is the maximum number of allowed requests,
  * and the second element is the size of the window in seconds.
  */
 public function getRateLimit($request, $action)
 {
     $allow = 10;
     $window = 600;
     $route = $action->controller->route;
     $rate_limit_name = Module::getApiName($route);
     $rate_limit_option = Option::findOne(['name' => $rate_limit_name]);
     if ($rate_limit_option) {
         try {
             $option = \yii\helpers\Json::decode($rate_limit_option->value);
             if (!array_key_exists('allow', $option) || !is_numeric($option['allow']) || !is_int($option['allow']) || $option['allow'] < 0 || $option['allow'] > Option::RATE_LIMIT_ALLOW_MAX) {
                 throw new \yii\base\InvalidParamException('Invalid allow value.');
             }
             if (!array_key_exists('window', $option) || !is_numeric($option['window']) || !is_int($option['window']) || $option['window'] < 0 || $option['allow'] > Option::RATE_LIMIT_WINDOW_MAX) {
                 throw new \yii\base\InvalidParamException('Invalid window value.');
             }
         } catch (\Exception $ex) {
             $option['allow'] = $allow;
             $option['window'] = $window;
         }
         return [$option['allow'], $option['window']];
     }
     return [$allow, $window];
 }
Beispiel #25
0
    ?>
        <?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 
Beispiel #26
0
</p>
                    <?php 
    echo Html::a('<i class="fa fa-circle text-success"></i>' . Yii::t('writesdown', 'Online'), ['/user/profile']);
    ?>
                </div>
            </div>
        <?php 
}
?>

        <?php 
$adminSiteMenu[0] = ['label' => Yii::t('writesdown', 'MAIN NAVIGATION'), 'options' => ['class' => 'header'], 'template' => '{label}'];
$adminSiteMenu[1] = ['label' => Yii::t('writesdown', 'Dashboard'), 'icon' => 'fa fa-dashboard', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Home'), 'url' => ['/site/index']]]];
$adminSiteMenu[10] = ['label' => Yii::t('writesdown', 'Media'), 'icon' => 'fa fa-picture-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Media'), 'url' => ['/media/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Media'), 'url' => ['/media/create']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Comments'), 'url' => ['/media-comment/index'], 'visible' => Yii::$app->user->can('editor')]], 'visible' => Yii::$app->user->can('author')];
$adminSiteMenu[20] = ['label' => Yii::t('writesdown', 'Appearance'), 'icon' => 'fa fa-paint-brush', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Menus'), 'url' => ['/menu/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Themes'), 'url' => ['/theme/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Widgets'), 'url' => ['/widget/index']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[23] = ['label' => Yii::t('writesdown', 'Modules'), 'icon' => 'fa fa-laptop', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Modules'), 'url' => ['/module/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Module'), 'url' => ['/module/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[30] = ['label' => Yii::t('writesdown', 'Post Types'), 'icon' => 'fa fa-files-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Post Types'), 'url' => ['/post-type/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Post Type'), 'url' => ['/post-type/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[40] = ['label' => Yii::t('writesdown', 'Taxonomies'), 'icon' => 'fa fa-tags', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Taxonomies'), 'url' => ['/taxonomy/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New Taxonomy'), 'url' => ['/taxonomy/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[50] = ['label' => Yii::t('writesdown', 'Users'), 'icon' => 'fa fa-user', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'All Users'), 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Add New User'), 'url' => ['/user/create'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'My Profile'), 'url' => ['/user/profile'], 'visible' => Yii::$app->user->can('subscriber')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('writesdown', 'Reset Password'), 'url' => ['/user/reset-password'], 'visible' => Yii::$app->user->can('subscriber')]]];
$adminSiteMenu = ArrayHelper::merge($adminSiteMenu, PostType::getMenu(2));
$adminSiteMenu = ArrayHelper::merge($adminSiteMenu, Option::getMenu(60));
if (isset(Yii::$app->params['adminSiteMenu']) && is_array(Yii::$app->params['adminSiteMenu'])) {
    $adminSiteMenu = ArrayHelper::merge($adminSiteMenu, Yii::$app->params['adminSiteMenu']);
}
ksort($adminSiteMenu);
echo MainSidebar::widget(['items' => $adminSiteMenu]);
?>

    </section>
</aside>
Beispiel #27
0
 /**
  * @param AcceptanceTester $I
  */
 public function testSignup(AcceptanceTester $I)
 {
     Option::up('allow_signup', '1');
     $I->wantTo('ensure that signup works');
     $signupPage = SignupPage::openBy($I);
     $I->see('Register a new membership', 'p');
     $I->amGoingTo('submit signup form with no data');
     $signupPage->submit([]);
     $I->expectTo('see validations error');
     $I->see('Username cannot be blank.', '.help-block');
     $I->see('Email cannot be blank.', '.help-block');
     $I->see('Password cannot be blank.', '.help-block');
     $I->amGoingTo('submit signup form with no correct email and password');
     $signupPage->submit(['username' => 'newuser', 'email' => 'newuser.email', 'password' => 'pass']);
     $I->expectTo('see that email and password are not correct.');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->see('Email is not a valid email address.', '.help-block');
     $I->see('Password should contain at least 6 characters.', '.help-block');
     $I->amGoingTo('submit signup form with correct data');
     $signupPage->submit(['username' => 'newuser', 'email' => '*****@*****.**', 'password' => 'password']);
     $I->expect('new user saved.');
     $I->dontSee('Username cannot be blank.', '.help-block');
     $I->dontSee('Email is not a valid email address.', '.help-block');
     $I->dontSee('Password should contain at least 6 characters.', '.help-block');
     User::deleteAll(['username' => 'newuser']);
     Option::up('allow_signup', '0');
 }
Beispiel #28
0
 * @date      8/23/2015
 * @time      9:30 PM
 * @author    Agiel K. Saputra <*****@*****.**>
 * @copyright Copyright (c) 2015 WritesDown
 * @license   http://www.writesdown.com/license/
 */
use yii\helpers\Html;
use yii\widgets\LinkPager;
use common\models\Option;
/* @var $this yii\web\View */
/* @var $user common\models\User */
/* @var $posts common\models\Post[] */
/* @var $tags common\models\Term[] */
/* @var $image common\models\Media */
/* @var $pages yii\data\Pagination */
$this->title = Html::encode(Yii::t('writesdown', 'All Posts By {user}', ['user' => $user->display_name]) . ' - ' . Option::get('sitetitle'));
$this->params['breadcrumbs'][] = Html::encode(Yii::t('writesdown', 'All Posts by {user}', ['user' => $user->display_name]));
?>
<div class="archive user-view">
    <header id="archive-header" class="archive-header">
        <h1><?php 
echo Html::encode(Yii::t('writesdown', 'All Posts By {user}', ['user' => $user->display_name]));
?>
</h1>
    </header>
    <?php 
if ($posts) {
    ?>
        <?php 
    foreach ($posts as $post) {
        ?>
Beispiel #29
0
        <p>
            <?php 
    echo Html::a('<strong>' . Yii::t('writesdown', 'Cancel Reply') . '</strong>', '#', ['id' => 'cancel-reply', 'class' => 'cancel-reply', 'style' => 'display:none;']);
    ?>

        </p>
    <?php 
}
?>

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
if (Yii::$app->user->isGuest && Option::get('require_name_email')) {
    ?>
        <div class="row">
            <div class="col-md-7">
                <?php 
    echo $form->field($model, 'comment_author')->textInput();
    ?>

                <?php 
    echo $form->field($model, 'comment_author_email')->textInput(['maxlength' => 100]);
    ?>

                <?php 
    echo $form->field($model, 'comment_author_url')->textInput(['maxlength' => 255]);
    ?>
Beispiel #30
0
]]></category>
                <?php 
    }
    ?>
                <guid isPermaLink="false">
                    <![CDATA[<?php 
    echo Yii::$app->urlManager->createAbsoluteUrl(['post/view', 'id' => $post->id]);
    ?>
]]>
                </guid>
                <description><![CDATA[<?php 
    echo $post->excerpt;
    ?>
]]></description>
                <?php 
    if (!Option::get('rss_use_excerpt')) {
        ?>
                    <content:encoded><![CDATA[<?php 
        echo $post->content;
        ?>
]]></content:encoded>
                <?php 
    }
    ?>
                <wfw:commentRss><![CDATA[<?php 
    echo $post->url;
    ?>
]]></wfw:commentRss>
                <slash:comments><?php 
    echo $post->comment_count;
    ?>