(C) Moorfields Eye Hospital NHS Foundation Trust, 2008-2011 (C) OpenEyes Foundation, 2011-2013 This file is part of OpenEyes. OpenEyes is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenEyes is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenEyes in a file titled COPYING. If not, see .
Author: OpenEyes (info@openeyes.org.uk)
Inheritance: extends CWidget
コード例 #1
0
 public function init()
 {
     $model = $this->model;
     if (!$this->extra_fields) {
         $this->extra_fields = array();
     }
     if (empty($_POST['id'])) {
         $this->data = $model::model()->findAll(array('order' => 'display_order asc'));
     } else {
         $this->data = array();
         foreach ($_POST['id'] as $i => $id) {
             $item = new $model();
             $item->id = $id;
             $item->name = $_POST['name'][$i];
             $attributes = $item->getAttributes();
             if (array_key_exists('active', $attributes)) {
                 $item->active = isset($_POST['active'][$i]) || intval($id) == 0 ? 1 : 0;
             }
             foreach ($this->extra_fields as $field) {
                 $item->{$field['field']} = $_POST[$field['field']][$i];
             }
             $this->data[] = $item;
         }
     }
     return parent::init();
 }
コード例 #2
0
ファイル: GenericAdmin.php プロジェクト: openeyes/openeyes
 public function init()
 {
     $model = $this->model;
     if (!$this->extra_fields) {
         $this->extra_fields = array();
     }
     if ($model::model()->hasAttribute('default')) {
         if (!empty($this->items)) {
             foreach ($this->items as $item) {
                 if ($item->default) {
                     $this->has_default = true;
                 }
             }
         }
     }
     return parent::init();
 }