示例#1
0
 protected function getModels()
 {
     $models = array();
     $files = scandir(Yii::getPathOfAlias('application.models'));
     foreach ($files as $file) {
         if ($file[0] !== '.' && CFileHelper::getExtension($file) === 'php') {
             $fileClassName = substr($file, 0, strpos($file, '.'));
             if (class_exists($fileClassName) && is_subclass_of($fileClassName, 'GiiyActiveRecord')) {
                 $fileClass = new ReflectionClass($fileClassName);
                 if (!$fileClass->isAbstract() && !is_array(GiiyActiveRecord::model($fileClassName)->getPrimaryKey())) {
                     $models[] = $fileClassName;
                 }
             }
         }
     }
     foreach (Yii::app()->getModules() as $module => $moduleConf) {
         if (Yii::getPathOfAlias($module . '.models')) {
             $files = scandir(Yii::getPathOfAlias($module . '.models'));
             foreach ($files as $file) {
                 if ($file[0] !== '.' && CFileHelper::getExtension($file) === 'php') {
                     $fileClassName = substr($file, 0, strpos($file, '.'));
                     if (class_exists($fileClassName) && is_subclass_of($fileClassName, 'GiiyActiveRecord')) {
                         $fileClass = new ReflectionClass($fileClassName);
                         if (!$fileClass->isAbstract() && !is_array(GiiyActiveRecord::model($fileClassName)->getPrimaryKey())) {
                             $models[] = $fileClassName;
                         }
                     }
                 }
             }
         }
     }
     return $models;
 }
示例#2
0
 public function wrapField($html, $attribute)
 {
     if ($this->model instanceof ITypeEnumerable && $attribute !== $this->model->tableSchema->primaryKey) {
         $classes = array('typeEnumerable');
         $hidden = true;
         foreach ($this->model->getTypesFields() as $type_id => $fields) {
             if (in_array($attribute, $fields)) {
                 $classes[] = 'typeEnumerable_' . $type_id;
                 if ($this->model->getType() && $this->model->getType()->id == $type_id) {
                     $hidden = false;
                 }
             }
         }
         $html = '<div name="' . $attribute . '" class="' . join(' ', $classes) . '" ' . ($hidden ? 'style="display:none" ' : '') . '>' . $html . '</div>';
     }
     return $html;
 }
示例#3
0
 public function renderWidget($widget)
 {
     ob_start();
     if ($widget instanceof TbSelect2 or $widget instanceof TbDatePicker or $widget instanceof TbTimePicker or $widget instanceof CJuiDateTimePicker) {
         echo $this->label($this->model, $widget->attribute, $widget->htmlOptions);
     }
     $widget->run();
     $html = ob_get_clean();
     if ($this->model instanceof ITypeEnumerable && $widget->attribute !== $this->model->tableSchema->primaryKey) {
         $classes = array('typeEnumerable');
         $hidden = true;
         foreach ($this->model->getTypesFields() as $type_id => $fields) {
             if (in_array($widget->attribute, $fields)) {
                 $classes[] = 'typeEnumerable_' . $type_id;
                 if ($this->model->getType() && $this->model->getType()->id == $type_id) {
                     $hidden = false;
                 }
             }
         }
         $html = '<div name="' . $widget->attribute . '" class="' . join(' ', $classes) . '" ' . ($hidden ? 'style="display:none" ' : '') . '>' . $html . '</div>';
     }
     return $html;
 }
示例#4
0
文件: admin.php 项目: schyzoo/giiy
<?
/**
 * The following variables are available in this template:
 * - $this: the BootCrudCode object
 */
?>
<?
$model = GiiyActiveRecord::model($this->modelClass);
echo "<?\n";
$label=$this->pluralize($this->class2name($this->modelClass));
echo "\$this->breadcrumbs=array(
	'$label'=>array('index'),
	'Manage',
);\n";
?>

$this->menu=array(
	array('label'=>'List <?php 
echo $this->modelClass;
?>
','url'=>array('index')),
	array('label'=>'Create <?php 
echo $this->modelClass;
?>
','url'=>array('create')),
);

Yii::app()->clientScript->registerScript('search', "
$('.search-button').click(function(){
	$('.search-form').toggle();
	return false;
示例#5
0
 public static function model($className = __CLASS__)
 {
     return parent::model($className);
 }
示例#6
0
    /**
     * @param GiiyActiveRecord $model
     * @return CActiveDataProvider
     */
    public function getDataProvider(GiiyActiveRecord $model)
    {
        /** @var CActiveDataProvider $dataProvider */
        $dataProvider = $model->search();
        $dataProvider->getPagination()->pageSize = 15;

        return $dataProvider;
    }