예제 #1
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';
     //var_dump($id, $post_type); exit;
     if ($id) {
         $postType = $this->findPostType($id);
     } else {
         if ($post_type) {
             $postType = $this->findPostTypeBySlug($post_type);
         } else {
             throw new NotFoundHttpException(Yii::t('content', '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('content', 'The requested page does not exist.'));
     }
 }
예제 #2
0
    ?>
</p>
                    <?php 
    echo Html::a('<i class="fa fa-circle text-success"></i>' . Yii::t('content', 'Online'), ['/user/profile']);
    ?>
                </div>
            </div>
        <?php 
}
?>

        <?php 
$adminSiteMenu[0] = ['label' => Yii::t('content', 'MAIN NAVIGATION'), 'options' => ['class' => 'header'], 'template' => '{label}'];
$adminSiteMenu[1] = ['label' => Yii::t('content', 'Dashboard'), 'icon' => 'fa fa-dashboard', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Home'), 'url' => ['/site/index']]]];
$adminSiteMenu[10] = ['label' => Yii::t('content', 'Media'), 'icon' => 'fa fa-picture-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Media'), 'url' => ['/media/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Media'), 'url' => ['/media/create']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Comments'), 'url' => ['/media-comment/index'], 'visible' => Yii::$app->user->can('editor')]], 'visible' => Yii::$app->user->can('author')];
$adminSiteMenu[20] = ['label' => Yii::t('content', 'Appearance'), 'icon' => 'fa fa-paint-brush', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Menus'), 'url' => ['/menu/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Themes'), 'url' => ['/theme/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Widgets'), 'url' => ['/widget/index']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[23] = ['label' => Yii::t('content', 'Modules'), 'icon' => 'fa fa-laptop', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Modules'), 'url' => ['/module/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Module'), 'url' => ['/module/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[30] = ['label' => Yii::t('content', 'Post Types'), 'icon' => 'fa fa-files-o', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Post Types'), 'url' => ['/post-type/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Post Type'), 'url' => ['/post-type/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[40] = ['label' => Yii::t('content', 'Taxonomies'), 'icon' => 'fa fa-tags', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Taxonomies'), 'url' => ['/taxonomy/index']], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New Taxonomy'), 'url' => ['/taxonomy/create']]], 'visible' => Yii::$app->user->can('administrator')];
$adminSiteMenu[50] = ['label' => Yii::t('content', 'Users'), 'icon' => 'fa fa-user', 'items' => [['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'All Users'), 'url' => ['/user/index'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'Add New User'), 'url' => ['/user/create'], 'visible' => Yii::$app->user->can('administrator')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', 'My Profile'), 'url' => ['/user/profile'], 'visible' => Yii::$app->user->can('subscriber')], ['icon' => 'fa fa-circle-o', 'label' => Yii::t('content', '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']);
}
// Short menu by index
ksort($adminSiteMenu);
echo MainSidebar::widget(['items' => $adminSiteMenu]);
?>
    </section>
</aside>
예제 #3
0
 /**
  * @inheritdoc
  */
 public function behaviors()
 {
     return ['access' => ['class' => AccessControl::className(), 'rules' => [['actions' => ['login', 'request-password-reset', 'reset-password', 'forbidden', 'not-found', 'terms'], 'allow' => true], ['actions' => ['logout', 'index', 'error'], 'allow' => true, 'roles' => ['@']], ['actions' => ['signup'], 'allow' => true, 'matchCallback' => function ($rule, $action) {
         return Option::get('allow_signup') && Yii::$app->user->isGuest;
     }]]], 'verbs' => ['class' => VerbFilter::className(), 'actions' => ['logout' => ['post']]]];
 }
예제 #4
0
            <div class="col-xs-4">
                <?php 
echo Html::submitButton('Signin', ['class' => 'btn btn-primary btn-block btn-flat', 'name' => 'signin-button']);
?>
            </div>
        </div>
        <?php 
ActiveForm::end();
?>

        <?php 
echo Html::a(Yii::t('content', 'Reset Password'), ['/site/request-password-reset']);
?>

        <br/>

        <?php 
echo Option::get('allow_signup') ? Html::a(Yii::t('content', 'Register a new membership'), ['/site/signup']) : "";
?>

    </div>

    <br/>

    <?php 
echo Html::a('<i class="fa fa-home"></i> ' . Yii::t('content', 'Back to {sitetitle}', ['sitetitle' => Option::get('sitetitle')]), Yii::$app->urlManagerFront->createUrl(['/site/index']), ['class' => 'btn btn-block btn-success']);
?>

</div>

예제 #5
0
 /**
  * Search post by title and content
  *
  * @param $s
  *
  * @return string
  * @throws \yii\web\NotFoundHttpException
  */
 public function actionSearch($s)
 {
     $query = Post::find()->orWhere(['LIKE', 'post_title', $s])->orWhere(['LIKE', 'post_content', $s])->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) {
         return $this->render('/site/search', ['posts' => $posts, 'pages' => $pages, 's' => $s]);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }