public function actionAddBasic($articleId, $languageId)
 {
     if (!empty($articleId)) {
         $article = Article::findOne($articleId);
         $article_translation = ArticleTranslation::find()->where(['article_id' => $articleId, 'language_id' => $languageId])->one();
         if (empty($article_translation)) {
             $article_translation = new ArticleTranslation();
         }
     } else {
         $article = new Article();
         $article_translation = new ArticleTranslation();
     }
     if (Yii::$app->request->isPost) {
         $article->load(Yii::$app->request->post());
         $article_translation->load(Yii::$app->request->post());
         if ($article->validate() && $article_translation->validate()) {
             $article->save();
             $article_translation->article_id = $article->id;
             $article_translation->language_id = $languageId;
             $article_translation->save();
             Yii::$app->getSession()->setFlash('success', 'Data were successfully modified.');
         } else {
             Yii::$app->getSession()->setFlash('danger', 'Failed to change the record.');
         }
     }
     if (\Yii::$app->request->isPjax) {
         return $this->renderPartial('add-basic', ['article' => $article, 'article_translation' => $article_translation, 'categories' => Category::find()->with('translations')->all(), 'selectedLanguage' => Language::findOne($languageId), 'languages' => Language::findAll(['active' => true])]);
     } else {
         return $this->render('save', ['article' => $article, 'languageId' => $languageId, 'viewName' => 'add-basic', 'params' => ['article' => $article, 'article_translation' => $article_translation, 'categories' => Category::find()->with('translations')->all(), 'selectedLanguage' => Language::findOne($languageId), 'languages' => Language::findAll(['active' => true])]]);
     }
 }
 /**
  * Creates a new DeliveryMethod model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @param integer $id
  * @param integer $languageId
  * @return mixed
  * @throws NotFoundHttpException
  * @throws BadRequestHttpException
  */
 public function actionSave($id = null, $languageId)
 {
     if (!empty($languageId)) {
         if (!empty($id)) {
             $model = $this->findModel($id);
             if (empty($model)) {
                 throw new NotFoundHttpException();
             }
             $modelTranslation = $this->findModelTranslation($id, $languageId);
             if (empty($modelTranslation)) {
                 $modelTranslation = new ProductAvailabilityTranslation();
             }
         } else {
             $model = new ProductAvailability();
             $modelTranslation = new ProductAvailabilityTranslation();
         }
     } else {
         throw new BadRequestHttpException();
     }
     if ($modelTranslation->load(Yii::$app->request->post())) {
         $model->save(false);
         $modelTranslation->availability_id = $model->id;
         $modelTranslation->language_id = $languageId;
         if ($modelTranslation->validate()) {
             $modelTranslation->save();
             return $this->redirect(['save', 'id' => $model->id, 'languageId' => $languageId]);
         }
     }
     return $this->render('save', ['model' => $model, 'modelTranslation' => $modelTranslation, 'languages' => Language::find()->all(), 'selectedLanguage' => Language::findOne($languageId)]);
 }
 public function actionSave($languageId = null, $categoryId = null)
 {
     if (!empty($categoryId)) {
         $category = Category::findOne($categoryId);
         $category_translation = CategoryTranslation::find()->where(['category_id' => $categoryId, 'language_id' => $languageId])->one();
         if (empty($category_translation)) {
             $category_translation = new CategoryTranslation();
         }
     } else {
         $category = new Category();
         $category_translation = new CategoryTranslation();
     }
     if (Yii::$app->request->isPost) {
         $category->load(Yii::$app->request->post());
         $category_translation->load(Yii::$app->request->post());
         if ($category->validate() && $category_translation->validate()) {
             $category->save();
             $category_translation->category_id = $category->id;
             $category_translation->language_id = $languageId;
             $category_translation->save();
             Yii::$app->getSession()->setFlash('success', 'Data were successfully modified.');
             return $this->redirect(Url::toRoute('/articles/category'));
         } else {
             Yii::$app->getSession()->setFlash('danger', 'Failed to change the record.');
         }
     }
     return $this->render('edit', ['category' => $category, 'category_translation' => $category_translation, 'categories' => Category::find()->with('translations')->all(), 'selectedLanguage' => Language::findOne($languageId), 'languages' => Language::findAll(['active' => true])]);
 }
예제 #4
0
 public static function findOrDefault($languageId)
 {
     if (empty($languageId) || !($language = Language::findOne($languageId))) {
         $language = Language::find()->where(['lang_id' => \Yii::$app->sourceLanguage])->one();
     }
     return $language;
 }
예제 #5
0
 public function actionSave($id = null, $languageId = null)
 {
     $selectedLanguage = Language::findOne($languageId);
     if (!empty($id)) {
         $country = ProductCountry::find()->where(['id' => $id])->one();
         $countryTranslation = ProductCountryTranslation::find()->where(['country_id' => $id, 'language_id' => $languageId])->one();
         if (empty($countryTranslation)) {
             $countryTranslation = new ProductCountryTranslation();
         }
     } else {
         $country = new ProductCountry();
         $countryTranslation = new ProductCountryTranslation();
     }
     if (\Yii::$app->request->isPost) {
         $country->load(\Yii::$app->request->post());
         $countryTranslation->load(\Yii::$app->request->post());
         if ($countryTranslation->validate()) {
             $country->save();
             $countryTranslation->country_id = $country->id;
             $countryTranslation->language_id = $selectedLanguage->id;
             $countryTranslation->save();
             return $this->redirect(Url::toRoute('/shop/country'));
         }
     }
     return $this->render('save', ['country' => $country, 'countryTranslation' => $countryTranslation, 'languages' => Language::findAll(['active' => true]), 'selectedLanguage' => $selectedLanguage]);
 }
예제 #6
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (empty($this->languages)) {
         $this->languages = Language::find()->all();
     }
     return $this->render('language-switcher', ['languages' => $this->languages, 'selectedLanguage' => $this->selectedLanguage, 'model' => $this->model]);
 }
 public function getTranslation($languageId = null)
 {
     /* @var $modelClass ActiveRecordInterface */
     /* @var $language ActiveRecordInterface */
     /* @var $translation ActiveRecordInterface */
     $modelClass = $this->translationClass;
     if (!empty($languageId)) {
         $language = Language::findOne($languageId);
         if ($language) {
             $translation = $modelClass::findOne(['language_id' => $language->getPrimaryKey(), $this->relationColumn => $this->owner->getPrimaryKey()]);
             return $translation;
         }
     }
     $language = Language::findOne(['lang_id' => Yii::$app->language]);
     // try to find translation on current language
     $translation = $modelClass::findOne(['language_id' => $language->getPrimaryKey(), $this->relationColumn => $this->owner->getPrimaryKey()]);
     if (!$translation) {
         // get default language
         $language = Language::findOne(['default' => true]);
         // try to find translation on default language
         $translation = $modelClass::findOne(['language_id' => $language->getPrimaryKey(), $this->relationColumn => $this->owner->getPrimaryKey()]);
         if (!$translation) {
             // find any translation
             $translation = $modelClass::findOne([$this->relationColumn => $this->owner->getPrimaryKey()]);
         }
     }
     return $translation;
 }
 public function create()
 {
     if ($this->validate()) {
         $language = new Language();
         $language->name = $this->name;
         $language->lang_id = $this->lang_id;
         $language->active = $this->active;
         $language->show = $this->show;
         if ($language->save()) {
             return true;
         } else {
             throw new RuntimeException('Database exception');
         }
     } else {
         throw new InvalidParamException("Invalid language params");
     }
 }
 /**
  * @inheritdoc
  */
 public function init()
 {
     $this->languages = Language::find()->asArray()->select('lang_id')->where(['active' => true])->all();
     $this->languages = ArrayHelper::getColumn($this->languages, 'lang_id');
     if ($this->languages) {
         if (!$this->enablePrettyUrl) {
             throw new InvalidConfigException('Locale URL support requires enablePrettyUrl to be set to true.');
         }
     }
     $this->_defaultLanguage = Yii::$app->language;
     parent::init();
 }
예제 #10
0
 public function run()
 {
     parent::run();
     $parents = self::findChildren($this->className, null);
     $languages = Language::find()->all();
     foreach ($languages as $key => $language) {
         if ($language->id == $this->languageId) {
             $this->languageId = $key;
         }
     }
     return $this->render('input-tree/index', ['parents' => $parents, 'form' => $this->form, 'model' => $this->model, 'attribute' => $this->attribute, 'languageId' => $this->languageId]);
 }
 public function up()
 {
     $this->createTable('shop_product_availability', ['id' => $this->primaryKey()]);
     $this->createTable('shop_product_availability_translation', ['id' => $this->primaryKey(), 'availability_id' => $this->integer(2), 'language_id' => $this->integer(2), 'title' => $this->string(256), 'description' => $this->string(256)]);
     $language = Language::find()->where(['lang_id' => 'en-US'])->one();
     $this->insert('shop_product_availability', ['id' => 1]);
     $this->insert('shop_product_availability_translation', ['availability_id' => 1, 'language_id' => $language->id, 'title' => 'In stock']);
     $this->insert('shop_product_availability', ['id' => 2]);
     $this->insert('shop_product_availability_translation', ['availability_id' => 2, 'language_id' => $language->id, 'title' => 'Expected']);
     $this->insert('shop_product_availability', ['id' => 3]);
     $this->insert('shop_product_availability_translation', ['availability_id' => 3, 'language_id' => $language->id, 'title' => 'To order']);
     $this->addColumn('shop_product', 'availability', $this->integer());
     $this->addForeignKey('shop_product_availability:shop_product_availability_id', 'shop_product', 'availability', 'shop_product_availability', 'id', 'cascade', 'cascade');
 }
예제 #12
0
 public function run($id = null, $langId = null)
 {
     /* @var GalleryImage $image */
     /* @var GalleryImageTranslation $imageTranslation */
     $language = $langId == null ? Language::getDefault() : Language::findOne($langId);
     if (empty($id)) {
         $image = new GalleryImage();
         $image->show = true;
         $imageTranslation = new GalleryImageTranslation();
     } else {
         $image = GalleryImage::findOne($id);
         if (empty($image)) {
             return $this->controller->redirect('/gallery/album/list');
         }
         $imageTranslation = $image->getTranslation($language->id);
         if (empty($imageTranslation)) {
             $imageTranslation = new GalleryImageTranslation();
         }
     }
     if (Yii::$app->request->isPost) {
         $post = Yii::$app->request->post();
         if ($image->load($post) && $imageTranslation->load($post)) {
             $image->image_file = UploadedFile::getInstance($image, 'image_file');
             if (!empty($image->image_file)) {
                 try {
                     // save image
                     $fileName = $this->generateFileName($image->image_file->baseName);
                     //                        die(\Imagick::getVersion());
                     $imagine = new Imagine();
                     $imagine->open($image->image_file->tempName)->save(Yii::getAlias($this->controller->module->imagesPath . '/' . $fileName . '-original.jpg'))->thumbnail(new Box(400, 400), ImageInterface::THUMBNAIL_OUTBOUND)->save(Yii::getAlias($this->controller->module->imagesPath . '/' . $fileName . '-thumb.jpg'));
                     $image->file_name = $fileName;
                 } catch (\Exception $ex) {
                     $image->addError('image_file', 'File save failed');
                 }
             }
             if ($image->validate() && $imageTranslation->validate()) {
                 $image->save();
                 $imageTranslation->image_id = $image->id;
                 $imageTranslation->language_id = $language->id;
                 $imageTranslation->save();
                 $this->controller->redirect(['edit', 'id' => $image->id, 'langId' => $language->id]);
             }
         }
     }
     return $this->controller->render('create-edit', ['image' => $image, 'imageTranslation' => $imageTranslation, 'currentLanguage' => $language]);
 }
 public function actionSwitchShow()
 {
     $id = \Yii::$app->request->get();
     if (!empty($id) && isset($id)) {
         $item = Language::findOne($id);
         if ($item) {
             $show = $item->show;
             if ($show == 1) {
                 $show = 0;
             } else {
                 $show = 1;
             }
             $item->show = $show;
             $item->save();
         } else {
             return $this->render('/site/error', ['message' => 'Error', 'errors' => 'Language is not found']);
         }
     }
     $this->redirect(['/languages']);
 }
 /**
  * @param string $page_key
  * @param integer $languageId
  * @return mixed
  * @throws BadRequestHttpException
  * @throws BadRequestHttpException
  */
 public function actionSavePage($page_key = null, $languageId = null)
 {
     $selected_language = !empty($languageId) ? Language::findOne($languageId) : Language::findOne(['lang_id' => Yii::$app->language]);
     if (!empty($selected_language)) {
         if (!empty($page_key)) {
             $static_page = StaticPage::findOne($page_key);
             if (!empty($static_page)) {
                 $static_page_translation = StaticPageTranslation::find()->where(['page_key' => $page_key, 'language_id' => $selected_language->id])->one();
                 if (empty($static_page_translation)) {
                     $static_page_translation = new StaticPageTranslation();
                     $static_page_translation->page_key = $static_page->key;
                 }
             } else {
                 throw new BadRequestHttpException('Such static page doesn\'t exist. You can\'t add translation.');
             }
         } else {
             $static_page = new StaticPage();
             $static_page_translation = new StaticPageTranslation();
         }
         if (Yii::$app->request->isPost) {
             if ($static_page_translation->load(Yii::$app->request->post())) {
                 if (empty($static_page->key)) {
                     $static_page->key = $static_page_translation->page_key;
                     if ($static_page->validate()) {
                         $static_page->save();
                     } else {
                         throw new BadRequestHttpException('Sorry, such static page already exist.');
                     }
                 }
                 $static_page_translation->language_id = $selected_language->id;
                 $static_page_translation->save();
             }
         }
         return $this->render('save-page', ['static_page' => $static_page, 'static_page_translation' => $static_page_translation, 'staticPage' => StaticPage::find()->all(), 'selectedLanguage' => $selected_language, 'languages' => Language::findAll(['active' => true])]);
     } else {
         throw new BadRequestHttpException('You can\'t add this static page translation, because such language doesn\'t exist');
     }
 }
예제 #15
0
 /**
  * Creates a URL according to the given route and parameters.
  * @param UrlManager $manager the URL manager
  * @param string $route the route. It should not have slashes at the beginning or the end.
  * @param array $params the parameters
  * @return string|boolean the created URL, or false if this rule cannot be used for creating this URL.
  */
 public function createUrl($manager, $route, $params)
 {
     if (($route == $this->articleRoute || $route == $this->categoryRoute) && !empty($params['id'])) {
         $id = $params['id'];
         $pathInfo = '';
         $parentId = null;
         $language = Language::findOne(['lang_id' => $manager->language]);
         if ($route == $this->articleRoute) {
             $article = Article::findOne($id);
             if ($article->getTranslation($language->id) && $article->getTranslation($language->id)->seoUrl) {
                 $pathInfo = $article->getTranslation($language->id)->seoUrl;
                 $parentId = $article->category_id;
             } else {
                 return false;
             }
         } else {
             if ($route == $this->categoryRoute) {
                 $category = Category::findOne($id);
                 if ($category->getTranslation($language->id) && $category->getTranslation($language->id)->seoUrl) {
                     $pathInfo = $category->getTranslation($language->id)->seoUrl;
                     $parentId = $category->parent_id;
                 } else {
                     return false;
                 }
             }
         }
         while ($parentId != null) {
             $category = Category::findOne($parentId);
             if ($category->getTranslation($language->id) && $category->getTranslation($language->id)->seoUrl) {
                 $pathInfo = $category->getTranslation($language->id)->seoUrl . '/' . $pathInfo;
                 $parentId = $category->parent_id;
             } else {
                 return false;
             }
         }
         if (!empty($this->prefix)) {
             $pathInfo = $this->prefix . $pathInfo;
         }
         return $pathInfo;
     }
     return false;
 }
예제 #16
0
        echo Url::to(['remove', 'id' => $article->id]);
        ?>
" class="glyphicon glyphicon-remove text-danger btn btn-default btn-sm">
                                    </a>
                                </td>
                            </tr>
                        <?php 
    }
    ?>
                        </tbody>
                    <?php 
}
?>
                </table>
                <!-- TODO: languageId -->
                <a href="<?php 
echo Url::to(['/articles/article/save', 'languageId' => Language::getCurrent()->id]);
?>
"
                   class="btn btn-primary pull-right">
                    <i class="fa fa-user-plus"></i> <?php 
echo Yii::t('articles', 'Add');
?>
                </a>
            </div>
        </div>
    </div>
</div>


예제 #17
0
echo Html::encode($this->title);
?>
</h1>


    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'options' => ['class' => 'project-list'], 'summary' => "", 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['headerOptions' => ['class' => 'text-center col-md-1'], 'attribute' => 'product.articulus', 'value' => function ($model) {
    if (!empty($model->product->articulus)) {
        return $model->product->articulus;
    }
    return '';
}, 'label' => Yii::t('shop', 'Articulus'), 'format' => 'html', 'contentOptions' => ['class' => 'project-title']], ['headerOptions' => ['class' => 'text-center col-md-6'], 'attribute' => 'product.translation.title', 'value' => function ($model) {
    if (!empty($model->product->translation->title)) {
        $content = !empty($model->product->translation->title) ? Html::a(Html::tag('h3', $model->product->translation->title), Url::toRoute(['/shop/product/show', 'id' => $model->product->id, 'languageId' => Language::getCurrent()->id]), ['class' => "text-success"]) : '';
        $content .= !empty($model->product->category->translation->title) ? Html::tag('p', Html::tag('small', Yii::t('shop', 'Category') . ': ' . Html::a($model->product->category->translation->title, Url::toRoute(['/shop/category/show', 'id' => $model->product->category_id, 'languageId' => Language::getCurrent()->id]), ['class' => 'text-info'])), ['class' => 'text-info']) : '';
        $content .= !empty($model->product->translation->description) ? $model->product->translation->description : '';
        return $content;
    }
    return '';
}, 'label' => Yii::t('shop', 'Title'), 'format' => 'html'], ['headerOptions' => ['class' => 'text-center col-md-2'], 'attribute' => 'image', 'value' => function ($model) {
    $imageUrl = !empty($model->product->image) ? $model->product->image->small : '/images/default.jpg';
    return Html::a(Html::img(Url::toRoute([$imageUrl])), Url::toRoute(['/shop/product/show', 'id' => $model->product->id, 'languageId' => Language::getCurrent()->id]));
}, 'label' => Yii::t('shop', 'Image'), 'format' => 'html', 'contentOptions' => ['class' => 'col-md-4 text-center']], ['headerOptions' => ['class' => 'text-center col-md-3'], 'value' => function ($model) {
    $deleteButton = Html::a(Yii::t('shop', 'Remove from favorites'), Url::to(['/shop/favorite-product/remove', 'productId' => $model->product_id]), ['class' => 'btn btn-warning col-md-12 m-t-xs']);
    $goToButton = Html::a(Yii::t('shop', 'Go to product'), Url::to(['/shop/product/show', 'id' => $model->product_id]), ['class' => 'btn btn-primary col-md-12']);
    return $goToButton . $deleteButton;
}, 'format' => 'raw', 'contentOptions' => ['class' => 'text-center']]]]);
?>

</div>
예제 #18
0
    $content = '';
    $number = 3;
    $i = 0;
    foreach ($model->images as $image) {
        if (!empty($image)) {
            if ($i < $number) {
                $content .= Html::img($image->small, ['class' => 'img-circle']);
                $i++;
            }
        }
    }
    return Html::a($content, Url::toRoute(['add-image', 'id' => $model->id, 'languageId' => Language::getCurrent()->id]));
}, 'label' => Yii::t('shop', 'Images'), 'format' => 'html', 'contentOptions' => ['class' => 'col-md-1 project-people']], ['headerOptions' => ['class' => 'text-center col-md-1'], 'attribute' => \Yii::t('shop', 'Status'), 'value' => function ($model) {
    switch ($model->status) {
        case Product::STATUS_ON_MODERATION:
            return Html::button(Yii::$app->user->can('moderateProductCreation') ? Html::a(\Yii::t('shop', 'On moderation'), Url::toRoute(['save', 'id' => $model->id, 'languageId' => Language::getCurrent()->id]), ['class' => '']) : Html::tag('span', \Yii::t('shop', 'On moderation')), ['class' => 'col-md-12 btn btn-warning btn-xs']);
            break;
        case Product::STATUS_DECLINED:
            return Html::tag('p', \Yii::t('shop', 'Declined'), ['class' => 'col-md-12 btn btn-danger btn-xs']);
            break;
        case Product::STATUS_SUCCESS:
            return Html::tag('p', \Yii::t('shop', 'Success'), ['class' => 'col-md-12 btn btn-primary btn-xs']);
            break;
        default:
            return $model->status;
    }
}, 'label' => Yii::t('shop', 'Status'), 'format' => 'html', 'filter' => Html::activeDropDownList($searchModel, 'status', [Product::STATUS_ON_MODERATION => \Yii::t('shop', 'On moderation'), Product::STATUS_DECLINED => \Yii::t('shop', 'Declined'), Product::STATUS_SUCCESS => \Yii::t('shop', 'Success')], ['class' => 'form-control', 'prompt' => 'Любой статус']), 'contentOptions' => ['class' => 'project-title text-center col-md-1']], ['headerOptions' => ['class' => 'text-center col-md-2'], 'attribute' => \Yii::t('shop', 'Manage'), 'value' => function ($model) {
    return ManageButtons::widget(['model' => $model]);
}, 'format' => 'raw', 'contentOptions' => ['class' => 'col-md-2 text-center']]]]);
?>
        <?php 
예제 #19
0
                        <?php 
    }
    ?>
                    </a>
                </td>
                <td>
                    <?php 
    echo Html::a($article->translation->name, ['/articles/article/save', 'articleId' => $article->id, 'languageId' => Language::getCurrent()->id]);
    ?>
                </td>
                <td>
                    <?php 
    if (!empty($article->category->translation->name)) {
        ?>
                        <?php 
        echo Html::a($article->category->translation->name, ['/articles/category/save', 'categoryId' => $article->category_id, 'languageId' => Language::getCurrent()->id]);
        ?>
                    <?php 
    } else {
        ?>
                        <span><?php 
        echo Yii::t('articles', 'Without category');
        ?>
</span>
                    <?php 
    }
    ?>
                </td>
                <td>
                    <?php 
    echo Yii::$app->formatter->asRelativeTime($article->created_at);
예제 #20
0
<?php

/**
 * @author Albert Gainutdinov <*****@*****.**>
 *
 * @var $this yii\web\View
 * @var $availabilities bl\cms\shop\common\entities\ProductAvailability
 */
use bl\cms\shop\widgets\ManageButtons;
use bl\multilang\entities\Language;
use yii\bootstrap\Html;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
$this->title = Yii::t('shop', 'Product availabilities');
$currentLanguage = Language::getCurrent();
?>

<div class="panel panel-default">

    <div class="panel-heading">
        <i class="glyphicon glyphicon-list"></i>
        <?php 
echo Html::encode($this->title);
?>
    </div>

    <div class="panel-body">

        <p>
            <?php 
echo Html::a(Yii::t('shop', 'Add'), ['save'], ['class' => 'btn btn-primary btn-xs pull-right']);
예제 #21
0
 /**
  * Selects product filters for category
  *
  * @param integer $id
  * @param integer $languageId
  * @param integer $categoryId
  * @return mixed
  * @throws Exception
  * @throws ForbiddenHttpException
  */
 public function actionSelectFilters($id = null, $languageId = null, $categoryId = null)
 {
     if (!empty($categoryId)) {
         $category = Category::findOne($categoryId);
         $filters = Filter::find()->where(['category_id' => $category->id])->all();
         $filter = !empty($id) ? Filter::findOne($id) : new Filter();
     } else {
         throw new Exception('You can not add filter before saving category.');
     }
     if (Yii::$app->request->isPost) {
         $filter->load(Yii::$app->request->post());
         if ($filter->validate()) {
             $filter->category_id = $category->id;
             $filter->save();
             Yii::$app->getSession()->setFlash('success', 'Data were successfully modified.');
             return $this->redirect(Yii::$app->request->referrer);
         }
     }
     return $this->render('save', ['category' => $category, 'languageId' => $languageId, 'selectedLanguage' => Language::findOne($languageId), 'languages' => Language::findAll(['active' => true]), 'viewName' => 'select-filters', 'params' => ['category' => $category, 'filters' => $filters, 'newFilter' => new Filter(), 'languageId' => $languageId]]);
 }
예제 #22
0
<?php

/**
 * @author Albert Gainutdinov <*****@*****.**>
 */
use bl\multilang\entities\Language;
use yii\bootstrap\Html;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
global $item;
$item = $model;
echo Html::a('<span class="glyphicon glyphicon-remove"></span>', Url::toRoute(['delete', 'id' => $GLOBALS['item']->id]), ['title' => Yii::t('yii', 'Delete'), 'class' => 'btn btn-danger pull-right btn-xs']) . Html::tag('div', Html::a(Html::tag('span', ' ' . \Yii::t('shop', 'Edit'), ['class' => 'glyphicon glyphicon-pencil']), Url::toRoute(['save', 'id' => $GLOBALS['item']->id, "languageId" => Language::getCurrent()->id]), ['class' => 'btn btn-primary btn-xs']) . Html::a('<span class="caret"></span>', Url::toRoute(['save', 'id' => $GLOBALS['item']->id, "languageId" => Language::getCurrent()->id]), ['class' => 'btn btn-primary btn-xs dropdown-toggle', 'type' => 'button', 'id' => 'dropdownMenu1', 'data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'aria-expanded' => 'true']) . Html::ul(ArrayHelper::map(Language::find()->all(), 'id', 'name'), ['item' => function ($item, $index) {
    return Html::tag('li', Html::a($item, Url::toRoute(['save', 'id' => $GLOBALS['item']->id, "languageId" => $index])));
}, 'class' => 'dropdown-menu', 'aria-labelledby' => 'dropdownMenu1']), ['class' => 'btn-group pull-right m-r-xs']);
예제 #23
0
 /**
  * Creates a URL according to the given route and parameters.
  * @param UrlManager $manager the URL manager
  * @param string $route the route. It should not have slashes at the beginning or the end.
  * @param array $params the parameters
  * @return string|boolean the created URL, or false if this rule cannot be used for creating this URL.
  */
 public function createUrl($manager, $route, $params)
 {
     $pathInfo = '';
     if ($route == $this->categoryRoute && empty($params['id'])) {
         $pathInfo = $this->prefix;
     } else {
         if (($route == $this->productRoute || $route == $this->categoryRoute) && !empty($params['id'])) {
             $id = $params['id'];
             $parentId = null;
             $language = Language::findOne(['lang_id' => $manager->language]);
             if ($route == $this->productRoute) {
                 $product = Product::findOne($id);
                 if (empty($product)) {
                     return false;
                 }
                 if ($product->getTranslation($language->id) && $product->getTranslation($language->id)->seoUrl) {
                     $pathInfo = $product->getTranslation($language->id)->seoUrl;
                     $parentId = $product->category_id;
                 } else {
                     return false;
                 }
             } else {
                 if ($route == $this->categoryRoute) {
                     $category = Category::findOne($id);
                     if ($category->getTranslation($language->id) && $category->getTranslation($language->id)->seoUrl) {
                         $pathInfo = $category->getTranslation($language->id)->seoUrl;
                         $parentId = $category->parent_id;
                     } else {
                         return false;
                     }
                 }
             }
             while ($parentId != null) {
                 $category = Category::findOne($parentId);
                 if ($category->getTranslation($language->id) && $category->getTranslation($language->id)->seoUrl) {
                     $pathInfo = $category->getTranslation($language->id)->seoUrl . '/' . $pathInfo;
                     $parentId = $category->parent_id;
                 } else {
                     return false;
                 }
             }
             if (!empty($this->prefix)) {
                 $pathInfo = $this->prefix . '/' . $pathInfo;
             }
             unset($params['id']);
         } else {
             return false;
         }
     }
     return $pathInfo . '?' . http_build_query($params);
 }
 public function actionDelete($categoryId = null, $languageId = null)
 {
     $language = Language::find()->where(['id' => $languageId])->one();
     if (Message::find()->where(['id' => $categoryId])->count() == 0) {
         SourceMessage::find()->where(['id' => $categoryId])->one()->delete();
     } else {
         $message = Message::find()->where(['id' => $categoryId, 'language' => $language->lang_id])->one();
         if (!empty($message)) {
             $message->delete();
         } else {
             Yii::$app->session->setFlash('success', 'This category linked data , such a category can not be deleted.');
         }
     }
     return $this->redirect(Yii::$app->request->referrer);
 }
예제 #25
0
<?php

use bl\cms\gallery\models\entities\GalleryAlbum;
use bl\cms\gallery\models\entities\GalleryAlbumTranslation;
use bl\multilang\entities\Language;
use dosamigos\tinymce\TinyMce;
use yii\bootstrap\ActiveForm;
use yii\helpers\Html;
use yii\helpers\Url;
/**
 * @var GalleryAlbum $album
 * @var GalleryAlbumTranslation $albumTranslation
 * @var Language $currentLanguage
 * @var Language[] $languages
 */
$languages = Language::findAll(['active' => true]);
?>

<?php 
$form = ActiveForm::begin(['method' => 'post', 'options' => ['enctype' => 'multipart/form-data']]);
?>
<div class="row">
    <div class="col-md-12">
        <div class="panel panel-default">
            <div class="panel-heading">
                <i class="glyphicon glyphicon-list"></i>
                <?php 
echo Yii::t('blcms-gallery/backend/album', 'Album');
?>
                <?php 
if (count($languages) > 1) {
예제 #26
0
                    <?php 
        echo !empty($product->ownerProfile->name) ? $product->ownerProfile->name : '';
        ?>
                    <?php 
        echo !empty($product->ownerProfile->surname) ? $product->ownerProfile->surname : '';
        ?>
                </td>
            <?php 
    }
    ?>
            <td style="vertical-align: middle;">
                <?php 
    if (!empty($product->category->translation->title)) {
        ?>
                    <?php 
        echo Html::a($product->category->translation->title, ['/shop/category/save', 'id' => $product->category_id, 'languageId' => Language::getCurrent()->id]);
        ?>
                <?php 
    } else {
        ?>
                    <span><?php 
        echo Yii::t('shop', 'Without parent');
        ?>
</span>
                <?php 
    }
    ?>
            </td>
            <td style="vertical-align: middle;">
                <?php 
    echo Yii::$app->formatter->asRelativeTime($product->creation_time);
예제 #27
0
?>
</h1>

        <p>
            <?php 
echo Html::a(Yii::t('shop', 'Create attribute'), Url::toRoute(['save', 'languageId' => Language::getCurrent()->id]), ['class' => 'btn btn-success']);
?>
        </p>
    </div>
    <div class="panel-body">
        <?php 
Pjax::begin();
?>
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterRowOptions' => ['class' => 'm-b-sm m-t-sm'], 'options' => ['class' => 'project-list'], 'tableOptions' => ['id' => 'my-grid', 'class' => 'table table-hover'], 'summary' => "", 'columns' => [['attribute' => 'Id', 'value' => 'id', 'headerOptions' => ['class' => 'text-center'], 'contentOptions' => ['class' => 'text-center']], ['headerOptions' => ['class' => 'text-center col-md-2'], 'attribute' => 'title', 'value' => 'translation.title', 'label' => Yii::t('shop', 'Title'), 'format' => 'text', 'contentOptions' => ['class' => 'text-center project-title col-md-2']], ['attribute' => 'type', 'value' => function ($model) {
    return \Yii::t('shop', $model->type->title);
}], ['attribute' => 'created_at', 'value' => 'created_at'], ['attribute' => 'updated_at', 'value' => 'updated_at'], ['headerOptions' => ['class' => 'text-center col-md-2'], 'attribute' => \Yii::t('shop', 'Manage'), 'value' => function ($model) {
    global $product;
    $product = $model;
    $languages = Language::findAll(['active' => true]);
    $list = Html::a('<span class="glyphicon glyphicon-remove"></span>', Url::toRoute(['remove', 'id' => $model->id]), ['title' => Yii::t('yii', 'Delete'), 'class' => 'btn btn-danger pull-right pjax']) . Html::tag('div', Html::a('Edit', Url::toRoute(['save', 'attrId' => $model->id, "languageId" => Language::getCurrent()->id]), ['class' => 'col-md-8 btn btn-default ']) . Html::a('<span class="caret"></span>', Url::toRoute(['save', 'attrId' => $model->id, "languageId" => Language::getCurrent()->id]), ['class' => 'block col-md-4 btn btn-default dropdown-toggle', 'type' => 'button', 'id' => 'dropdownMenu1', 'data-toggle' => 'dropdown', 'aria-haspopup' => 'true', 'aria-expanded' => 'true']) . Html::ul(ArrayHelper::map($languages, 'id', 'name'), ['item' => function ($item, $index) {
        return Html::tag('li', Html::a($item, Url::toRoute(['save', 'attrId' => $GLOBALS['product']->id, "languageId" => $index]), []), []);
    }, 'class' => 'dropdown-menu', 'aria-labelledby' => 'dropdownMenu1']), ['class' => 'btn-group pull-left']);
    return $list;
}, 'format' => 'raw', 'contentOptions' => ['class' => 'col-md-2 text-center']]]]);
?>
        <?php 
Pjax::end();
?>
    </div>
</div>
예제 #28
0
 /**
  * @param integer $attrId
  * @param integer $languageId
  * @return mixed
  * @throws Exception
  */
 public function actionAddValue($attrId, $languageId)
 {
     if (!empty($attrId)) {
         $languageId = empty($languageId) ? Language::getCurrent()->id : $languageId;
         $model = new ShopAttributeValue();
         $modelTranslation = new ShopAttributeValueTranslation();
         $attributeTextureModel = new AttributeTextureForm();
         if (Yii::$app->request->post()) {
             if ($modelTranslation->load(Yii::$app->request->post())) {
                 $model->attribute_id = $attrId;
                 if (ShopAttribute::findOne($attrId)->type_id == 3 || ShopAttribute::findOne($attrId)->type_id == 4) {
                     $colorTexture = new ShopAttributeValueColorTexture();
                     if (ShopAttribute::findOne($attrId)->type_id == 3) {
                         if ($attributeTextureModel->load(Yii::$app->request->post())) {
                             $colorTexture->color = $attributeTextureModel->color;
                         }
                     } elseif (ShopAttribute::findOne($attrId)->type_id == 4) {
                         if ($attributeTextureModel->load(Yii::$app->request->post())) {
                             $attributeTextureModel->imageFile = UploadedFile::getInstance($attributeTextureModel, 'imageFile');
                             $colorTexture->texture = $attributeTextureModel->upload();
                         }
                     }
                     $colorTexture->save();
                     $modelTranslation->value = $colorTexture->id;
                 }
                 if ($model->save()) {
                     $modelTranslation->value_id = $model->id;
                     $modelTranslation->language_id = $languageId;
                     if ($modelTranslation->save()) {
                         if (\Yii::$app->request->isPjax) {
                             $searchAttributeValueModel = new SearchAttributeValue();
                             $dataProviderAttributeValue = $searchAttributeValueModel->search(Yii::$app->request->queryParams);
                             return $this->renderPartial('add-value', ['dataProvider' => $dataProviderAttributeValue, 'attribute' => ShopAttribute::findOne($attrId), 'selectedLanguage' => Language::findOne($languageId), 'valueModel' => new ShopAttributeValue(), 'valueModelTranslation' => new ShopAttributeValueTranslation(), 'attributeTextureModel' => $attributeTextureModel]);
                         } else {
                             return $this->redirect(Url::toRoute(['save', 'attrId' => $attrId, 'languageId' => $languageId]));
                         }
                     }
                 } else {
                     throw new Exception($model->errors);
                 }
             }
         } else {
             return $this->render(Url::toRoute(['add-value', 'attrId' => $attrId, 'languageId' => $languageId]));
         }
     }
 }
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getLanguage()
 {
     return $this->hasOne(Language::className(), ['id' => 'language_id']);
 }
예제 #30
0
    }
    return $content;
}, 'label' => Yii::t('shop', 'Title'), 'format' => 'html', 'contentOptions' => ['class' => 'project-title col-md-3']], ['headerOptions' => ['class' => 'text-center col-md-3'], 'attribute' => 'parent_id', 'filter' => ArrayHelper::map(Category::find()->all(), 'id', 'translation.title'), 'value' => 'parent.translation.title', 'label' => Yii::t('shop', 'Parent category'), 'format' => 'html', 'contentOptions' => ['class' => 'project-title col-md-3']], ['headerOptions' => ['class' => 'text-center col-md-2'], 'attribute' => 'images', 'value' => function ($model) {
    $content = '';
    if (!empty($model->cover)) {
        $content .= Html::img('/images/shop-category/' . $model->cover . '-small.jpg', ['class' => 'img-circle']);
    }
    if (!empty($model->thumbnail)) {
        $content .= Html::img('/images/shop-category/' . $model->thumbnail . '-small.jpg', ['class' => 'img-circle']);
    }
    if (!empty($model->menu_item)) {
        $content .= Html::img('/images/shop-category/' . $model->menu_item . '-small.jpg', ['class' => 'img-circle']);
    }
    return Html::a($content, Url::toRoute(['add-image', 'categoryId' => $model->id, 'languageId' => Language::getCurrent()->id]));
}, 'label' => Yii::t('shop', 'Images'), 'format' => 'html', 'contentOptions' => ['class' => 'col-md-2 project-people']], ['headerOptions' => ['class' => 'text-center col-md-1'], 'format' => 'html', 'attribute' => 'show', 'filter' => [1 => \Yii::t('shop', 'On'), 0 => \Yii::t('shop', 'Off')], 'label' => Yii::t('shop', 'Show'), 'contentOptions' => ['class' => 'text-center col-md-1'], 'value' => function ($model) {
    return Html::a(Html::tag('i', '', ['class' => $model->show ? 'glyphicon glyphicon-ok text-primary' : 'glyphicon glyphicon-minus text-danger']), Url::to(['switch-show', 'id' => $model->id]), ['class' => 'category-nav']);
}], ['headerOptions' => ['class' => 'text-center col-md-2'], 'attribute' => \Yii::t('shop', 'Manage'), 'value' => function ($model) {
    return ManageButtons::widget(['model' => $model]);
}, 'format' => 'raw', 'contentOptions' => ['class' => 'col-md-2 text-center']]]]);
?>

        <?php 
Pjax::end();
?>

        <?php 
echo Html::a(Html::tag('i', '', ['class' => 'fa fa-user-plus']) . Yii::t('shop', 'Create Category'), ['save', 'languageId' => Language::getCurrent()->id], ['class' => 'btn btn-primary btn-xs pull-right']);
?>
    </div>

</div>