public function notInBlock($blockPk) { //don't show widgets that already in block $existWidgets = TemplateBlock::model()->findByPk($blockPk)->widgets; $ids = CHtml::listData($existWidgets, 'pk', 'pk'); return $this->notIn($ids); }
public function __construct($node, $parent) { parent::__construct($node, $parent); self::$possible_attributes = array_merge(parent::$possible_attributes, self::$possible_attributes); self::$required_attributes = array_merge(parent::$required_attributes, self::$required_attributes); self::$possible_children = array_merge(parent::$possible_children, self::$possible_children); self::$required_children = array_merge(parent::$required_children, self::$required_children); }
public function actionMakeOwn($catPk, $blockPk) { $cat = Category::model()->findByPk($catPk); $block = TemplateBlock::model()->findByPk($blockPk); $newBlock = $block->copy(); $db = Yii::app()->db; $transaction = $db->beginTransaction(); try { //create new Block $newBlock->category_id = null; $cat->blocks = array($newBlock); $cat->save(); //Create copies of components $widgets = $block->widgets; foreach ($widgets as $widget) { $widget->pk = null; $widget->block_id = null; } //save components $newBlock->widgets = $widgets; $newBlock->save(); $transaction->commit(); echo 'ok'; } catch(CException $e) { $transaction->rollBack(); echo $e->__toString(); } }