public function getListView(&$criteria, $return = false)
    {
        $dp = new EActiveDataProvider(get_class($this->model), array(
            'criteria' => $criteria,
            //'pagination' => $this->settings['pagination'],
        ));

        //default params
        $params = array(
            'dataProvider'=>$dp,
            'pager'=>array(
                'id'=>$this->widgetModel->pk.'Pager', 'class'=>'LinkPager', 'htmlOptions'=>array('class'=>'pager'),
                'cssFile'=>Yii::app()->baseUrl.'/css/pager.css'
            ),
            'ajaxUpdate'=>true,
            'template'=>$this->render('listTemplate', array(), true),
            'afterAjaxUpdate' => ModelFactory::getAfterAjaxUpdateFunction($this->category->type),
            'beforeAjaxUpdate' => ModelFactory::getBeforeAjaxUpdateFunction($this->category->type),
            'category' => $this->category,
            'contextWidget' => $this
        );

        try {
            $res = Y::controller()->widget('ListView', $params, true);
        } catch (CException $e) {
            Y::dump($e->__toString());
        }

        if ($return)
            return $res;
        else
            echo $res;
    }
Example #2
0
 public function __toString() //__toString can't throw Exception in PHP
 {
     try {
         return $this->renderBlock($this->templateAlias);
     } catch (CException $e) {
         Y::dump($e->__toString());
     }
 }
 public function setPositions($ids, $table, $criteria = null)
 {
     $criteria = $criteria ? $criteria : new CDbCriteria();
     $owner = $this->getOwner();
     $pk = $owner->primaryKey();
     //last id have 0 priority => revers => first id have 0 priority => flip => every id have their priority
     $priorities = array_flip(array_reverse($ids));
     $data = array('priority' => Sql::arrToCase($pk, $priorities));
     $c = Yii::app()->db->commandBuilder->createUpdateCommand($table, $data, $criteria);
     Y::dump($c->execute());
 }
	/**
	 * Manages all models.
	 */
	public function actionAdmin()
	{
		$all = Lookup::model()->getAll();
		Y::dump($all);
		$model = new Portfolio('search');
		$model->unsetAttributes();  // clear any default values
		$model = $model->current($cat);
		
		if (isset($_GET['Portfolio']))
			$model->attributes=$_GET['Portfolio'];
		
		if (isset($_GET['ajax'])) {
			$this->renderPartial('admingrid',array(
	            'model'=>$model,
		    ));
    	} else {
    		$this->render('admin',array(
				'model'=>$model,
    			'cat'=>$cat
    		));
		}
	}
Example #5
0
 public function actionBisec()
 {
     $c = Yii::app()->db->getCommandBuilder()->createFindCommand('edge', new CDbCriteria(array('condition' => 't.edge="associate"')));
     $data = $c->limit(1000)->query();
     $n = Node::model()->count();
     $tmp = array_fill(0, $n, 10000);
     $W = array_fill(0, $n, $tmp);
     $k = 0;
     foreach ($data as $item) {
         $i = (int) $item['source'];
         $j = (int) $item['target'];
         $W[$i][$j] = $W[$j][$i] = 1;
         if (++$k > 100) {
             break;
         }
     }
     Y::end(round(memory_get_peak_usage() / (1024 * 1024), 2) . "MB");
     $f = Yii::getPathOfAlias('application') . '/../gr.txt';
     Y::dump(file_put_contents($f, json_encode($W)));
     // Initialization
     for ($i = 0; $i < $n; $i++) {
         $W[$i][$i] = INF;
     }
     $f = Yii::getPathOfAlias('application') . '/../gr.txt';
     Y::dump(file_put_contents($f, json_encode($W)));
     // Algorithm
     for ($k = 0; $k < $n; $k++) {
         for ($i = 0; $i < $n; $i++) {
             for ($j = 0; $j < $n; $j++) {
                 $W[$i][$j] = min($W[$i][$j], $W[$i][$k] + $W[$k][$j]);
             }
         }
         if ($k == 10) {
             break;
         }
     }
     Y::end($W);
 }
	public function actionSaveWidgetsPosition($blockPk, $widgets)
	{
		Y::dump($widgets);
	}
 public function handlerUpdate($event)
 {
     Y::dump($this->getViewPath());
 }