clear column CoBlocks

parent 646c7008
...@@ -86,26 +86,14 @@ class CoBlocks extends \common\components\ActiveRecordModel ...@@ -86,26 +86,14 @@ class CoBlocks extends \common\components\ActiveRecordModel
* @block string name block * @block string name block
* @return HTML string * @return HTML string
*/ */
public static function printBlock($block) { public static function printBlock($block)
$model = self::findOne(['name'=>$block]); {
return $model->text; $model = self::findOne(['name' => $block]);
return $model->lang->text;
} }
public static function printStaticBlock($block, $addPath = false) public static function printStaticBlock($block, $addPath = false)
{ {
return Yii::$app->getView()->render( '@app/views/layouts/block/' . $block . '.php'); return Yii::$app->getView()->render( '@app/views/layouts/block/' . $block . '.php');
} }
public function afterFind() {
parent::afterFind();
if(Yii::$app->controller->id !='block-admin')
$this->text = \common\components\AppManager::prepareWidget($this->text);
$this->text = str_replace('../../../','/',$this->text);
}
public function beforeSave($insert) {
$this->text = str_replace("../../../source/","http://taskon.soc-zaim.ru/source/",$this->text);
return parent::beforeSave($insert);
}
} }
...@@ -70,6 +70,18 @@ class CoBlocksLang extends \common\components\ActiveRecordModel ...@@ -70,6 +70,18 @@ class CoBlocksLang extends \common\components\ActiveRecordModel
]; ];
} }
public function afterFind()
{
parent::afterFind();
if(Yii::$app->controller->id !='block-admin')
{
$this->text = \common\components\AppManager::prepareWidget($this->text);
}
$this->text = str_replace('../../../', '/', $this->text);
}
/** /**
* @return \yii\db\ActiveQuery * @return \yii\db\ActiveQuery
*/ */
......
<?php
use yii\db\Migration;
class m160203_090311_drop_column_blocks extends Migration
{
public function up()
{
$this->dropColumn('co_blocks', 'text');
}
public function down()
{
$this->createColumn('co_blocks', 'text', 'longtext NOT NULL');
}
}
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