Beispiel #1
0
 /**
  * Creates a new Content model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate($node_id = 1)
 {
     $model = new Content();
     $nodeinfo = Node::findOne($node_id);
     $cm_id = $nodeinfo['cm_id'];
     $model->setCm($cm_id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('create', ['model' => $model, 'nodeinfo' => $nodeinfo]);
     }
 }
Beispiel #2
0
    <?php 
$form = ActiveForm::begin(['layout' => 'horizontal', 'fieldConfig' => ['template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}", 'horizontalCssClasses' => ['label' => 'col-lg-2', 'wrapper' => 'col-lg-8', 'error' => 'col-lg-8', 'hint' => 'col-lg-8']]]);
?>

    <?php 
echo $form->field($model, 'site_id')->hiddenInput()->label(false);
?>


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

    <?php 
echo $form->field($model, 'is_real')->inline(true)->radioList(Node::isReal())->hint(Yii::t('app', 'V Nodes can link other real nodes'), ['class' => 'help-block col-lg-offset-2 col-lg-10']);
?>

    <?php 
echo $form->field($model, 'v_nodes')->textarea(['rows' => 2]);
?>
    <?php 
echo Html::activeHiddenInput($model, 'parent');
?>
    <?php 
echo $form->field($model, 'cm_id')->dropDownList(ArrayHelper::map(Cm::find()->all(), 'id', 'name'), ['prompt' => Yii::t('app', 'Please select content model')])->hint(Yii::t('app', 'When selected ,can not modify'));
?>

    <?php 
echo $form->field($model, 'parent_txt')->textInput(['placeHolder' => Yii::t('app', 'Please input Node id or Node name to select') . Yii::t('app', 'When selected ,can not modify')]);
?>
Beispiel #3
0
$this->title = Yii::t('app', 'Nodes');
$this->params['breadcrumbs'][] = ['label' => $site->name, 'url' => ['index', 'site_id' => $site->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="node-index">


    <form class="form-inline">
        <div class="form-group">
        <?php 
echo Html::a(Yii::t('app', 'Create Node'), ['create', 'site_id' => $site->id], ['class' => 'btn btn-success', 'data-pjax' => 0]);
?>
        <?php 
echo Html::a(Yii::t('app', 'Sort Move Node'), ['sort', 'site_id' => $site->id], ['class' => 'btn btn-success', 'data-pjax' => 0]);
?>
        </div>

    </form>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'rowOptions' => function ($model) {
    return ['id' => 'row_' . $model->id];
}, 'columns' => ['id', ['attribute' => 'name', 'value' => function ($model) {
    return str_repeat('━', $model->depth) . $model->name;
}], ['attribute' => 'is_real', 'value' => function ($model) {
    return Node::isReal()[$model->is_real];
}], ['attribute' => 'status', 'value' => function ($model) {
    return Node::nodeStatus()[$model->status];
}], 'cm.name', ['class' => 'yii\\grid\\ActionColumn']]]);
?>
</div>
Beispiel #4
0
 /**
  * Finds the Node model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Node the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Node::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Beispiel #5
0
use yii\helpers\Html;
use yii\widgets\DetailView;
use backend\models\Node;
/* @var $this yii\web\View */
/* @var $model backend\models\Node */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => $site->name, 'url' => ['index', 'site_id' => $site->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="node-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a(Yii::t('app', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a(Yii::t('app', 'Delete'), ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Yii::t('app', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['id', 'site.name', 'cm.name', 'name', ['attribute' => 'is_real', 'value' => Node::isReal()[$model->is_real]], 'v_nodes:ntext', ['attribute' => 'parent', 'value' => isset($model->father) ? $model->father->name : ''], 'slug', 'workflow.name', 'tpl_index', 'tpl_detail', ['attribute' => 'status', 'value' => Node::nodeStatus()[$model->status]], 'seo_title', 'seo_keyword', 'seo_description']]);
?>

</div>