示例#1
0
 /**
  * Updates an existing Banner 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->save()) {
         foreach (Property::getLanguages() as $lang) {
             $file = UploadedFile::getInstanceByName('image_' . $lang);
             if (!is_null($file)) {
                 ImageManager::addBannerImage($model->id, $file, $lang);
             }
         }
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         return $this->render('update', ['model' => $model]);
     }
 }
示例#2
0
?>
"><img src="<?php 
echo Yii::getAlias('@web/images/logo.png');
?>
"></a>
            </div>
            <div class="col-md-7" id="top-search">
                <div style="text-align: right;display: none">
                    <?php 
echo Menu::widget(['items' => $topLinks, 'options' => ['id' => 'top-links']]);
?>
                </div>
                <div style="text-align: right;margin-top: 20px;">
                    <ul id="top-langs">
                        <?php 
foreach (\app\models\Property::getLanguages() as $lang) {
    ?>
                            <?php 
    if (Yii::$app->language == $lang) {
        ?>
                                <li><span class="flag flag-<?php 
        echo $lang;
        ?>
 selected"><?php 
        echo $languages[$lang];
        ?>
</span></li>
                            <?php 
    } else {
        ?>
                                <li><a href="<?php 
示例#3
0
 public function from_array($arr)
 {
     $this->setAttributes($arr);
     if ($this->save()) {
         foreach (Property::getLanguages() as $lang) {
             $pLang = $this->getProductLang($lang, true);
             if (array_key_exists($lang . ':name', $arr)) {
                 $pLang->name = $arr[$lang . ':name'];
             }
             if (array_key_exists($lang . ':description', $arr)) {
                 $pLang->description = $arr[$lang . ':description'];
             }
             if (array_key_exists($lang . ':information', $arr)) {
                 $pLang->information = $arr[$lang . ':information'];
             }
             $pLang->save();
         }
         return true;
     } else {
         return false;
     }
 }