Пример #1
0
	public function relations()
	{
		return array(
			'category' => array(self::BELONGS_TO, 'Category', 'category_id'),
			'widgets'=>array(self::MANY_MANY, 'TemplateWidget', 'templates_blocks_widgets_relations('.self::getPkAttr().', '.TemplateWidget::getPkAttr().')'),
		);
	}
Пример #2
0
    public function actionAddWidgets($blockPk)
    {
        if (isset($_POST['newWidgets'])) {
            $widgets = array();
            foreach ($_POST['newWidgets'] as $pk) {
                $widgets[] = TemplateWidget::model()->findByPk($pk);
            }
            $block = TemplateBlock::model()->findByPk($blockPk);
            $block->widgets = CMap::mergeArray($block->widgets, $widgets);
            
            $this->renderPartial('item', array('models'=>$widgets));
        } else {
            //make list of widgets
            $widgets = TemplateWidget::model()->notInBlock($blockPk)->findAll();
            $list = CHtml::listData($widgets, 'pk', 'title');

            $this->renderPartial("/widgets/widgetChangeForm", array('widgets'=>$list), false, true);
        }
    }
Пример #3
0
 public function actionAll()
 {
     $createdWidgets = TemplateWidget::model()->findAll();
     
     $widgets = array();
     foreach ($createdWidgets as $model) {
         $widgets[] = array(
             'text'=>$model->getDetailsLink(array(), array('update'=>"#widget-details")),
             'htmlOptions'=>array(
                 'id'=>"widgets_".$model->pk,
                 'class'=>'widget-link'
             )
         );
     }
     $this->renderPartial('all', array('widgets'=>$widgets), false, true);
 }