Commit 25bc7081 authored by Виталий Мурашко's avatar Виталий Мурашко

Merge branch 'master' of http://git.task-on.com/ktask/task-on.com

parents d3f88425 4856a062
...@@ -25,9 +25,9 @@ return [ ...@@ -25,9 +25,9 @@ return [
'main' => ['class' => 'common\modules\main\main'], 'main' => ['class' => 'common\modules\main\main'],
'utility' => ['class' => 'c006\utility\migration\Module'], 'utility' => ['class' => 'c006\utility\migration\Module'],
'triggers' => ['class' => 'common\modules\triggers\Module'], 'triggers' => ['class' => 'common\modules\triggers\Module'],
'school' => ['class' => 'common\modules\school\Module'],
'rbac' => ['class' => 'common\modules\rbac\rbac'],
'message-template' => ['class' => 'common\modules\messageTemplate\Module'], 'message-template' => ['class' => 'common\modules\messageTemplate\Module'],
'school' => ['class' => 'common\modules\school\Module'],
'rbac' => ['class' => 'common\modules\rbac\rbac'],
], ],
'components' => [ 'components' => [
'session' => [ 'session' => [
......
...@@ -27,6 +27,7 @@ class Bid extends \common\components\ActiveRecordModel ...@@ -27,6 +27,7 @@ class Bid extends \common\components\ActiveRecordModel
const FORM_MESSAGE = 'message'; const FORM_MESSAGE = 'message';
const TAG_INVOLVEMENT = 'Вовлечение'; const TAG_INVOLVEMENT = 'Вовлечение';
const TAG_TREATMENT = 'Обращение';
const FILE_FOLDER = '/uploads/bids/'; const FILE_FOLDER = '/uploads/bids/';
...@@ -66,7 +67,13 @@ class Bid extends \common\components\ActiveRecordModel ...@@ -66,7 +67,13 @@ class Bid extends \common\components\ActiveRecordModel
public function rules() public function rules()
{ {
return [ return [
[['name', 'phone', 'email'], 'required', 'on' => self::SCENARIO_PROJECT], ['phone', 'required', 'when' => function($model) {
return !$model->email;
}, 'on' => self::SCENARIO_PROJECT],
['email', 'required', 'when' => function($model) {
return !$model->phone;
}, 'on' => self::SCENARIO_PROJECT],
[['email'], 'email'], [['email'], 'email'],
[['name', 'phone'], 'required', 'on' => self::SCENARIO_CALLBACK], [['name', 'phone'], 'required', 'on' => self::SCENARIO_CALLBACK],
......
...@@ -4,7 +4,7 @@ namespace common\modules\content\models; ...@@ -4,7 +4,7 @@ namespace common\modules\content\models;
use Yii; use Yii;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use himiklab\sitemap\behaviors\SitemapBehavior; use frontend\modules\sitemap\behaviors\SitemapBehavior;
use \yii\helpers\Url; use \yii\helpers\Url;
use common\modules\content\models\CoBlocks; use common\modules\content\models\CoBlocks;
...@@ -78,11 +78,11 @@ class CoContent extends \common\components\ActiveRecordModel ...@@ -78,11 +78,11 @@ class CoContent extends \common\components\ActiveRecordModel
'scope' => function ($model) { 'scope' => function ($model) {
/** @var \yii\db\ActiveQuery $model */ /** @var \yii\db\ActiveQuery $model */
$model->select(['url', 'updated_at', 'priority']); $model->select(['url', 'updated_at', 'priority']);
// $model->andWhere(['is_deleted' => 0]); $model->andWhere(['active' => 1]);
}, },
'dataClosure' => function ($model) { 'dataClosure' => function ($model) {
return [ return [
'loc' => Url::to($model->url, true), 'loc' => Url::to($model->url),
'lastmod' => date('c', $model->updated_at), 'lastmod' => date('c', $model->updated_at),
'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY, 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
'priority' => $model->priority 'priority' => $model->priority
......
...@@ -136,7 +136,7 @@ class CoContentLang extends \common\components\ActiveRecordModel ...@@ -136,7 +136,7 @@ class CoContentLang extends \common\components\ActiveRecordModel
$arrWhatReplaceNext[] = '[projects]'; $arrWhatReplaceNext[] = '[projects]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('projects'); $arrReplaceNext[] = CoBlocks::printStaticBlock('projects');
$arrWhatReplaceNext[] = '[case-subscribe]'; $arrWhatReplaceNext[] = '[case-subscribe]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('case-subscribe'); $arrReplaceNext[] = CoBlocks::printStaticBlock('case-subscribe', ['title' => $this->title]);
$arrWhatReplaceNext[] = '[case-more]'; $arrWhatReplaceNext[] = '[case-more]';
$arrReplaceNext[] = CoBlocks::printStaticBlock('case-more', ['model' => $this->content]); $arrReplaceNext[] = CoBlocks::printStaticBlock('case-more', ['model' => $this->content]);
$arrWhatReplaceNext[] = '[footer]'; $arrWhatReplaceNext[] = '[footer]';
......
...@@ -28,12 +28,12 @@ class Module extends \common\components\WebModule ...@@ -28,12 +28,12 @@ class Module extends \common\components\WebModule
public static function name() public static function name()
{ {
return 'Управление шаблонами'; return 'Управление письмами';
} }
public static function description() public static function description()
{ {
return 'Управление шаблонами'; return 'Управление письмами';
} }
...@@ -45,7 +45,7 @@ class Module extends \common\components\WebModule ...@@ -45,7 +45,7 @@ class Module extends \common\components\WebModule
public static function adminMenu() public static function adminMenu()
{ {
return [ return [
'Управление шаблонами' => '/message-template/template-admin/manage' 'Управление письмами' => '/message-template/template-admin/manage'
]; ];
} }
} }
...@@ -12,7 +12,10 @@ use Yii; ...@@ -12,7 +12,10 @@ use Yii;
use common\components\AdminController; use common\components\AdminController;
use common\modules\messageTemplate\models\MessageTemplate; use common\modules\messageTemplate\models\MessageTemplate;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use yii\swiftmailer\Message;
use yii\web\HttpException;
use yii\web\NotFoundHttpException; use yii\web\NotFoundHttpException;
use yii\web\ServerErrorHttpException;
use common\modules\messageTemplate\components\Templates; use common\modules\messageTemplate\components\Templates;
class TemplateAdminController extends AdminController { class TemplateAdminController extends AdminController {
...@@ -25,10 +28,23 @@ class TemplateAdminController extends AdminController { ...@@ -25,10 +28,23 @@ class TemplateAdminController extends AdminController {
'Manage' => 'Управление шаблонами', 'Manage' => 'Управление шаблонами',
'Create' => 'Добавление шаблона', 'Create' => 'Добавление шаблона',
'Update' => 'Редактирование шаблона', 'Update' => 'Редактирование шаблона',
'Delete' => 'Удаление шаблона' 'Delete' => 'Удаление шаблона',
'Copy' => 'Создание копии'
]; ];
} }
public function actionCopy($id){
/** @var MessageTemplate $model */
/** @var MessageTemplate $model_two */
$model = new MessageTemplate();
$model_two = $this->findModel($id);
$model->attributes=$model_two->attributes;
if ($model->save())
$this->redirect(['update', 'id' => $model->getPrimaryKey()]);
else
throw new ServerErrorHttpException('Копирование не удалось', 500);
}
/** /**
* @return string * @return string
*/ */
......
...@@ -7,6 +7,9 @@ return [ ...@@ -7,6 +7,9 @@ return [
'name' => [ 'name' => [
'type' => 'text' 'type' => 'text'
], ],
'subject' => [
'type' => 'text'
],
'template' => [ 'template' => [
'type' => 'textarea' 'type' => 'textarea'
] ]
......
...@@ -11,6 +11,7 @@ use Yii; ...@@ -11,6 +11,7 @@ use Yii;
* @property string $name * @property string $name
* @property string $template * @property string $template
* @property string $created_at * @property string $created_at
* @property string $subject
*/ */
class MessageTemplate extends \common\components\ActiveRecordModel class MessageTemplate extends \common\components\ActiveRecordModel
{ {
...@@ -48,10 +49,10 @@ class MessageTemplate extends \common\components\ActiveRecordModel ...@@ -48,10 +49,10 @@ class MessageTemplate extends \common\components\ActiveRecordModel
public function rules() public function rules()
{ {
return [ return [
[['name', 'template'], 'required'], [['name', 'template', 'subject'], 'required'],
[['template'], 'string'], [['template'], 'string'],
[['created_at'], 'safe'], [['created_at'], 'safe'],
[['name'], 'string', 'max' => 255], [['name', 'subject'], 'string', 'max' => 255],
]; ];
} }
...@@ -61,10 +62,11 @@ class MessageTemplate extends \common\components\ActiveRecordModel ...@@ -61,10 +62,11 @@ class MessageTemplate extends \common\components\ActiveRecordModel
public function attributeLabels() public function attributeLabels()
{ {
return [ return [
'id' => 'ID', 'id' => 'ID шаблона',
'name' => 'Название', 'name' => 'Название',
'template' => 'Шаблон', 'template' => 'Шаблон',
'created_at' => 'Дата создания', 'created_at' => 'Дата создания',
'subject' => 'Тема сообщения'
]; ];
} }
} }
...@@ -19,11 +19,24 @@ use yii\grid\GridView; ...@@ -19,11 +19,24 @@ use yii\grid\GridView;
'id', 'id',
'name', 'name',
'template:html', 'subject',
[
'attribute' => 'template',
'format' => 'html',
'options' => [
'style' => 'width: 200px;'
]
],
'created_at:datetime', 'created_at:datetime',
[ [
'class' => 'yii\grid\ActionColumn', 'class' => 'yii\grid\ActionColumn',
'template' => '{update}{delete}', 'template' => '{double}{update}{delete}',
'buttons' => [
'double' => function($url, $model) {
$url = \yii\helpers\Url::toRoute(['/message-template/template-admin/copy', 'id' => $model->id]);
return \yii\helpers\Html::a('<span class="glyphicon"><img src="/img/copy.png"></span>', $url, ['title' => 'Сделать дубликат']);
}
]
], ],
], ],
]); ?> ]); ?>
......
...@@ -50,6 +50,10 @@ class DefaultController extends BaseController ...@@ -50,6 +50,10 @@ class DefaultController extends BaseController
$trigger->initAction($message); $trigger->initAction($message);
} }
} }
/** @var TriggerSchedule $model */
$model=TriggerSchedule::findOne($message->getPrimaryKey());
$model->checked=1;
$model->save();
} }
} }
} }
...@@ -30,7 +30,7 @@ return [ ...@@ -30,7 +30,7 @@ return [
], ],
'message_template_id' => [ 'message_template_id' => [
'type' => 'dropdownlist', 'type' => 'dropdownlist',
'items' => array('1' => 'first template', '2' => 'second template') 'items' => \yii\helpers\ArrayHelper::map(\common\modules\messageTemplate\models\MessageTemplate::find()->all(), 'id', 'name')
], ],
'timeout' => [ 'timeout' => [
'type' => 'text', 'type' => 'text',
......
<?php <?php
namespace common\modules\users\models; namespace common\modules\users\models;
use common\components\UnisenderAPI;
use common\modules\messageTemplate\controllers\TemplateAdminController;
use common\modules\messageTemplate\models\MessageTemplate;
use common\modules\triggers\models\TriggerSchedule;
use Yii; use Yii;
use yii\base\NotSupportedException; use yii\base\NotSupportedException;
use yii\behaviors\TimestampBehavior; use yii\behaviors\TimestampBehavior;
use yii\db\ActiveRecord; use yii\db\ActiveRecord;
use yii\helpers\Json;
use yii\web\IdentityInterface; use yii\web\IdentityInterface;
use yii\data\ActiveDataProvider; use yii\data\ActiveDataProvider;
use himiklab\sortablegrid\SortableGridBehavior; use himiklab\sortablegrid\SortableGridBehavior;
use \common\components\validators\RuEmailValidator; use \common\components\validators\RuEmailValidator;
use \common\modules\messageTemplate\components\Templates;
use \common\modules\rbac\models\AuthItem; use \common\modules\rbac\models\AuthItem;
use \common\modules\rbac\models\AuthAssignment; use \common\modules\rbac\models\AuthAssignment;
...@@ -538,5 +544,56 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter ...@@ -538,5 +544,56 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
{ {
return (bool)static::find()->where('email = :email', [':email'=>$email])->count(); return (bool)static::find()->where('email = :email', [':email'=>$email])->count();
} }
/**
* @param $template_id
*/
public function afterRegistration($template_id){
/** @var \DateTime $time_now */
$time_now=new \DateTime();
/** @var MessageTemplate $templateModel */
$templateModel = MessageTemplate::findOne($template_id);
/** @var Templates $template */
$template = new Templates($template_id, ['user_fio' => $this->fio]);
$email = $this->email;
$sender = new UnisenderAPI();
// Create the send list
$newList = $sender->createList();
$newListObject=Json::decode($newList);
if (array_key_exists('result', $newListObject) && array_key_exists('id', $newListObject['result'])) {
$newListId=$newListObject['result']['id'];
// Subscribe user to new List
$sender->subscribe(['list_ids' => $newListId, 'fields[email]' => $email, 'double_optin' => 1]);
// Create new message
$newMessage=$sender->createEmailMessage($this->fio, $email, $templateModel->subject, $template->getTemplate(), $newListId);
// Decode result
$newMessageObject=Json::decode($newMessage);
if (array_key_exists('result', $newMessageObject) && array_key_exists('message_id', $newMessageObject['result'])) {
// Get the message ID
$newMessageId=$newMessageObject['result']['message_id'];
// Create new campaign
$newCampaign = $sender->createCampaign($newMessageId);
// Parse the result
$newCampaignObject = Json::decode($newCampaign);
if (array_key_exists('result', $newCampaignObject) && array_key_exists('campaign_id', $newCampaignObject['result'])) {
$newCampaignId = $newCampaignObject['result']['campaign_id'];
$schedule = new TriggerSchedule();
$schedule->sended=1;
$schedule->checked=0;
$schedule->message_id=$newMessageId;
$schedule->message=$template->getTemplate();
$schedule->email=$email;
$schedule->time=$time_now->format('Y-m-d H:i:s');
$schedule->date_create=$time_now->format('Y-m-d H:i:s');
$schedule->list_id=$newListId;
$schedule->campaign_id=$newCampaignId;
if (!$schedule->save()) {
echo 'Письмо не было отправлено';
}
}
}
}
}
} }
...@@ -32,7 +32,6 @@ ...@@ -32,7 +32,6 @@
"dompdf/dompdf": "dev-master", "dompdf/dompdf": "dev-master",
"tecnick.com/tcpdf": "dev-master", "tecnick.com/tcpdf": "dev-master",
"mikehaertl/phpwkhtmltopdf": "^2.0@dev", "mikehaertl/phpwkhtmltopdf": "^2.0@dev",
"himiklab/yii2-sitemap-module" : "*",
"mirocow/yii2-minify-view" : "*", "mirocow/yii2-minify-view" : "*",
"kartik-v/yii2-widget-fileinput": "@dev", "kartik-v/yii2-widget-fileinput": "@dev",
"nodge/yii2-eauth": "~2.0", "nodge/yii2-eauth": "~2.0",
......
<?php
use yii\db\Migration;
class m160217_145619_add_subject_column_to_template extends Migration
{
public function up()
{
$this->addColumn(
'message_template',
'subject',
$this->string(255)->notNull()
);
}
public function down()
{
$this->dropColumn(
'message_template',
'subject'
);
}
}
...@@ -25,7 +25,7 @@ return [ ...@@ -25,7 +25,7 @@ return [
'users' => ['class' => 'common\modules\users\users',], 'users' => ['class' => 'common\modules\users\users',],
'blog' => ['class' => 'common\modules\blog\Module'], 'blog' => ['class' => 'common\modules\blog\Module'],
'sitemap' => [ 'sitemap' => [
'class' => 'himiklab\sitemap\Sitemap', 'class' => 'frontend\modules\sitemap\Sitemap',
'models' => [ 'models' => [
// your models // your models
'common\modules\content\models\CoContent', 'common\modules\content\models\CoContent',
......
<?php
/**
* @link https://github.com/himiklab/yii2-sitemap-module
* @copyright Copyright (c) 2014 HimikLab
* @license http://opensource.org/licenses/MIT MIT
*/
namespace frontend\modules\sitemap;
use Yii;
use yii\base\InvalidConfigException;
use yii\base\Module;
use yii\caching\Cache;
use common\modules\languages\models\Languages;
/**
* Yii2 module for automatically generating XML Sitemap.
*
* @author HimikLab
* @package himiklab\sitemap
*/
class Sitemap extends Module
{
public $controllerNamespace = 'frontend\modules\sitemap\controllers';
/** @var int */
public $cacheExpire = 86400;
/** @var Cache|string */
public $cacheProvider = 'cache';
/** @var string */
public $cacheKey = 'sitemap';
/** @var boolean Use php's gzip compressing. */
public $enableGzip = false;
/** @var array */
public $models = [];
/** @var array */
public $urls = [];
public function init()
{
parent::init();
if (is_string($this->cacheProvider)) {
$this->cacheProvider = Yii::$app->{$this->cacheProvider};
}
if (!$this->cacheProvider instanceof Cache) {
throw new InvalidConfigException('Invalid `cacheKey` parameter was specified.');
}
}
/**
* Build and cache a site map.
* @return string
* @throws \yii\base\InvalidConfigException
*/
public function buildSitemap()
{
$urls = $this->urls;
foreach ($this->models as $modelName)
{
/** @var behaviors\SitemapBehavior $model */
if (is_array($modelName))
{
$model = new $modelName['class'];
if (isset($modelName['behaviors'])) {
$model->attachBehaviors($modelName['behaviors']);
}
}
else
{
$model = new $modelName;
}
$urls = array_merge($urls, $model->generateSiteMap());
}
$langs = Languages::find()->all();
$sitemapData = $this->createControllerByID('default')->renderPartial('index', [
'urls' => $urls,
'langs' => $langs
]);
$this->cacheProvider->set($this->cacheKey, $sitemapData, $this->cacheExpire);
return $sitemapData;
}
}
<?php
/**
* @link https://github.com/himiklab/yii2-sitemap-module
* @copyright Copyright (c) 2014 HimikLab
* @license http://opensource.org/licenses/MIT MIT
*/
namespace frontend\modules\sitemap\behaviors;
use yii\base\Behavior;
use yii\base\InvalidConfigException;
/**
* Behavior for XML Sitemap Yii2 module.
*
* For example:
*
* ```php
* public function behaviors()
* {
* return [
* 'sitemap' => [
* 'class' => SitemapBehavior::className(),
* 'scope' => function ($model) {
* $model->select(['url', 'lastmod']);
* $model->andWhere(['is_deleted' => 0]);
* },
* 'dataClosure' => function ($model) {
* return [
* 'loc' => Url::to($model->url, true),
* 'lastmod' => strtotime($model->lastmod),
* 'changefreq' => SitemapBehavior::CHANGEFREQ_DAILY,
* 'priority' => 0.8
* ];
* }
* ],
* ];
* }
* ```
*
* @see http://www.sitemaps.org/protocol.html
* @author HimikLab
* @package himiklab\sitemap
*/
class SitemapBehavior extends Behavior
{
const CHANGEFREQ_ALWAYS = 'always';
const CHANGEFREQ_HOURLY = 'hourly';
const CHANGEFREQ_DAILY = 'daily';
const CHANGEFREQ_WEEKLY = 'weekly';
const CHANGEFREQ_MONTHLY = 'monthly';
const CHANGEFREQ_YEARLY = 'yearly';
const CHANGEFREQ_NEVER = 'never';
const BATCH_MAX_SIZE = 100;
/** @var callable */
public $dataClosure;
/** @var string|bool */
public $defaultChangefreq = false;
/** @var float|bool */
public $defaultPriority = false;
/** @var callable */
public $scope;
public function init()
{
if (!is_callable($this->dataClosure)) {
throw new InvalidConfigException('SitemapBehavior::$dataClosure isn\'t callable.');
}
}
public function generateSiteMap()
{
$result = [];
$n = 0;
/** @var \yii\db\ActiveRecord $owner */
$owner = $this->owner;
$query = $owner::find();
if (is_callable($this->scope)) {
call_user_func($this->scope, $query);
}
foreach ($query->each(self::BATCH_MAX_SIZE) as $model) {
$urlData = call_user_func($this->dataClosure, $model);
if (empty($urlData)) {
continue;
}
$result[$n]['loc'] = $urlData['loc'];
$result[$n]['lastmod'] = $urlData['lastmod'];
if (isset($urlData['changefreq'])) {
$result[$n]['changefreq'] = $urlData['changefreq'];
} elseif ($this->defaultChangefreq !== false) {
$result[$n]['changefreq'] = $this->defaultChangefreq;
}
if (isset($urlData['priority'])) {
$result[$n]['priority'] = $urlData['priority'];
} elseif ($this->defaultPriority !== false) {
$result[$n]['priority'] = $this->defaultPriority;
}
if (isset($urlData['news'])) {
$result[$n]['news'] = $urlData['news'];
}
if (isset($urlData['images'])) {
$result[$n]['images'] = $urlData['images'];
}
++$n;
}
return $result;
}
}
<?php
/**
* @link https://github.com/himiklab/yii2-sitemap-module
* @copyright Copyright (c) 2014 HimikLab
* @license http://opensource.org/licenses/MIT MIT
*/
namespace frontend\modules\sitemap\controllers;
use Yii;
use yii\web\Controller;
/**
* @author HimikLab
* @package himiklab\sitemap
*/
class DefaultController extends Controller
{
public function actionIndex()
{
/** @var \himiklab\sitemap\Sitemap $module */
$module = $this->module;
if (!$sitemapData = $module->cacheProvider->get($module->cacheKey))
{
$sitemapData = $module->buildSitemap();
}
Yii::$app->response->format = \yii\web\Response::FORMAT_RAW;
$headers = Yii::$app->response->headers;
$headers->add('Content-Type', 'application/xml');
if ($module->enableGzip)
{
$sitemapData = gzencode($sitemapData);
$headers->add('Content-Encoding', 'gzip');
$headers->add('Content-Length', strlen($sitemapData));
}
return $sitemapData;
}
}
<?php
/**
* @link https://github.com/himiklab/yii2-sitemap-module
* @copyright Copyright (c) 2014 HimikLab
* @license http://opensource.org/licenses/MIT MIT
*
* @var array $urls
*/
echo '<?xml version="1.0" encoding="UTF-8"?>' . PHP_EOL;
?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
xmlns:xhtml="http://www.w3.org/1999/xhtml"
xmlns:image="http://www.google.com/schemas/sitemap-image/1.1"
xmlns:news="http://www.google.com/schemas/sitemap-news/0.9">
<?php foreach ($urls as $url): ?>
<url>
<loc><?= yii\helpers\Url::to($url['loc'], true) ?></loc>
<?php if($langs) :
foreach ($langs as $lang) : ?>
<xhtml:link rel="alternate" hreflang="<?=$lang->url?>" href="<?= yii\helpers\Url::to((!$lang->default?'/'.$lang->url:'').($url['loc']=='/'?'':'/'.$url['loc']), true) ?>"/>
<?php endforeach;
endif; ?>
<?php if (isset($url['lastmod'])): ?>
<lastmod><?= is_string($url['lastmod']) ?
$url['lastmod'] : date(DATE_W3C, $url['lastmod']) ?></lastmod>
<?php endif; ?>
<?php if (isset($url['changefreq'])): ?>
<changefreq><?= $url['changefreq'] ?></changefreq>
<?php endif; ?>
<?php if (isset($url['priority'])): ?>
<priority><?= $url['priority'] ?></priority>
<?php endif; ?>
<?php if (isset($url['news'])): ?>
<news:news>
<news:publication>
<news:name><?= $url['news']['publication']['name'] ?></news:name>
<news:language><?= $url['news']['publication']['language'] ?></news:language>
</news:publication>
<?php
echo isset($url['news']['access']) ? "<news:access>{$url['news']['access']}</news:access>" : '';
echo isset($url['news']['genres']) ? "<news:genres>{$url['news']['genres']}</news:genres>" : '';
?>
<news:publication_date>
<?= is_string($url['news']['publication_date']) ?
$url['news']['publication_date'] : date(DATE_W3C, $url['news']['publication_date']) ?>
</news:publication_date>
<news:title> <?= $url['news']['title'] ?></news:title>
<?php
echo isset($url['news']['keywords']) ?
"<news:keywords>{$url['news']['keywords']}</news:keywords>" : '';
echo isset($url['news']['stock_tickers']) ?
"<news:stock_tickers>{$url['news']['stock_tickers']}</news:stock_tickers>" : '';
?>
</news:news>
<?php endif; ?>
<?php if (isset($url['images'])):
foreach ($url['images'] as $image): ?>
<image:image>
<image:loc><?= yii\helpers\Url::to($image['loc'], true) ?></image:loc>
<?php
echo isset($image['caption']) ?
"<image:caption>{$image['caption']}</image:caption>" : '';
echo isset($image['geo_location']) ?
"<image:geo_location>{$image['geo_location']}</image:geo_location>" : '';
echo isset($image['title']) ?
"<image:title>{$image['title']}</image:title>" : '';
echo isset($image['license']) ?
"<image:license>{$image['license']}</image:license>" : '';
?>
</image:image>
<?php endforeach;
endif; ?>
</url>
<?php endforeach; ?>
</urlset>
...@@ -14,17 +14,22 @@ use common\modules\bids\models\Bid; ...@@ -14,17 +14,22 @@ use common\modules\bids\models\Bid;
<?php <?php
$model = new Bid; $model = new Bid;
$model->scenario = Bid::SCENARIO_CALLBACK; $model->scenario = Bid::SCENARIO_CALLBACK;
$model->form = Bid::FORM_CALLBACK;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'action' => '/', 'action' => '/',
'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'valid_form bids-form', 'class' => 'valid_form bids-form',
'data-title' => 'Заказать звонок',
'data-form' => 'Заказать звонок',
'data-tag' => Bid::TAG_TREATMENT
], ],
]); ?> ]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?> <?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?>
<?php echo Html::hiddenInput('Bid[form]', Bid::FORM_CALLBACK, ['class' => 'not_clear']); ?> <?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>
<?php echo $form->field($model, 'name', [ <?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>', 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
......
...@@ -45,17 +45,22 @@ $more = CoContent::find() ...@@ -45,17 +45,22 @@ $more = CoContent::find()
<?php <?php
$model = new Bid; $model = new Bid;
$model->scenario = Bid::SCENARIO_SUBSCRIBE; $model->scenario = Bid::SCENARIO_SUBSCRIBE;
$model->form = Bid::FORM_SUBSCRIBE;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'action' => '/', 'action' => '/',
'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'subsc_form bids-form', 'class' => 'subsc_form bids-form',
'data-title' => 'Кейс: ' . $title,
'data-form' => 'Подписаться на обновление',
'data-tag' => Bid::TAG_INVOLVEMENT
], ],
]); ?> ]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?> <?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?>
<?php echo Html::hiddenInput('Bid[form]', Bid::FORM_SUBSCRIBE, ['class' => 'not_clear']); ?> <?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>
<?php echo $form->field($model, 'email', [ <?php echo $form->field($model, 'email', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>', 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
......
...@@ -18,25 +18,29 @@ use common\modules\bids\models\Bid; ...@@ -18,25 +18,29 @@ use common\modules\bids\models\Bid;
<?php <?php
$model = new Bid; $model = new Bid;
$model->scenario = Bid::SCENARIO_PROJECT; $model->scenario = Bid::SCENARIO_PROJECT;
$model->form = Bid::FORM_PROJECT;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'id' => 'form_foot', 'id' => 'form_foot',
'action' => '/', 'action' => '/',
'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'footer_form bids-form', 'class' => 'footer_form bids-form',
'enctype' => 'multipart/form-data' 'data-title' => 'Рассчитать проект',
'data-form' => 'Рассчитать проект',
'data-tag' => Bid::TAG_TREATMENT
], ],
]); ?> ]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?> <?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?>
<?php echo Html::hiddenInput('Bid[form]', Bid::FORM_PROJECT, ['class' => 'not_clear']); ?> <?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>
<?php echo $form->field($model, 'name', [ <?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>', 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => [] 'errorOptions' => []
])->textInput([ ])->textInput([
'placeholder' => 'Ваше имя*', 'placeholder' => 'Ваше имя',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
]); ?> ]); ?>
...@@ -44,7 +48,7 @@ use common\modules\bids\models\Bid; ...@@ -44,7 +48,7 @@ use common\modules\bids\models\Bid;
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>', 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => [] 'errorOptions' => []
])->textInput([ ])->textInput([
'placeholder' => 'Телефон*', 'placeholder' => 'Телефон',
'class' => 'footer_form__input' 'class' => 'footer_form__input'
]); ?> ]); ?>
......
<meta name="title" content="<?php echo \Yii::$app->controller->meta_title?>"> <?php
<meta name="keywords" content="<?php echo \Yii::$app->controller->meta_keywords?>">
<meta name="description" content="<?php echo \Yii::$app->controller->meta_description?>">
<meta name='yandex-verification' content='6f739356d418cfe3' /> use common\modules\languages\models\Languages;
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"> $langs = Languages::find()->where(['!=', 'id', Languages::getCurrent()->id])->all();
<link rel="apple-touch-icon" href="/images/favicon/apple-touch-icon.png"> ?>
<link rel="apple-touch-icon" sizes="72x72" href="/images/favicon/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="/images/favicon/apple-touch-icon-114x114.png">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="title" content="<?php echo \Yii::$app->controller->meta_title?>">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"> <meta name="keywords" content="<?php echo \Yii::$app->controller->meta_keywords?>">
<meta name="description" content="<?php echo \Yii::$app->controller->meta_description?>">
<?php $this->registerCssFile('/css/animate.css');?> <meta name='yandex-verification' content='6f739356d418cfe3' />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<?php $this->registerCssFile('/js/libs/bootstrap/css/bootstrap.css');?> <?php if($langs) :
<?php $this->registerCssFile('/js/libs/magnific/magnific-popup.css');?> foreach ($langs as $lang) : $url = \Yii::$app->request->getLangUrl(); ?>
<?php $this->registerCssFile('/js/libs/bxslider/jquery.bxslider.css');?> <link rel="alternate" hreflang="<?=$lang->url?>" href="<?= yii\helpers\Url::to((!$lang->default?'/'.$lang->url:'').($url=='/'?'':'/'.$url), true) ?>" />
<?php endforeach;
endif; ?>
<?php $this->registerCssFile('/css/fonts.css');?> <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon">
<?php $this->registerCssFile('/css/screen.css');?> <link rel="apple-touch-icon" href="/images/favicon/apple-touch-icon.png">
<?php $this->registerCssFile('/css/media.css');?> <link rel="apple-touch-icon" sizes="72x72" href="/images/favicon/apple-touch-icon-72x72.png">
<?php $this->registerCssFile('/css/custom.css');?> <link rel="apple-touch-icon" sizes="114x114" href="/images/favicon/apple-touch-icon-114x114.png">
\ No newline at end of file
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<?php $this->registerCssFile('/css/animate.css');?>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
<?php $this->registerCssFile('/js/libs/bootstrap/css/bootstrap.css');?>
<?php $this->registerCssFile('/js/libs/magnific/magnific-popup.css');?>
<?php $this->registerCssFile('/js/libs/bxslider/jquery.bxslider.css');?>
<?php $this->registerCssFile('/css/fonts.css');?>
<?php $this->registerCssFile('/css/screen.css');?>
<?php $this->registerCssFile('/css/media.css');?>
<?php $this->registerCssFile('/css/custom.css');?>
\ No newline at end of file
...@@ -82,25 +82,29 @@ use \common\modules\bids\models\Bid; ...@@ -82,25 +82,29 @@ use \common\modules\bids\models\Bid;
<?php <?php
$model = new Bid; $model = new Bid;
$model->scenario = Bid::SCENARIO_CALLBACK; $model->scenario = Bid::SCENARIO_CALLBACK;
$model->form = Bid::FORM_MESSAGE;
$form = ActiveForm::begin([ $form = ActiveForm::begin([
'id' => 'form_foot', 'id' => 'form_foot',
'action' => '/', 'action' => '/',
'enableClientValidation' => false,
'options' => [ 'options' => [
'class' => 'sect_cont_form bids-form', 'class' => 'sect_cont_form bids-form',
'enctype' => 'multipart/form-data' 'data-title' => 'Отправить сообщение с сайта',
'data-form' => 'Отправить сообщение с сайта',
'data-tag' => Bid::TAG_TREATMENT
], ],
]); ?> ]); ?>
<?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?> <?php echo Html::hiddenInput('scenario', $model->scenario, ['class' => 'not_clear']); ?>
<?php echo Html::hiddenInput('Bid[form]', Bid::FORM_MESSAGE, ['class' => 'not_clear']); ?> <?php echo $form->field($model, 'form', ['template' => '{input}'])->hiddenInput(['class' => 'not_clear']); ?>
<?php echo $form->field($model, 'name', [ <?php echo $form->field($model, 'name', [
'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>', 'template' => '<div class="row"><div class="col-sm-4">{input}</div></div>',
'errorOptions' => [] 'errorOptions' => []
])->textInput([ ])->textInput([
'placeholder' => 'Ваше имя*', 'placeholder' => 'Ваше имя',
'class' => 'sect_cont_form__input' 'class' => 'sect_cont_form__input'
]); ?> ]); ?>
......
...@@ -50,7 +50,7 @@ $('form.bids-form').on('beforeSubmit', function(e) { ...@@ -50,7 +50,7 @@ $('form.bids-form').on('beforeSubmit', function(e) {
{ {
errors = []; errors = [];
$.each(response, function(key, value) { $.each(response, function(key, value) {
$('.field-'+key).addClass('has-error'); form.find('.field-'+key).addClass('has-error');
errors = errors.concat(value); errors = errors.concat(value);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment