예제 #1
0
파일: index.php 프로젝트: bariew/sitown
use yii\grid\GridView;
use bariew\yii2Tools\helpers\GridHelper;
use app\modules\poll\models\Question;
use app\modules\code\models\PullRequest;
/* @var $this yii\web\View */
/* @var $searchModel app\modules\poll\models\QuestionSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('modules/poll', 'Questions');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="question-index">

    <h1>
        <?php 
echo Html::encode($this->title);
?>
        <span class="pull-right"><?php 
echo \bariew\yii2Tools\helpers\HtmlHelper::linkDropdown(Yii::t('modules/poll', 'Create Question'), array_map(function (&$v) {
    return $v = ['/poll/question/create', 'type' => $v];
}, array_flip($searchModel::typeList())));
?>
        </span>
    </h1>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'summary' => false, 'columns' => ['title', GridHelper::listFormat($searchModel, 'type'), 'created_at:date', 'url:url', ['attribute' => 'status', 'format' => 'raw', 'value' => function ($data) {
    return $data->link;
}, 'filter' => $searchModel::statusList()]]]);
?>
</div>
예제 #2
0
 /**
  * Runs access methods for view event.
  * @param Event $event view event.
  * @return bool
  */
 public function responseAfterPrepare(Event $event)
 {
     if (!Yii::$app instanceof Application) {
         return true;
     }
     $doc = \phpQuery::newDocumentHTML($event->sender->content);
     foreach ($doc->find('a') as $el) {
         $link = pq($el);
         if (!($rule = HtmlHelper::urlToPath($link->attr('href')))) {
             continue;
         }
         if (!$this->checkAccess(Yii::$app->user->id, implode('/', $rule))) {
             $link->remove();
         }
     }
     foreach ($doc->find('ul.dropdown-menu') as $el) {
         $ul = pq($el);
         if (!$ul->find('a[href!="#"]')->length) {
             $ul->parent('li.dropdown')->addClass('hide');
         }
     }
     $event->sender->content = $doc;
 }
예제 #3
0
 public function prettyPrint($attribute)
 {
     return HtmlHelper::arrayPrettyPrint($this->labeledAttribute($attribute));
 }