Esempio n. 1
0
 /**
  * Формирование ссылки
  *
  * @param array $rowParams
  * @param string $value
  * @return string
  */
 public function Url($rowParams = [], $value = "", $item = [])
 {
     $params = $this->MakeRowParams($rowParams["params"]);
     list($module_name) = explode("/", yii::$app->request->pathInfo);
     $url = new \app\modelsActiveRecords\DinamicModel();
     $url->setTableName('module');
     $module = $url->find()->select("id")->where(["name" => $module_name])->asArray()->one();
     $module_id = $module["id"];
     $url->setTableName('url');
     $tag = Html::label($rowParams["label"], $rowParams["name"]);
     $getUrl = $url->find()->where(["page_id" => $value])->asArray()->one();
     $model_admin = new \app\base\ModelAdmin();
     $id = !empty($value) ? $value : $model_admin->GetLastInsertId($rowParams["model_id"]);
     if (yii::$app->request->post()) {
         $urlField = yii::$app->request->post($rowParams["name"]);
         $actionField = yii::$app->request->post('action');
         $findUrl = $url->find()->where(["page_id" => $id])->one();
         if ($findUrl) {
             $findUrl->page_id = $id;
             $findUrl->url = $urlField;
             $findUrl->module = $module_id;
             $findUrl->action = !empty($actionField) ? $actionField : "index";
             $findUrl->save();
         } else {
             $url->page_id = $id;
             $url->url = $urlField;
             $url->module = $module_id;
             $url->action = !empty($actionField) ? $actionField : "index";
             $url->save();
         }
     }
     $tag .= Html::textInput($this->ReturnGroup($rowParams), $getUrl["url"], $params);
     $tag .= Html::a('', 'javascript:void(0)', ['class' => 'fa fa-link', 'style' => 'text-decoration:none; margin-left:5px;', 'onclick' => 'TranslyteEn_ru("#name")']);
     return $tag;
 }
 /**
  * Создание действия для страницы
  */
 public function __ModelCreateActionsForPage($rowParams = [], $value = "", $item = [])
 {
     $params = $this->MakeRowParams($rowParams["params"]);
     $model = new \app\modelsActiveRecords\DinamicModel();
     $model->setTableName($params["table"]);
     $id = !empty(yii::$app->request->get('id')) ? yii::$app->request->get('id') : 0;
     if (yii::$app->request->isPost) {
         $model_admin = new \app\base\ModelAdmin();
         $id = !empty($id) ? $id : $model_admin->GetLastInsertId($rowParams["model_id"]);
         $data = yii::$app->request->post($rowParams['name']);
         $model = new \app\modelsActiveRecords\Actions();
         $model->Add($id, $data);
     }
     $tag = Html::a(Html::tag('i', "", ["class" => "fa fa-plus"]) . 'Добавить действие', 'javascript:void(0)', ["onclick" => "addAction(this, '{$rowParams['name']}')"]);
     $tag .= Html::beginTag('table', ["style" => "width:440px"]);
     $data = $model->find()->where(["page_id" => $id])->asArray()->all();
     if ($data) {
         foreach ($data as $index => $value) {
             $tag .= Html::beginTag('tr');
             $tag .= Html::tag('td', Html::textInput("{$rowParams['name']}[{$index}][name]", $value["name"]));
             $tag .= Html::tag('td', Html::textInput("{$rowParams['name']}[{$index}][value]", $value["value"]));
             $tag .= Html::tag('td', html::a('Удалить', 'javascript:void(0)', ['onclick' => 'removeRow(this)']));
             $tag .= Html::endTag('tr');
         }
     }
     $tag .= Html::endTag('table');
     return $tag;
 }