function __construct($opts) { if (!($model = MMap::getValue($opts, 'model'))) { throw new Exception('no model for list display'); } $this->model = $model; $this->opts = $opts; $columns = array(); if (isset($opts['columns'])) { foreach ($opts['columns'] as $k => $v) { if ('buttons' === $k) { !$v && ($v = array()); $v = array_merge($v, array('grid' => $this)); $this->buttons = new MButton($v); continue; } else { if (is_array($v)) { $columns[$v[0]] = array_slice($v, 1); } else { $columns[$v] = array(); } } } } $this->columns = $columns; $options = array('url' => app()->controller->getRequest()->uri, 'ajaxType' => 'GET', 'ajaxUpdate' => array($this->id), 'pageVar' => $this->pagerVar(), 'ajaxVar' => $this->ajaxVar, 'pagerClass' => 'pagination', 'loadingClass' => 'grid-view-loading', 'filterClass' => 'filters', 'tableClass' => 'items table table-hover', 'selectableRows' => 1, 'enableHistory' => false, 'updateSelector' => '{page}, {sort}', 'filterSelector' => '{filter}'); $options = MJavaScript::encode($options); app()->controller->appendScript(__CLASS__ . '#' . $this->getId(), "jQuery('#{$this->id}').yiiGridView({$options});"); }
function createWidget($owner, $className, $properties = array()) { $className = Monc::importlib($className, true); $widget = new $className($owner); if (isset($this->widgets[$className])) { $properties = $properties === array() ? $this->widgets[$className] : MMap::mergeArray($this->widgets[$className], $properties); } foreach ($properties as $name => $value) { $widget->{$name} = $value; } return $widget; }
/** * @param $model * @param $attribute * @param $htmlOptions * @return array */ protected static function activeControlBefore($model, $attribute, $htmlOptions) { $modelClass = get_class($model); $controlOptions = MMap::getValue($htmlOptions, 'controlOptions'); $labelOptions = MMap::getValue($htmlOptions, 'labelOptions'); $classL = MMap::getValue($labelOptions, 'class'); $id = MMap::getValue($htmlOptions, 'id'); !$id && ($id = self::id($model, $attribute)); $class = MMap::getValue($controlOptions, 'class'); $class .= ' ' . 'data-' . $class; $uniqid = uniqid(); $labelAttr = $model->label($attribute); $labelAttr = t($labelAttr); $value = $model->{$attribute}; return array($modelClass, $classL, $id, $class, $uniqid, $labelAttr, $value); }
<?php $main = (require dirname(__FILE__) . DS . '..' . DS . "main.php"); return MMap::mergeArray($main, array('db' => array('dsn' => 'mysql:host=localhost;dbname=monc-php', 'user' => 'root', 'password' => '123', 'charset' => 'utf-8')));
<?php $main = (require dirname(__FILE__) . DS . '..' . DS . "main.php"); return MMap::mergeArray($main, array('db' => array('dsn' => 'mysql:host=[hostname];dbname=[dbname]', 'user' => '[user]', 'password' => '[pwd]', 'charset' => 'utf-8')));