예제 #1
0
파일: form.php 프로젝트: vanie3/appland
 protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false)
 {
     // Handle the optional arguments.
     $options['control'] = MArrayHelper::getValue($options, 'control', false);
     // Create a signature hash.
     $hash = md5($source . serialize($options));
     // Check if we can use a previously loaded form.
     if (isset($this->_forms[$hash]) && !$clear) {
         return $this->_forms[$hash];
     }
     // Get the form.
     MForm::addFormPath(MPATH_COMPONENT . '/models/forms');
     MForm::addFieldPath(MPATH_COMPONENT . '/models/fields');
     try {
         $form = MForm::getInstance($name, $source, $options, false, $xpath);
         if (isset($options['load_data']) && $options['load_data']) {
             // Get the data for the form.
             $data = $this->loadFormData();
         } else {
             $data = array();
         }
         // Allow for additional modification of the form, and events to be triggered.
         // We pass the data because plugins may require it.
         $this->preprocessForm($form, $data);
         // Load the data into the form after the plugins have operated.
         $form->bind($data);
     } catch (Exception $e) {
         $this->setError($e->getMessage());
         return false;
     }
     // Store the form for later.
     $this->_forms[$hash] = $form;
     return $form;
 }
예제 #2
0
파일: admin.php 프로젝트: vanie3/appland
 public function batch($commands, $pks, $contexts)
 {
     // Sanitize user ids.
     $pks = array_unique($pks);
     MArrayHelper::toInteger($pks);
     // Remove any values of zero.
     if (array_search(0, $pks, true)) {
         unset($pks[array_search(0, $pks, true)]);
     }
     if (empty($pks)) {
         $this->setError(MText::_('MGLOBAL_NO_ITEM_SELECTED'));
         return false;
     }
     $done = false;
     if (!empty($commands['category_id'])) {
         $cmd = MArrayHelper::getValue($commands, 'move_copy', 'c');
         if ($cmd == 'c') {
             $result = $this->batchCopy($commands['category_id'], $pks, $contexts);
             if (is_array($result)) {
                 $pks = $result;
             } else {
                 return false;
             }
         } elseif ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks, $contexts)) {
             return false;
         }
         $done = true;
     }
     if (!empty($commands['assetgroup_id'])) {
         if (!$this->batchAccess($commands['assetgroup_id'], $pks, $contexts)) {
             return false;
         }
         $done = true;
     }
     if (!empty($commands['language_id'])) {
         if (!$this->batchLanguage($commands['language_id'], $pks, $contexts)) {
             return false;
         }
         $done = true;
     }
     if (!$done) {
         $this->setError(MText::_('MLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION'));
         return false;
     }
     // Clear the cache
     $this->cleanCache();
     return true;
 }
예제 #3
0
파일: mgrid.php 프로젝트: vanie3/appland
 public static function state($states, $value, $i, $prefix = '', $enabled = true, $translate = true, $checkbox = 'cb')
 {
     if (is_array($prefix)) {
         $options = $prefix;
         $enabled = array_key_exists('enabled', $options) ? $options['enabled'] : $enabled;
         $translate = array_key_exists('translate', $options) ? $options['translate'] : $translate;
         $checkbox = array_key_exists('checkbox', $options) ? $options['checkbox'] : $checkbox;
         $prefix = array_key_exists('prefix', $options) ? $options['prefix'] : '';
     }
     $state = MArrayHelper::getValue($states, (int) $value, $states[0]);
     $task = array_key_exists('task', $state) ? $state['task'] : $state[0];
     $text = array_key_exists('text', $state) ? $state['text'] : (array_key_exists(1, $state) ? $state[1] : '');
     $active_title = array_key_exists('active_title', $state) ? $state['active_title'] : (array_key_exists(2, $state) ? $state[2] : '');
     $inactive_title = array_key_exists('inactive_title', $state) ? $state['inactive_title'] : (array_key_exists(3, $state) ? $state[3] : '');
     $tip = array_key_exists('tip', $state) ? $state['tip'] : (array_key_exists(4, $state) ? $state[4] : false);
     $active_class = array_key_exists('active_class', $state) ? $state['active_class'] : (array_key_exists(5, $state) ? $state[5] : '');
     $inactive_class = array_key_exists('inactive_class', $state) ? $state['inactive_class'] : (array_key_exists(6, $state) ? $state[6] : '');
     return self::action($i, $task, $prefix, $text, $active_title, $inactive_title, $tip, $active_class, $inactive_class, $enabled, $translate, $checkbox);
 }