示例#1
0
 /**
  * Update meta data for current post.
  *
  * @param $meta_name
  * @param $meta_value
  *
  * @return bool
  */
 public function upMeta($meta_name, $meta_value)
 {
     $model = PostMeta::find()->andWhere(['meta_name' => $meta_name])->andWhere(['post_id' => $this->id])->one();
     if (is_array($meta_value) || is_object($meta_value)) {
         $meta_value = Json::encode($meta_value);
     }
     $model->meta_value = $meta_value;
     return $model->save();
 }
示例#2
0
 /**
  * Update activated widget via ajax.
  *
  * @param $id integer
  */
 public function actionAjaxUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         $model->widget_config = Json::encode($model->widget_config);
         $model->save();
     }
 }
示例#3
0
 /**
  * Update meta data for current media.
  *
  * @param $meta_name
  * @param $meta_value
  *
  * @return bool
  */
 public function upMeta($meta_name, $meta_value)
 {
     /* @var $model \common\models\MediaMeta */
     $model = MediaMeta::find()->andWhere(['meta_name' => $meta_name])->andWhere(['media_id' => $this->id])->one();
     if (is_array($meta_value) || is_object($meta_value)) {
         $meta_value = Json::encode($meta_value);
     }
     $model->meta_value = $meta_value;
     return $model->save();
 }
示例#4
0
 /**
  * Updates an existing Module model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param integer $id
  *
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post())) {
         $model->module_config = Json::encode($model->module_config);
         if ($model->save()) {
             return $this->redirect(['index']);
         }
     }
     return $this->render('update', ['model' => $model]);
 }
示例#5
0
 /**
  * Update option with name as key.
  *
  * @param string $name
  * @param string|array $value
  * @return bool
  */
 public static function up($name, $value)
 {
     /* @var $model \common\models\Option */
     $model = static::findOne(['name' => $name]);
     if (is_array($value) || is_object($value)) {
         $model->value = Json::encode($value);
     } else {
         $model->value = $value;
     }
     return $model->save();
 }
示例#6
0
文件: Post.php 项目: ochiem/app-cms
 /**
  * Update meta data for current post.
  *
  * @param $meta_name
  * @param $meta_value
  *
  * @return bool
  */
 public function upMeta($meta_name, $meta_value)
 {
     /* @var $model \common\models\PostMeta */
     $model = PostMeta::findOne(['meta_name' => $meta_name, 'post_id' => $this->id]);
     if (is_array($meta_value) || is_object($meta_value)) {
         $meta_value = Json::encode($meta_value);
     }
     $model->meta_value = $meta_value;
     return $model->save();
 }
示例#7
0
                                </div>
                            </div>
                        </div>
                    </div>
                </form>
                <div class="library-left">
                    <ul class="media-container clearfix"></ul>
                </div>
                <div class="library-right">
                    <div class="media-details"></div>
                    <div class="media-form"></div>
                </div>
                <div class="library-footer">
                    <?php 
echo Html::button(Yii::t('writesdown', 'Insert Media'), ['class' => 'insert-media btn btn-primary pull-right btn-flat']);
?>
                </div>
            </div>
        </div>
    </div>
</div>
<?php 
echo $this->render('_template-upload');
echo $this->render('_template-download');
echo $this->render('_template-details');
echo $this->render('_template-form', ['model' => $model]);
$options = Json::encode(['url' => ['json' => Url::to(['get-json']), 'update' => Url::to(['/media/ajax-update']), 'upload' => Url::to(['/media/ajax-upload']), 'insert' => Yii::$app->request->get('editor', false) ? Url::to(['editor-insert']) : Url::to(['field-insert'])], 'editor' => (bool) Yii::$app->request->get('editor', false), 'multiple' => (bool) Yii::$app->request->get('multiple', false), 'callback' => Yii::$app->request->get('callback', false)]);
$this->registerJs('jQuery("#media-browser").mediabrowser(' . $options . ')');
?>

示例#8
0
 /**
  * Update option with option_name as key.
  *
  * @param string       $option_name
  * @param string|array $option_value
  *
  * @return bool
  */
 public static function up($option_name, $option_value)
 {
     /* @var $model \common\models\Option */
     $model = static::find()->where(['option_name' => $option_name])->one();
     if (is_array($option_value) || is_object($option_value)) {
         $model->option_value = Json::encode($option_value);
     } else {
         $model->option_value = $option_value;
     }
     return $model->save();
 }
 /**
  * Generate response in the form of a string of json.
  *
  * @param bool $printResponse
  *
  * @return array
  */
 public function getResponse($printResponse = true)
 {
     if ($printResponse) {
         $this->head();
         $content = Json::encode($this->response);
         $redirect = stripslashes(Yii::$app->request->getQueryParam('redirect'));
         if ($redirect) {
             $this->setHeader('Location', sprintf($redirect, rawurlencode($content)));
             return null;
         }
         echo $content;
     }
     return $this->response;
 }
 /**
  * Insert URL of media to input field.
  *
  * @return string
  */
 public function actionFieldInsert()
 {
     $files = [];
     foreach (Yii::$app->request->post('Media') as $media) {
         $mediaUploadHandler = new MediaUploadHandler(null, false);
         $file = $mediaUploadHandler->get(ArrayHelper::getValue($media, 'id'), $mediaUploadHandler::NOT_PRINT_RESPONSE);
         $files[] = ArrayHelper::getValue($file, 'file');
     }
     return Json::encode($files);
 }
示例#11
0
 /**
  * Update meta data for current media.
  *
  * @param string $name
  * @param string|array $value
  * @return bool
  */
 public function upMeta($name, $value)
 {
     /* @var $model \common\models\MediaMeta */
     $model = MediaMeta::findOne(['name' => $name, 'media_id' => $this->id]);
     if (is_array($value) || is_object($value)) {
         $value = Json::encode($value);
     }
     $model->value = $value;
     return $model->save();
 }