public function actionSendnow($id)
 {
     $model = Page::findById($id);
     if (null === $model) {
         Yii::$app->session->setFlash('error', Yii::t('app', 'Document with this ID does not exist'));
         return $this->render('@app/views/notifications/newsletter/sendnow');
     }
     $emailsOk = [];
     $emailsBad = [];
     $activeSubscribes = (new SubscribeEmail())->getActiveSubscribes();
     foreach ($activeSubscribes as $sEmail) {
         $status = Yii::$app->mail->compose('@app/views/notifications/newsletter/sendnow-notify.php', ['user' => $sEmail->name, 'page' => $model])->setTo($sEmail->email)->setFrom(Yii::$app->mail->transport->getUserName())->setSubject(Yii::t('app', 'New notify'))->send();
         if ($status) {
             array_push($emailsOk, $sEmail);
         } else {
             array_push($emailsBad, $sEmail);
         }
     }
     $params = ['emailsBad' => $emailsBad, 'emailsOk' => $emailsOk];
     if (count($emailsBad) > 0) {
         Yii::$app->session->setFlash('warning', Yii::t('app', 'There are addresses that email could not be sent'));
     } else {
         Yii::$app->session->setFlash('info', Yii::t('app', 'Subscribe completed'));
     }
     return $this->render('sendnow', $params);
 }
Example #2
0
 public function run()
 {
     app\backend\assets\FrontendEditingAsset::register($this->view);
     $items = [['label' => Icon::show('dashboard') . ' ' . Yii::t('app', 'Backend'), 'url' => ['/backend/']]];
     switch (Yii::$app->requestedRoute) {
         case 'shop/product/list':
             if (isset($_GET['properties'])) {
                 $apply_if_params = [];
                 foreach ($_GET['properties'] as $property_id => $values) {
                     if (isset($values[0])) {
                         $apply_if_params[$property_id] = $values[0];
                     }
                 }
                 if (Yii::$app->response->dynamic_content_trait === true) {
                     $items[] = ['label' => Icon::show('puzzle') . ' ' . Yii::t('app', 'Edit Dynamic Content'), 'url' => ['/backend/dynamic-content/edit', 'id' => Yii::$app->response->matched_dynamic_content_trait_model->id]];
                 } else {
                     if (isset($_GET['properties'], $_GET['last_category_id'])) {
                         $items[] = ['label' => Icon::show('puzzle') . ' ' . Yii::t('app', 'Add Dynamic Content'), 'url' => ['/backend/dynamic-content/edit', 'DynamicContent' => ['apply_if_params' => Json::encode($apply_if_params), 'apply_if_last_category_id' => $_GET['last_category_id'], 'object_id' => Object::getForClass(app\modules\shop\models\Product::className())->id, 'route' => 'shop/product/list']]];
                     }
                 }
             } else {
                 // no properties selected - go to category edit page
                 if (isset($_GET['last_category_id'])) {
                     $reviewsLink = $this->getReviewEditParams("Category", intval($_GET['last_category_id']));
                     $cat = app\modules\shop\models\Category::findById($_GET['last_category_id']);
                     $items[] = ['label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit category'), 'url' => ['/shop/backend-category/edit', 'id' => $cat->id, 'parent_id' => $cat->parent_id]];
                 }
             }
             break;
         case 'shop/product/show':
             if (isset($_GET['model_id'])) {
                 $reviewsLink = $this->getReviewEditParams("Product", intval($_GET['model_id']));
                 $items[] = ['label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit product'), 'url' => ['/shop/backend-product/edit', 'id' => intval($_GET['model_id'])]];
             }
             break;
         case '/page/page/show':
         case '/page/page/list':
             if (isset($_GET['id'])) {
                 $page = app\modules\page\models\Page::findById($_GET['id']);
                 $reviewsLink = $this->getReviewEditParams("Page", $_GET['id']);
                 $items[] = ['label' => Icon::show('pencil') . ' ' . Yii::t('app', 'Edit page'), 'url' => ['/page/backend/edit', 'id' => $page->id, 'parent_id' => $page->parent_id]];
             }
             break;
     }
     if (!empty($reviewsLink)) {
         $items[] = $reviewsLink;
     }
     return $this->render('floating-panel', ['items' => $items, 'bottom' => $this->bottom]);
 }
Example #3
0
 public function run()
 {
     if ($this->model === null) {
         $this->model = Page::findById($this->parent_id);
     }
     if ($this->model === null) {
         return "<!-- can't render - model is null -->";
     }
     $children = Page::find()->where(['parent_id' => $this->model->id])->orderBy('date_added DESC');
     if (null !== $this->limit) {
         $children->limit($this->limit);
     }
     $children = $children->all();
     return $this->render($this->viewFile, ['model' => $this->model, 'children' => $children, 'more_pages_label' => $this->more_pages_label]);
 }
 /**
  * @inheritdoc
  * @return string
  */
 public function run()
 {
     if ($this->model === null) {
         $this->model = Page::findById($this->parent_id);
     }
     if ($this->model === null) {
         return "<!-- can't render - model is null -->";
     }
     $cacheKey = 'PagesListWidget:' . $this->model->id . ':limit:' . $this->limit;
     $children = Yii::$app->cache->get($cacheKey);
     if ($children === false) {
         $children = Page::find()->where(['parent_id' => $this->model->id])->orderBy(['date_added' => SORT_DESC]);
         if (null !== $this->limit) {
             $children->limit($this->limit);
         }
         $children = $children->all();
         Yii::$app->cache->set($cacheKey, $children, 86400, new TagDependency(['tags' => [ActiveRecordHelper::getCommonTag(Page::className())]]));
     }
     return $this->render($this->viewFile, ['model' => $this->model, 'children' => $children, 'more_pages_label' => $this->more_pages_label]);
 }
Example #5
0
 /**
  * @inheritdoc
  */
 public function createUrl($manager, $route, $params)
 {
     /** @var Page $model */
     if ($route == 'page/page/show' || $route == 'page/page/list') {
         $model = null;
         if (isset($params['model'])) {
             $model = $params['model'];
             unset($params['model']);
         } else {
             if (isset($params['id'])) {
                 $model = Page::findById($params['id']);
                 unset($params['id']);
             }
         }
         if (null !== $model) {
             $url = $model->slug_compiled === ':mainpage:' ? '' : $model->slug_compiled;
             $_query = http_build_query($params);
             $url = !empty($_query) ? $url . '?' . $_query : $url;
             return $url;
         }
     }
     return false;
 }
</th>
            <td>
                <?php 
echo isset($review->author_phone) ? $review->author_phone : Html::tag('em', Yii::t('yii', '(not set)'));
?>

            </td>
        </tr>
        <tr>
            <th style="text-align: left;"><?php 
echo $review->getAttributeLabel('text');
?>
</th>
            <td>
                <?php 
echo isset($review->text) ? $review->text : Html::tag('em', Yii::t('yii', '(not set)'));
?>
            </td>
        </tr>
        <?php 
$row = '';
$obj = Page::findById($review->object_model_id);
if ($obj !== null) {
    $row = Html::tag('tr', Html::tag('th', 'Страница', ['style' => 'text-align: left;']) . Html::tag('td', Html::a($obj->name, Url::to(['/page/show', 'id' => $obj->id], true))), ['style' => 'background: #f5f5f5;']);
}
$output = Html::tag('p', 'See review details ' . Html::a('here', Url::to(['/backend/review/pages'], true)));
echo $row;
?>
    </table>
<?php 
echo $output;
Example #7
0
 private function buildBreadcrumbsArray($model)
 {
     if ($model === null || $model->id === 1) {
         return [];
     }
     // init
     $breadcrumbs = [];
     $crumbs[$model->slug] = $model->breadcrumbs_label;
     // get basic data
     $parent = Page::findById($model->parent_id);
     // if parent exists and not a main page
     while ($parent !== null && $parent->id != 1) {
         $crumbs[$parent->slug] = $parent->breadcrumbs_label;
         $parent = $parent->parent;
     }
     // build array for widget
     $url = '';
     $crumbs = array_reverse($crumbs, true);
     foreach ($crumbs as $slug => $label) {
         $url .= '/' . $slug;
         $breadcrumbs[] = ['label' => (string) $label, 'url' => $url];
     }
     unset($breadcrumbs[count($breadcrumbs) - 1]['url']);
     // last item is not a link
     return $breadcrumbs;
 }
Example #8
0
 /**
  * renders url according to given data
  * @param $chunkData
  * @param TagDependency $dependency
  * @return string
  */
 private static function renderUrl($chunkData, &$dependency)
 {
     $expression = '%(?P<objectName>[^#]+?)#(?P<objectId>[\\d]+?)$%';
     $output = '';
     preg_match($expression, $chunkData['key'], $m);
     if (true === isset($m['objectName'], $m['objectId'])) {
         $id = (int) $m['objectId'];
         switch (strtolower($m['objectName'])) {
             case "page":
                 if (null !== ($model = Page::findById($id))) {
                     $dependency->tags[] = ActiveRecordHelper::getCommonTag(Page::className());
                     $dependency->tags[] = $model->objectTag();
                     $output = Url::to(['@article', 'id' => $id]);
                 }
                 break;
             case "category":
                 if (null !== ($model = Category::findById($id))) {
                     $dependency->tags[] = ActiveRecordHelper::getCommonTag(Category::className());
                     $dependency->tags[] = $model->objectTag();
                     $output = Url::to(['@category', 'last_category_id' => $id, 'category_group_id' => $model->category_group_id]);
                 }
                 break;
             case "product":
                 if (null !== ($model = app\modules\shop\models\Product::findById($id))) {
                     $dependency->tags[] = ActiveRecordHelper::getCommonTag(Product::className());
                     $dependency->tags[] = $model->objectTag();
                     $output = Url::to(['@product', 'model' => $model, 'category_group_id' => $model->getMainCategory()->category_group_id]);
                 }
                 break;
         }
     }
     return $output;
 }