Exemplo n.º 1
0
 public function action_new()
 {
     Breadcrumbs::add(Breadcrumb::factory()->set_title(__('New')));
     $this->template->title = __('New Custom Field for Advertisement');
     //find all, for populating form select fields
     list($categories) = Model_Category::get_all();
     if ($_POST) {
         $name = URL::title(Core::post('name'));
         $field = new Model_Field();
         try {
             $options = array('label' => Core::post('label'), 'tooltip' => Core::post('tooltip'), 'required' => Core::post('required') == 'on' ? TRUE : FALSE, 'searchable' => Core::post('searchable') == 'on' ? TRUE : FALSE);
             if ($field->create($name, Core::post('type'), Core::post('values'), Core::post('categories'), $options)) {
                 Cache::instance()->delete_all();
                 Theme::delete_minified();
                 Alert::set(Alert::SUCCESS, __('Field created ' . $name));
                 Request::current()->redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
             } else {
                 Alert::set(Alert::ERROR, __('Field already exists ' . $name));
             }
         } catch (Exception $e) {
             throw new HTTP_Exception_500();
         }
     }
     $this->template->content = View::factory('oc-panel/pages/fields/new', array('categories' => $categories));
 }
Exemplo n.º 2
0
 public function action_template()
 {
     if ($_POST) {
         $cf_templates = '
                         {
                             "cars": [
                                 {
                                     "name": "forsaleby",
                                     "type": "select",
                                     "label": "For sale by",
                                     "tooltip": "For sale by",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Owner,Dealer"
                                 },
                                 {
                                     "name": "adtype",
                                     "type": "select",
                                     "label": "Ad type",
                                     "tooltip": "Ad type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "I’m selling my car,I’m looking for a car to buy"
                                 },
                                 {
                                     "name": "make",
                                     "type": "select",
                                     "label": "Make",
                                     "tooltip": "Make",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Acura,Alfa Romeo,AM General,AMC,Aston Martin,Audi,Austin-Healey,Bently,BMW,Bricklin,Bugatti,Buick,Cadillac,Chevrolet,Chrysler,Daewoo,Datsun,Diahatsu,Dodge,Eagle,Ferrari,Fiat,Ford,Geo,GMC,Honda,HUMMER,Hyundai,Infiniti,International Harvester,Isuzu,Jaguar,Jeep,Kia,Lamborghini,Land Rover,Lexus,Lincoln,Lotus,Maserati,Maybach,Mazda,Mercedes-Benz,Mercury,MG,MINI,Mitsubishi,Nissan,Oldsmobile,Opel,Peugeot,Plymouth,Pontiac,Porsche,Ram,Renault,Rolls-Royce,Saab,Saturn,Scion,Shelby,Smart,Subaru,Suzuki,Toyota,Triumph,Volkswagen,Volvo,Other"
                                 },
                                 {
                                     "name": "othermake",
                                     "type": "string",
                                     "label": "Other make",
                                     "tooltip": "Other make",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "model",
                                     "type": "string",
                                     "label": "Model",
                                     "tooltip": "Model",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "year",
                                     "type": "integer",
                                     "label": "Year",
                                     "tooltip": "Year",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "kilometers",
                                     "type": "integer",
                                     "label": "Kilometers",
                                     "tooltip": "Kilometers",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "bodytype",
                                     "type": "select",
                                     "label": "Body type",
                                     "tooltip": "Body type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Convertible,Coupe (2 door),Hatchback,Minivan or Van,Pickup Truck,Sedan,SUV. crossover,Wagon,Other"
                                 },
                                 {
                                     "name": "transmission",
                                     "type": "select",
                                     "label": "Transmission",
                                     "tooltip": "Transmission",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Automatic,Manual,Other"
                                 },
                                 {
                                     "name": "drivetrain",
                                     "type": "select",
                                     "label": "Drivetrain",
                                     "tooltip": "Drivetrain",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "4 x 4,All-wheel drive (AWD),Front-wheel drive (FWD),Rear-wheel drive (RWD),Other"
                                 },
                                 {
                                     "name": "color",
                                     "type": "select",
                                     "label": "Color",
                                     "tooltip": "Color",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Black,Blue,Brown,Burgundy,Gold,Green,Grey,Orange,Pink,Purple,Red,Silver,Tan,Teal,White,Yellow,Other"
                                 },
                                 {
                                     "name": "fueltype",
                                     "type": "select",
                                     "label": "Fuel Type",
                                     "tooltip": "Fuel Type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Diesel,Gasoline,Hybrid-Electric,Other"
                                 },
                                 {
                                     "name": "type",
                                     "type": "select",
                                     "label": "Type",
                                     "tooltip": "Type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Damaged,Lease Takeover,New,Used"
                                 }
                             ],
                             "houses": [
                                 {
                                     "name": "furnished",
                                     "type": "select",
                                     "label": "Furnished",
                                     "tooltip": "Furnished",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Yes,No"
                                 },
                                 {
                                     "name": "bedrooms",
                                     "type": "select",
                                     "label": "Bedrooms",
                                     "tooltip": "Bedrooms",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Studio,1,2,3,4,5,6,7,8,9,10"
                                 },
                                 {
                                     "name": "bathrooms",
                                     "type": "select",
                                     "label": "Bathrooms",
                                     "tooltip": "Bathrooms",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "1,2,3,4,5,6,7,8,9,10"
                                 },
                                 {
                                     "name": "pets",
                                     "type": "select",
                                     "label": "Pets",
                                     "tooltip": "Pets",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "yes,No"
                                 },
                                 {
                                     "name": "agencybrokerfee",
                                     "type": "select",
                                     "label": "Agency\\/broker fee",
                                     "tooltip": "Agency\\/broker fee",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Yes,No"
                                 },
                                 {
                                     "name": "squaremeters",
                                     "type": "string",
                                     "label": "Square meters",
                                     "tooltip": "Square meters",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "pricenegotiable",
                                     "type": "checkbox",
                                     "label": "Price negotiable",
                                     "tooltip": "Price negotiable",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 }
                             ],
                             "jobs": [
                                 {
                                     "name": "jobtype",
                                     "type": "select",
                                     "label": "Job type",
                                     "tooltip": "Job type",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Full-time,Part-time"
                                 },
                                 {
                                     "name": "experienceinyears",
                                     "type": "select",
                                     "label": "Experience in Years",
                                     "tooltip": "Experience in Years",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Less than 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,More than 20"
                                 },
                                 {
                                     "name": "salary",
                                     "type": "integer",
                                     "label": "Salary",
                                     "tooltip": "Salary",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "salarytype",
                                     "type": "select",
                                     "label": "Salary type",
                                     "tooltip": "Salary type",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "Hourly,Daily,Weekly,Monthly,Quarterly,Yearly"
                                 },
                                 {
                                     "name": "extrainformation",
                                     "type": "textarea",
                                     "label": "Extra information",
                                     "tooltip": "Extra information",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "company",
                                     "type": "string",
                                     "label": "Company",
                                     "tooltip": "Company name",
                                     "required": true,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "companydescription",
                                     "type": "textarea",
                                     "label": "Company description",
                                     "tooltip": "Company description",
                                     "required": false,
                                     "searchable": false,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 }
                             ],
                             "dating": [
                                 {
                                     "name": "age",
                                     "type": "integer",
                                     "label": "Age",
                                     "tooltip": "Age",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": ""
                                 },
                                 {
                                     "name": "body",
                                     "type": "select",
                                     "label": "Body",
                                     "tooltip": "Body",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "-,Athletic,Average,big,Curvy,Fit,Heavy,HWP,Skinny,Thin,"
                                 },
                                 {
                                     "name": "height",
                                     "type": "select",
                                     "label": "Height",
                                     "tooltip": "Height",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": true,
                                     "values": "Taller than 6.8 (203 cm),6.7 (200 cm),6.6 (198 cm),6.5 (195 cm),6.4 (194cm),6.3 (190 cm),6.2 (187 cm),6.1 (185 cm),6.0 (182 cm),5.11 (180 cm),5.10 (177 cm),5.9 (175 cm),5.8 (172 cm),5.7 (170 cm),5.6 (167 cm),5.5 (165 cm),5.4 (162 cm),5.3 (160 cm),5.2 (157 cm),5.1 (154 cm),5.0 (152 cm),4.11 (150 cm),4.10 (147 cm),4.9 (145 cm),4.8 (142 cm) or less"
                                 },
                                 {
                                     "name": "status",
                                     "type": "select",
                                     "label": "Status",
                                     "tooltip": "Status",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": "Single,In a Relationship,Engaged,Married,Separated,Divorced,Widowed"
                                 },
                                 {
                                     "name": "occupation",
                                     "type": "string",
                                     "label": "Occupation",
                                     "tooltip": "Occupation",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "hair",
                                     "type": "string",
                                     "label": "Hair",
                                     "tooltip": "Hair",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 },
                                 {
                                     "name": "eyecolor",
                                     "type": "string",
                                     "label": "Eye color",
                                     "tooltip": "Eye color",
                                     "required": false,
                                     "searchable": true,
                                     "admin_privilege": false,
                                     "show_listing": false,
                                     "values": ""
                                 }
                             ]
                         }
                         ';
         $cf_templates = json_decode($cf_templates, TRUE);
         $field = new Model_Field();
         foreach ($cf_templates[Core::post('type')] as $custom_field) {
             try {
                 $name = $custom_field['name'];
                 $options = array('label' => $custom_field['label'], 'tooltip' => $custom_field['tooltip'], 'required' => $custom_field['required'], 'searchable' => $custom_field['searchable'], 'admin_privilege' => $custom_field['admin_privilege'], 'show_listing' => $custom_field['show_listing']);
                 if ($field->create($name, $custom_field['type'], $custom_field['values'], Core::post('categories'), $options)) {
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
                 } else {
                     Alert::set(Alert::WARNING, sprintf(__('Field %s already exists'), $name));
                 }
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     } else {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     }
 }
Exemplo n.º 3
0
 public function action_template()
 {
     if ($_POST) {
         $cf_templates = ['cars' => [['name' => 'forsaleby', 'type' => 'select', 'label' => __('For sale by'), 'tooltip' => __('For sale by'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Owner'), __('Dealer')])], ['name' => 'adtype', 'type' => 'select', 'label' => __('Ad type'), 'tooltip' => __('Ad type'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => implode(',', [__('I’m selling my car'), __('I’m looking for a car to buy')])], ['name' => 'make', 'type' => 'select', 'label' => __('Make'), 'tooltip' => __('Make'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', ['Acura', 'Alfa Romeo', 'AM General', 'AMC', 'Aston Martin', 'Audi', 'Austin-Healey', 'Bently', 'BMW', 'Bricklin', 'Bugatti', 'Buick', 'Cadillac', 'Chevrolet', 'Chrysler', 'Daewoo', 'Datsun', 'Diahatsu', 'Dodge', 'Eagle', 'Ferrari', 'Fiat', 'Ford', 'Geo', 'GMC', 'Honda', 'HUMMER', 'Hyundai', 'Infiniti', 'International Harvester', 'Isuzu', 'Jaguar', 'Jeep', 'Kia', 'Lamborghini', 'Land Rover', 'Lexus', 'Lincoln', 'Lotus', 'Maserati', 'Maybach', 'Mazda', 'Mercedes-Benz', 'Mercury', 'MG', 'MINI', 'Mitsubishi', 'Nissan', 'Oldsmobile', 'Opel', 'Peugeot', 'Plymouth', 'Pontiac', 'Porsche', 'Ram', 'Renault', 'Rolls-Royce', 'Saab', 'Saturn', 'Scion', 'Shelby', 'Smart', 'Subaru', 'Suzuki', 'Toyota', 'Triumph', 'Volkswagen', 'Volvo', __('Other')])], ['name' => 'othermake', 'type' => 'string', 'label' => __('Other make'), 'tooltip' => __('Other make'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE], ['name' => 'model', 'type' => 'string', 'label' => __('Model'), 'tooltip' => __('Model'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE], ['name' => 'year', 'type' => 'integer', 'label' => __('Year'), 'tooltip' => __('Year'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE], ['name' => 'kilometers', 'type' => 'integer', 'label' => __('Kilometers'), 'tooltip' => __('Kilometers'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE], ['name' => 'bodytype', 'type' => 'select', 'label' => __('Body type'), 'tooltip' => __('Body type'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Convertible'), __('Coupe (2 door)'), __('Hatchback'), __('Minivan or Van'), __('Pickup Truck'), __('Sedan'), __('SUV. crossover'), __('Wagon'), __('Other')])], ['name' => 'transmission', 'type' => 'select', 'label' => __('Transmission'), 'tooltip' => __('Transmission'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Automatic'), __('Manual'), __('Other')])], ['name' => 'drivetrain', 'type' => 'select', 'label' => 'Drivetrain', 'tooltip' => 'Drivetrain', 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('4 x 4'), __('All-wheel drive (AWD)'), __('Front-wheel drive (FWD)'), __('Rear-wheel drive (RWD)'), __('Other')])], ['name' => 'color', 'type' => 'select', 'label' => __('Color'), 'tooltip' => __('Color'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Black'), __('Blue'), __('Brown'), __('Burgundy'), __('Gold'), __('Green'), __('Grey'), __('Orange'), __('Pink'), __('Purple'), __('Red'), __('Silver'), __('Tan'), __('Teal'), __('White'), __('Yellow'), __('Other')])], ['name' => 'fueltype', 'type' => 'select', 'label' => __('Fuel Type'), 'tooltip' => __('Fuel Type'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Diesel'), __('Gasoline'), __('Hybrid-Electric'), __('Other')])], ['name' => 'type', 'type' => 'select', 'label' => __('Type'), 'tooltip' => __('Type'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Damaged'), __('Lease Takeover'), __('New'), __('Used')])]], 'houses' => [['name' => 'furnished', 'type' => 'select', 'label' => __('Furnished'), 'tooltip' => __('Furnished'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Yes'), __('No')])], ['name' => 'bedrooms', 'type' => 'select', 'label' => __('Bedrooms'), 'tooltip' => __('Bedrooms'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', ['Studio', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10'])], ['name' => 'bathrooms', 'type' => 'select', 'label' => __('Bathrooms'), 'tooltip' => __('Bathrooms'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'])], ['name' => 'pets', 'type' => 'select', 'label' => __('Pets'), 'tooltip' => __('Pets'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', ['yes', 'No'])], ['name' => 'agencybrokerfee', 'type' => 'select', 'label' => __('Agency/broker fee'), 'tooltip' => __('Agency/broker fee'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Yes'), __('No')])], ['name' => 'squaremeters', 'type' => 'string', 'label' => __('Square meters'), 'tooltip' => __('Square meters'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE], ['name' => 'pricenegotiable', 'type' => 'checkbox', 'label' => __('Price negotiable'), 'tooltip' => __('Price negotiable'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE]], 'jobs' => [['name' => 'jobtype', 'type' => 'select', 'label' => __('Job type'), 'tooltip' => __('Job type'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', ['Full-time', 'Part-time'])], ['name' => 'experienceinyears', 'type' => 'select', 'label' => __('Experience in Years'), 'tooltip' => __('Experience in Years'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Less than 1'), '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '20', __('More than 20')])], ['name' => 'salary', 'type' => 'integer', 'label' => __('Salary'), 'tooltip' => __('Salary'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE], ['name' => 'salarytype', 'type' => 'select', 'label' => 'Salary type', 'tooltip' => 'Salary type', 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => implode(',', [__('Hourly'), __('Daily'), __('Weekly'), __('Monthly'), __('Quarterly'), __('Yearly')])], ['name' => 'extrainformation', 'type' => 'textarea', 'label' => __('Extra information'), 'tooltip' => __('Extra information'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE], ['name' => 'company', 'type' => 'string', 'label' => __('Company'), 'tooltip' => __('Company name'), 'required' => TRUE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE], ['name' => 'companydescription', 'type' => 'textarea', 'label' => __('Company description'), 'tooltip' => __('Company description'), 'required' => FALSE, 'searchable' => FALSE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE]], 'dating' => [['name' => 'age', 'type' => 'integer', 'label' => __('Age'), 'tooltip' => __('Age'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => FALSE], ['name' => 'body', 'type' => 'select', 'label' => __('Body'), 'tooltip' => __('Body'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', ['-', __('Athletic'), __('Average'), __('big'), __('Curvy'), __('Fit'), __('Heavy'), __('HWP'), __('Skinny'), __('Thin')])], ['name' => 'height', 'type' => 'select', 'label' => __('Height'), 'tooltip' => __('Height'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => TRUE, 'values' => implode(',', [__('Taller than 6.8 (203 cm)'), '6.7 (200 cm)', '6.6 (198 cm)', '6.5 (195 cm)', '6.4 (194cm)', '6.3 (190 cm)', '6.2 (187 cm)', '6.1 (185 cm)', '6.0 (182 cm)', '5.11 (180 cm)', '5.10 (177 cm)', '5.9 (175 cm)', '5.8 (172 cm)', '5.7 (170 cm)', '5.6 (167 cm)', '5.5 (165 cm)', '5.4 (162 cm)', '5.3 (160 cm)', '5.2 (157 cm)', '5.1 (154 cm)', '5.0 (152 cm)', '4.11 (150 cm)', '4.10 (147 cm)', '4.9 (145 cm)', '4.8 (142 cm) or less'])], ['name' => 'status', 'type' => 'select', 'label' => __('Status'), 'tooltip' => __('Status'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => implode(',', [__('Single'), __('In a Relationship'), __('Engaged'), __('Married'), __('Separated'), __('Divorced'), __('Widowed')])], ['name' => 'occupation', 'type' => 'string', 'label' => __('Occupation'), 'tooltip' => __('Occupation'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE], ['name' => 'hair', 'type' => 'string', 'label' => __('Hair'), 'tooltip' => __('Hair'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE], ['name' => 'eyecolor', 'type' => 'string', 'label' => __('Eye color'), 'tooltip' => __('Eye color'), 'required' => FALSE, 'searchable' => TRUE, 'admin_privilege' => FALSE, 'show_listing' => FALSE, 'values' => FALSE]]];
         $field = new Model_Field();
         foreach ($cf_templates[Core::post('type')] as $custom_field) {
             try {
                 $name = $custom_field['name'];
                 $options = array('label' => $custom_field['label'], 'tooltip' => $custom_field['tooltip'], 'required' => $custom_field['required'], 'searchable' => $custom_field['searchable'], 'admin_privilege' => $custom_field['admin_privilege'], 'show_listing' => $custom_field['show_listing']);
                 if ($field->create($name, $custom_field['type'], $custom_field['values'], Core::post('categories'), $options)) {
                     Core::delete_cache();
                     Alert::set(Alert::SUCCESS, sprintf(__('Field %s created'), $name));
                 } else {
                     Alert::set(Alert::WARNING, sprintf(__('Field %s already exists'), $name));
                 }
             } catch (Exception $e) {
                 throw HTTP_Exception::factory(500, $e->getMessage());
             }
         }
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     } else {
         HTTP::redirect(Route::url('oc-panel', array('controller' => 'fields', 'action' => 'index')));
     }
 }