private function normalize_field(&$field)
 {
     foreach ($field as $key => $value) {
         if (in_array($value, array('true', 'false'))) {
             $field[$key] = filter_var($value, FILTER_VALIDATE_BOOLEAN);
         }
         // Handle some key / value pairs
         if (($key === 'options' || $key === 'js_options' || $key === 'query_args') && is_array($value)) {
             // Options aren't affected with taxonomies
             if ($field['type'] === 'taxonomy' || $field['type'] === 'taxonomy_advanced') {
                 continue;
             }
             $tmp_array = array();
             $tmp_std = array();
             foreach ($value as $arr) {
                 $skip = empty($arr['key']);
                 if (in_array($arr['value'], array('true', 'false'))) {
                     $arr['value'] = filter_var($arr['value'], FILTER_VALIDATE_BOOLEAN);
                 }
                 $tmp_array[$arr['key']] = $arr['value'];
                 if (isset($arr['selected']) && $arr['selected']) {
                     $tmp_std[] = $arr['key'];
                 }
                 // Push default value to std on Text List
                 if (isset($arr['default']) && !empty($arr['default'])) {
                     if ($field['type'] === 'fieldset_text') {
                         $tmp_std[$arr['value']] = $arr['default'];
                     } else {
                         $tmp_std[] = $arr['default'];
                     }
                 }
             }
             if (!isset($skip) || !$skip) {
                 $field[$key] = $tmp_array;
             }
             if (!empty($tmp_std)) {
                 $field['std'] = $tmp_std;
             }
             // if ( count( $tmp_std ) > 0 )
             // 	$field['std'] = $tmp_std[0];
         }
         // Remember unset the empty value on the last.
         if (empty($value)) {
             unset($field[$key]);
         }
     }
     unset($field['$$hashKey']);
     if (empty($field['datalist']['id'])) {
         unset($field['datalist']);
     }
     if (!empty($field['id'])) {
         $field['id'] = str_snake($field['id']);
     }
     // Move Tabs to Meta Box
     if (isset($field['type']) && $field['type'] === 'tab') {
         if (!isset($this->meta_box['tabs'])) {
             $this->meta_box['tabs'] = array();
         }
         $this->meta_box['tabs'][$field['id']] = array('label' => $field['label']);
         if (!empty($field['icon'])) {
             $this->meta_box['tabs'][$field['id']]['icon'] = $field['icon'];
         }
     }
     return $this;
 }
예제 #2
0
 /**
  * Make the classes from controller and action
  *
  * @return string
  */
 public function makeClassFromController()
 {
     if (!($action = Route::currentRouteAction())) {
         return;
     }
     // Strip restful prefixes and suffices
     preg_match('#(\\w+)Controller@(?:get|post)?(\\w+)#i', $action, $matches);
     // Make an action for missing methods
     if ($matches[2] == 'missingMethod') {
         $matches[2] = implode(' ', Request::segments());
     }
     // Combine controller and action to make class
     return str_snake($matches[1], '-') . ' ' . Str::snake($matches[2], '-');
 }