Пример #1
0
 /**
  * Display all options
  * @return void
  */
 function viewAll()
 {
     global $DB, $USER;
     $r = $DB->config->get(array('type!' => 'not_editable'), false, false, 'section,property');
     $form = new Form();
     $e = $this->may($USER, EDIT);
     $lastSectionName = false;
     $lastSection = false;
     $sections = array();
     while ($c = Database::fetchAssoc($r)) {
         if ($lastSectionName != $c['section']) {
             $lastSectionName = $c['section'];
             if ($lastSection != false && $lastSection->count() == 0) {
                 array_pop($sections);
             }
             $sections[] = $lastSection = new Fieldset(ucwords(str_replace('_', ' ', $c['section'])));
         }
         $mult = false;
         $a = false;
         switch ($c['type']) {
             case 'CSV':
                 if (is_array($c['value'])) {
                     $c['value'] = @join(',', $c['value']);
                 }
             case 'text':
                 if ($e) {
                     $a = new Input(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', $c['value'], null, __($c['description']));
                 } else {
                     $a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">' . $c['value'] . '</span><span class="description">' . __($c['description']) . '</span>';
                 }
                 break;
             case 'password':
                 if ($e) {
                     $a = new Password(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', '********', null, __($c['description']));
                 } else {
                     $a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">********</span><span class="description">' . __($c['description']) . '</span>';
                 }
                 break;
             case 'set':
                 $mult = true;
             case 'select':
                 if (is_array($c['set'])) {
                     if ($e) {
                         $a = new Select(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', array_map('__', $c['set']), $c['value'], $mult, false, false, __($c['description']));
                     } else {
                         $a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">' . @$c['set'][$c['value']] . '</span><span class="description">' . __($c['description']) . '</span>';
                     }
                 }
                 break;
             case 'check':
                 if ($e) {
                     $a = new Checkbox(ucwords(__(str_replace('_', ' ', $c['property']))), 'conf[' . $c['section'] . '][' . $c['property'] . ']', $c['value'], $c['value'], false, __($c['description']));
                 } else {
                     $a = '<span class="property">' . ucwords(__(str_replace('_', ' ', $c['property']))) . ':</span> <span class="value">' . $c['value'] . '</span><span class="description">' . __($c['description']) . '</span>';
                 }
                 break;
         }
         if ($a) {
             $lastSection->add($a);
         }
     }
     if ($lastSection != false && $lastSection->count() == 0) {
         array_pop($sections);
     }
     if ($e) {
         return $form->collection($sections);
     } else {
         return join('', $sections);
     }
 }