Example #1
0
 private function _get_frm_valid()
 {
     $form = array('txt_name' => '', 'txt_phone' => '', 'txt_fax' => '', 'txt_email' => '', 'txt_address' => '', 'txt_city' => '', 'txt_zipcode' => '', 'txt_contact' => '', 'txt_state' => '', 'txt_slogan' => '', 'txt_title' => '', 'txt_keyword' => '', 'txt_description' => '', 'txt_per_test' => '', 'txt_width' => '', 'txt_height' => '', 'rdo_enable_cart' => '', 'attach_logo' => '');
     $errors = $form;
     if ($_POST) {
         $post = new Validation(array_merge($_POST, $_FILES));
         if (!empty($_FILES['attach_logo']['name'])) {
             $post->add_rules('attach_logo', 'upload::type[gif,jpg,png,jpeg]', 'upload::size[2M]');
         }
         $post->pre_filter('trim', TRUE);
         $post->add_rules('txt_name', 'required');
         $post->add_rules('txt_phone', 'required');
         //$post->add_rules('txt_fax','phone[7,10,11,14]');
         $post->add_rules('txt_email', 'required', 'email');
         $post->pre_filter('trim', TRUE);
         $post->add_rules('txt_width', 'digit');
         $post->add_rules('txt_height', 'digit');
         $post->add_rules('txt_per_test', 'digit');
         if ($post->validate()) {
             $form = arr::overwrite($form, $post->as_array());
             return $form;
         } else {
             $errors = arr::overwrite($errors, $post->errors('site_validation'));
             $str_error = '';
             foreach ($errors as $id => $name) {
                 if ($name) {
                     $str_error .= $name . '<br>';
                 }
             }
             $this->session->set_flash('error_msg', $str_error);
         }
     }
     url::redirect('admin_config');
     die;
 }
Example #2
0
 public function render($options = null)
 {
     if (!$options) {
         $config = Kohana::config_load('zest');
         $options = $config['comment'];
     }
     $array = array("date_format" => 'D jS M Y', "image" => array(50, 50), "html" => '{AVATAR}{DATE} by {AUTHOR}<br/><p>{TEXT}</p><a href="{DELETE_LINK}" title="delete comment"></a><div class="spacer">&nbsp;</div>', "default_image" => 'http://' . $_SERVER['HTTP_HOST'] . '/zest/images/user_icon.gif', "template" => '');
     $array = arr::overwrite($array, $options);
     if (isset($array['template']) && $array['template'] != "") {
         $html = zest::template_to_html('snippets/' . $array['template']);
     } else {
         $html = $array['html'];
     }
     $html = str_replace('{DATE}', date($array['date_format'], strtotime($this->date)), $html);
     $html = str_replace('{AVATAR}', gravatar::render($this->email, $array['image'][0], $array['default_image']), $html);
     if ($this->fl_deleted == 1) {
         $html = str_replace('{TEXT}', '<i>This comment has been deleted.</i>', $html);
     } else {
         $html = str_replace('{TEXT}', $this->title, $html);
     }
     $html = str_replace('{AUTHOR}', $this->display_name, $html);
     if ($this->can_modify()) {
         $html = str_replace('{DELETE_LINK}', $this->delete_url(), $html);
     }
     return $html;
 }
Example #3
0
 public function login()
 {
     $form = $errors = array("user" => "", "password" => "");
     $post = new Validation($_POST);
     $post->add_rules("user", "required");
     $post->add_rules("password", "required");
     if ($valid = $post->validate()) {
         try {
             $token = G3Remote::instance()->get_access_token($post["user"], $post["password"]);
             Session::instance()->set("g3_client_access_token", $token);
             $response = G3Remote::instance()->get_resource("gallery");
             $valid = true;
             $content = $this->_get_main_view($response->resource);
         } catch (Exception $e) {
             Kohana_Log::add("error", Kohana_Exception::text($e));
             $valid = false;
         }
     }
     if (!$valid) {
         $content = new View('login.html');
         $content->form = arr::overwrite($form, $post->as_array());
         $content->errors = arr::overwrite($errors, $post->errors());
     }
     $this->auto_render = false;
     print json_encode(array("status" => $valid ? "ok" : "error", "content" => (string) $content));
 }
Example #4
0
 /**
  * Returns the formatted html
  *
  * html example
  * e.g <h1>{TITLE}</h1><h2>{DATE}</h2><h3>by {AUTHOR}</h3>{IMAGE}{TEXT}<div class="spacer">&nbsp;</div>
  *
  * @param   array	$options	Options for the rendering array('count', 'date_format','image' = array($width,$height), 'word_count', 'html')
  * @return	string	$html		Formatted HTML
  */
 public function render_summary($options = null, $feedpost_options = null)
 {
     $array = array('per_page' => 5, 'pagination' => 'classic', 'template' => 'feed', 'html' => '{FEEDPOSTS}{PAGINATION}');
     if (!$options) {
         $config = Kohana::config_load('zest');
         $options = $config['feed.summary'];
     }
     $array = arr::overwrite($array, $options);
     $uri = uri::instance();
     $page = $uri->segment('page', 1);
     $feedposts = "";
     $posts = $this->get_posts($array['per_page'], ($page - 1) * $array['per_page']);
     foreach ($posts as $post) {
         $feedposts .= $post->render_summary($feedpost_options);
     }
     $pagination = new Pagination(array('uri_segment' => 'page', 'total_items' => count($this->get_posts()), 'items_per_page' => $array['per_page'], 'style' => $array['pagination']));
     if ($array['template'] != '') {
         $html = zest::template_to_html('snippets/' . $array['template']);
     } else {
         $html = $array['html'];
     }
     $html = str_replace("{RSS_LINK}", $this->get_rss(), $html);
     $html = str_replace("{FEEDPOSTS}", $feedposts, $html);
     $html = str_replace("{PAGINATION}", $pagination, $html);
     $html = str_replace("{FEED_LINK}", $this->get_url(), $html);
     return $html;
 }
Example #5
0
 function index()
 {
     $this->template->content = new View('admin/blocks');
     $this->template->content->title = Kohana::lang('ui_admin.blocks');
     // Get Registered Blocks
     if (!is_array($this->_registered_blocks)) {
         $this->_registered_blocks = array();
     }
     // Get Active Blocks
     $settings = ORM::factory('settings', 1);
     $active_blocks = $settings->blocks;
     $active_blocks = array_filter(explode("|", $active_blocks));
     // setup and initialize form field names
     $form = array('action' => '', 'block' => '');
     //	copy the form as errors, so the errors will be stored with keys corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     $form_action = "";
     if ($_POST) {
         $post = Validation::factory($_POST);
         //	 Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('action', 'required', 'alpha', 'length[1,1]');
         $post->add_rules('block', 'required', 'alpha_dash');
         if (!array_key_exists($post->block, $this->_registered_blocks)) {
             $post->add_error('block', 'exists');
         }
         if ($post->validate()) {
             // Activate a block
             if ($post->action == 'a') {
                 array_push($active_blocks, $post->block);
                 $settings->blocks = implode("|", $active_blocks);
                 $settings->save();
             } elseif ($post->action == 'd') {
                 $active_blocks = array_diff($active_blocks, array($post->block));
                 $settings->blocks = implode("|", $active_blocks);
                 $settings->save();
             }
         } else {
             $errors = arr::overwrite($errors, $post->errors('blocks'));
             $form_error = TRUE;
         }
     }
     // Sort the Blocks
     $sorted_blocks = blocks::sort($active_blocks, array_keys($this->_registered_blocks));
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->form_action = $form_action;
     $this->template->content->total_items = count($this->_registered_blocks);
     $this->template->content->registered_blocks = $this->_registered_blocks;
     $this->template->content->active_blocks = $active_blocks;
     $this->template->content->sorted_blocks = $sorted_blocks;
     // Javascript Header
     $this->template->tablerowsort_enabled = TRUE;
     $this->template->js = new View('admin/blocks_js');
 }
Example #6
0
 private function _get_frm_valid()
 {
     $rdo_type = 'image';
     $file_ext = 'jpg,jpeg,gif,png';
     $form = array('hd_id' => '', 'attach_image' => '', 'txt_width' => '', 'txt_height' => '', 'sel_status' => '');
     $errors = $form;
     if ($_POST) {
         $post = new Validation(array_merge($_FILES, $_POST));
         $post->add_rules('attach_' . $rdo_type, 'upload::type[' . $file_ext . ']', 'upload::size[10M]');
         $post->add_rules('txt_width', 'digit');
         $post->add_rules('txt_height', 'digit');
         if ($post->validate()) {
             $form = arr::overwrite($form, $post->as_array());
             return $form;
         } else {
             $errors = $post->errors('banner_validation');
             $str_error = '';
             foreach ($errors as $id => $name) {
                 if ($name) {
                     $str_error .= $name . '<br>';
                 }
             }
             $this->session->set_flash('error_msg', $str_error);
             url::redirect($this->site['history']['current']);
             die;
         }
     }
 }
Example #7
0
 private function _get_frm_valid()
 {
     $hd_id = $this->input->post('hd_id');
     $form = $this->data_template_model->get_frm();
     $errors = $form;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim', TRUE);
         $post->add_rules('txt_name', 'required', 'length[1,200]');
         $post->add_rules('txt_content', 'required');
         if ($post->validate()) {
             $form = arr::overwrite($form, $post->as_array());
             return $form;
         } else {
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors('account_validation'));
             $str_error = '';
             foreach ($errors as $id => $name) {
                 if ($name) {
                     $str_error .= $name . '<br>';
                 }
             }
             $this->session->set_flash('error_msg', $str_error);
             if ($hd_id) {
                 url::redirect('admin_emailtemplate/edit/' . $hd_id);
             }
             die;
         }
     }
 }
Example #8
0
 private function _get_record()
 {
     $form = array('txt_name' => '', 'txt_email' => '', 'txt_phone' => '', 'txt_subject' => '', 'txt_content' => '', 'txt_code' => '', 'txt_last_name' => '', 'txt_first_name' => '', 'txt_company' => '');
     $errors = $form;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim', TRUE);
         $post->add_rules('txt_name', 'required');
         $post->add_rules('txt_email', 'required', 'email');
         $post->add_rules('txt_subject', 'required');
         $post->add_rules('txt_content', 'required');
         //$post->add_rules('txt_code','required');
         //$post->add_callbacks('txt_random',array($this,'_check_security_code'));
         //$post->add_rules('sel_send','trim');
         if ($post->validate()) {
             $form = arr::overwrite($form, $post->as_array());
             return $form;
         } else {
             $form = arr::overwrite($form, $post->as_array());
             // Retrieve input data
             $this->session->set_flash('input_data', $form);
             // Set input data in session
             $errors = arr::overwrite($errors, $post->errors('contact_validation'));
             $error_msg = '';
             foreach ($errors as $id => $name) {
                 if ($name) {
                     $error_msg .= '<br>' . $name;
                 }
             }
             $this->session->set_flash('error_msg', $error_msg);
             url::redirect('contact');
             die;
         }
     }
 }
Example #9
0
 public function index()
 {
     // Create new session
     $this->session->create();
     $this->template->header->this_page = 'alerts';
     $this->template->content = new View('alerts');
     // Display news feeds?
     $this->template->content->allow_feed = Kohana::config('settings.allow_feed');
     // Retrieve default country, latitude, longitude
     $default_country = Kohana::config('settings.default_country');
     // Retrieve Country Cities
     $this->template->content->cities = $this->_get_cities($default_country);
     // Setup and initialize form field names
     $form = array('alert_mobile' => '', 'alert_mobile_yes' => '', 'alert_email' => '', 'alert_email_yes' => '', 'alert_lat' => '', 'alert_lon' => '', 'alert_radius' => '');
     // Copy the form as errors, so the errors will be stored with keys
     // corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // If there is a post and $_POST is not empty
     if ($post = $this->input->post()) {
         // Create a new alert
         $alert = ORM::factory('alert');
         // Test to see if things passed the rule checks
         if ($alert->validate($post)) {
             // Yes! everything is valid
             // Save alert and send out confirmation code
             if (!empty($post->alert_mobile)) {
                 $this->_send_mobile_alert($post->alert_mobile, $post->alert_lon, $post->alert_lat, $post->alert_radius);
             }
             if (!empty($post->alert_email)) {
                 $this->_send_email_alert($post->alert_email, $post->alert_lon, $post->alert_lat, $post->alert_radius);
             }
             $this->session->set('alert_mobile', $post->alert_mobile);
             $this->session->set('alert_email', $post->alert_email);
             url::redirect('alerts/confirm');
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('alerts'));
             $form_error = TRUE;
         }
     } else {
         $form['alert_lat'] = Kohana::config('settings.default_lat');
         $form['alert_lon'] = Kohana::config('settings.default_lon');
         $form['alert_radius'] = 20;
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     // Javascript Header
     $this->template->header->map_enabled = TRUE;
     $this->template->header->js = new View('alerts_js');
     $this->template->header->js->default_map = Kohana::config('settings.default_map');
     $this->template->header->js->default_zoom = Kohana::config('settings.default_zoom');
     $this->template->header->js->latitude = $form['alert_lat'];
     $this->template->header->js->longitude = $form['alert_lon'];
 }
Example #10
0
File: user.php Project: swk/bluebox
 public function register()
 {
     $subview = new View('user/register');
     $subview->tab = 'main';
     $subview->section = 'register';
     // What are we working with here?
     $base = $this->newUser;
     // Must have an initialized user model object to get started
     if (!$base) {
         return FALSE;
     }
     // Nothing to do here.
     // Populate form data with whatever our database record has
     $subview->register = $base->toArray();
     // Pass errors from the controller to our view
     $validation = Bluebox_Controller::$validation;
     foreach ($validation->errors() as $field => $error) {
         // the form helper will expect the errors based on the field name
         // of register
         $field = preg_replace('/^user/', 'register', $field, 1, $count);
         if (!empty($count)) {
             $validation->add_error($field, $error);
         }
     }
     // If we are coming from a previous form field/post, we want to repopulate the previous field entries again on this page so
     // that errors/etc. can be corrected, rather then lost.
     if (isset($this->repopulateForm) and isset($this->repopulateForm['register'])) {
         $subview->register = arr::overwrite($subview->register, $this->repopulateForm['register']);
         $subview->confirm_password = $this->input->post('confirm_password');
     } else {
         $subview->confirm_password = '';
     }
     // Add our view to the main application
     $this->views[] = $subview;
 }
Example #11
0
 private function _get_record_aut_config()
 {
     $form = array('txt_aut_api_login' => '', 'txt_aut_transaction_key' => '', 'sel_aut_post_url' => '');
     $errors = $form;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim', TRUE);
         $post->add_rules('txt_aut_api_login', 'trim', 'required');
         $post->add_rules('txt_aut_transaction_key', 'trim', 'required');
         $post->add_rules('sel_aut_post_url', 'trim', 'required');
         $form = arr::overwrite($form, $post->as_array());
         $form = $this->_set_form_aut_config($form);
         if ($post->validate()) {
             return $form;
         } else {
             $this->session->set_flash('frm_aut', $form);
             $errors = arr::overwrite($errors, $post->errors('authorizenet_config_validation'));
             $str_error = '';
             foreach ($errors as $id => $name) {
                 if ($name) {
                     $str_error .= '<br>' . $name;
                 }
             }
             $this->session->set_flash('error_msg', $str_error);
             url::redirect('admin_payment_method');
             die;
         }
     }
 }
Example #12
0
 public function index()
 {
     $this->template->content = new View('admin/flickrwijit_form');
     // setup and initialize form field names
     $form = array('flickr_tag' => '', 'flickr_id' => '', 'num_of_photos' => '', 'image_width' => '', 'image_height' => '', 'block_position' => '', 'enable_cache' => '', 'block_no_photos' => '');
     //  Copy the form as errors, so the errors will be stored with keys
     //  corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('flickr_tag', 'required', 'length[0,500]');
         $post->add_rules('flickr_id', 'length[0,20]');
         $post->add_rules('num_of_photos', 'numeric');
         $post->add_rules('image_width', 'length[2,600]', 'numeric');
         $post->add_rules('image_height', 'required', 'length[2,600]', 'numeric');
         $post->add_rules('block_position', 'length[1,6]', 'numeric');
         $post->add_rules('enable_cache', 'between[0,1]', 'numeric');
         $post->add_rules('block_no_photos', 'between[4,10]', 'numeric');
         // passed validation test.
         if ($post->validate()) {
             $flickrwijit_settings = new Flickrwijit_Model(1);
             $flickrwijit_settings->flickr_tag = $post->flickr_tag;
             $flickrwijit_settings->flickr_id = $post->flickr_id;
             $flickrwijit_settings->num_of_photos = $post->num_of_photos;
             $flickrwijit_settings->image_height = $post->image_height;
             $flickrwijit_settings->image_width = $post->image_width;
             $flickrwijit_settings->block_position = $post->block_position;
             $flickrwijit_settings->enable_cache = $post->enable_cache;
             $flickrwijit_settings->block_no_photos = $post->block_no_photos;
             $flickrwijit_settings->save();
             // Delete Settings Cache
             // $this->cache->delete('settings');
             // $this->cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('flickrwijit'));
             $form_error = TRUE;
         }
     } else {
         $flickrwijit_settings = ORM::factory('flickrwijit', 1);
         $form = array('flickr_tag' => $flickrwijit_settings->flickr_tag, 'flickr_id' => $flickrwijit_settings->flickr_id, 'num_of_photos' => $flickrwijit_settings->num_of_photos, 'image_width' => $flickrwijit_settings->image_width, 'image_height' => $flickrwijit_settings->image_height, 'block_position' => $flickrwijit_settings->block_position, 'enable_cache' => $flickrwijit_settings->enable_cache, 'block_no_photos' => $flickrwijit_settings->block_no_photos);
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
 }
Example #13
0
 public function __construct($options = array())
 {
     $default = array("width" => 900, "height" => 150, "view" => "includes/banner", "images" => array());
     $config = Kohana::config_load('zest');
     $config = arr::overwrite($default, $config['banner']);
     $this->config = arr::overwrite($config, $options);
 }
Example #14
0
 /**
  * Show latest PER_PAGE news on page
  * @return void
  */
 public function index($module = NULL, $page = 1)
 {
     $this->set_title(Kohana::lang('search.search'));
     if ($page == 1) {
         $this->add_breadcrumb(Kohana::lang('search.the_best_results'), url::current());
     } else {
         $this->add_breadcrumb(Kohana::lang('search.page_no') . ' ' . $page, url::current());
     }
     // Default values
     $form = array('value' => '');
     $errors = array();
     if ($_POST) {
         $post = new Validation($_POST);
         // Some filters
         $post->pre_filter('trim', TRUE);
         // Rules
         $post->add_rules('value', 'required');
         if ($post->validate()) {
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // Repopulate form with error and original values
             $form = arr::overwrite($form, $post->as_array());
             $errors = $post->errors('search_errors');
         }
     }
     $this->template->content = new View('search');
     $data = $this->products->search($post['value']);
     $data2 = $this->page->search($post['value']);
     $data3 = $this->news->search($post['value']);
     $this->template->content->data = $data;
     $this->template->content->data2 = $data2;
     $this->template->content->data3 = $data3;
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
 }
Example #15
0
 public function __construct($options = array())
 {
     $default = array("width" => "100", "height" => "100", "images" => array(), "class" => "square_thumb", "view" => null, "thickbox" => true);
     $config = Kohana::config_load('zest');
     $config = arr::overwrite($default, $config['gallery']);
     $this->config = arr::overwrite($config, $options);
 }
 public function handler()
 {
     access::verify_csrf();
     $form = $this->_get_form();
     $errors = array_fill_keys(array_keys($form), "");
     if ($_POST) {
         $post = new Validation($_POST);
         $post->add_rules("updates_enabled", array("valid", "numeric"));
         $post->add_rules("popular_enabled", array("valid", "numeric"));
         $post->add_rules("updates_limit", array("valid", "numeric"));
         $post->add_rules("popular_limit", array("valid", "numeric"));
         $post->add_rules("updates_description", "length[0,2048]");
         $post->add_rules("popular_description", "length[0,2048]");
         if ($post->validate()) {
             foreach (array("updates", "popular") as $album) {
                 $album_defn = unserialize(module::get_var("dynamic", $album));
                 $album_defn->enabled = $post["{$album}_enabled"];
                 $album_defn->description = $post["{$album}_description"];
                 $album_defn->limit = $post["{$album}_limit"] === "" ? null : $post["{$album}_limit"];
                 module::set_var("dynamic", $album, serialize($album_defn));
             }
             message::success(t("Dynamic Albums Configured"));
             url::redirect("admin/dynamic");
         } else {
             $form = arr::overwrite($form, $post->as_array());
             $errors = arr::overwrite($errors, $post->errors());
         }
     }
     print $this->_get_view($form, $errors);
 }
Example #17
0
 public function add()
 {
     $form = array('building_id' => '', 'name' => '', 'index' => '', 'img_uri' => '', 'active' => '');
     $errors = $form;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim', true);
         $post->add_rules('buildings_id', 'required', 'digit');
         $post->add_rules('name', 'required');
         $post->add_rules('index', 'required');
         $post->add_rules('img_uri', 'required');
         $post->add_rules('active', 'required');
         if ($post->validate()) {
             // check for invilid
             $form = arr::overwrite($form, $post->as_array());
             $people = new Person_Model();
             $result = $people->save($this->input->get('person'), $person_id);
         } else {
             $form = arr::overwrite($form, $post->as_array());
             client::validation_results(arr::overwrite($errors, $post->errors('hiring_employee_form_validations')));
             client::messageSend("There were errors in some fields", E_USER_WARNING);
         }
     }
     $building = new Building_Model();
     $buildings_list = $building->select_list();
     $this->template->title = 'Seating::Spaces::Add';
     $this->template->content = new View('pages/spaces_add');
     $this->template->content->form = $form;
     $this->template->content->buildings_list = $buildings_list;
 }
Example #18
0
 public function step_database()
 {
     $this->content = View::factory('step_database')->bind('form', $form);
     $this->title = 'Database Configuration';
     $form = array('username' => '', 'password' => '', 'hostname' => '', 'database' => '');
     if ($_POST) {
         $data = array('username' => $username = $this->input->post('username'), 'password' => $password = $this->input->post('password'), 'hostname' => $hostname = $this->input->post('hostname'), 'database' => $database = $this->input->post('database'), 'table_prefix' => '');
         try {
             installer::check_database($username, $password, $hostname, $database);
             Session::instance()->set('database_data', $data);
             url::redirect('install/step_create_data');
         } catch (Exception $e) {
             $form = arr::overwrite($form, $this->input->post());
             $error = $e->getMessage();
             // TODO create better error messages
             switch ($error) {
                 case 'access':
                     $this->error = 'wrong username or password';
                     break;
                 case 'unknown_host':
                     $this->error = 'could not find the host';
                     break;
                 case 'connect_to_host':
                     $this->error = 'could not connect to host';
                     break;
                 case 'select':
                     $this->error = 'could not select the database';
                     break;
                 default:
                     $this->error = $error;
             }
         }
     }
 }
Example #19
0
 private function _get_valid_accinfo($old_pass)
 {
     $form = array('txt_old_pass' => '', 'txt_new_pass' => '', 'txt_cf_new_pass' => '', 'txt_email' => '');
     $errors = $form;
     if ($_POST) {
         $post = new Validation($_POST);
         $post->pre_filter('trim', TRUE);
         if (!empty($old_pass)) {
             $post->add_rules('txt_new_pass', 'required', 'length[6,50]');
             $post->add_rules('txt_cf_new_pass', 'matches[txt_new_pass]');
             $post->add_callbacks('txt_old_pass', array($this, '_check_old_pass'));
         }
         $post->add_rules('txt_email', 'required', 'email');
         $post->add_callbacks('txt_email', array($this, '_check_email'));
         if ($post->validate()) {
             $form = arr::overwrite($form, $post->as_array());
             return $form;
         } else {
             $form = arr::overwrite($form, $post->as_array());
             $this->session->set_flash('input_data', $form);
             $errors = arr::overwrite($errors, $post->errors('account_validation'));
             $str_error = '';
             foreach ($errors as $id => $name) {
                 if ($name) {
                     $str_error .= $name . '<br>';
                 }
             }
             $this->session->set_flash('error_msg', $str_error);
             url::redirect($this->uri->segment(1));
             die;
         }
     }
 }
Example #20
0
File: shout.php Project: anqqa/Anqh
 /**
  * Show shouts or shout
  */
 public function index()
 {
     $shout = new Shout_Model();
     $form_values = $shout->as_array();
     $form_errors = array();
     // Check post
     if (csrf::valid() && ($post = $this->input->post())) {
         $shout->author_id = $this->user->id;
         $shout->shout = $post['shout'];
         try {
             $shout->save();
             if (!request::is_ajax()) {
                 url::redirect(url::current());
             }
         } catch (ORM_Validation_Exception $e) {
             $form_errors = $e->validation->errors();
             $form_values = arr::overwrite($form_values, $post);
         }
     }
     $shouts = ORM::factory('shout')->find_all(10);
     $view = View_Mod::factory('generic/shout', array('mod_title' => __('Shouts'), 'shouts' => $shouts, 'can_shout' => ORM::factory('shout')->has_access(Shout_Model::ACCESS_WRITE, $this->user), 'errors' => $form_errors, 'values' => $form_values));
     if (request::is_ajax()) {
         echo $view;
         return;
     }
     widget::add('main', $view);
 }
Example #21
0
 public function index()
 {
     $this->template->content = new View('admin/profile');
     // setup and initialize form field names
     $form = array('username' => '', 'password' => '', 'password_again' => '', 'name' => '', 'email' => '', 'notify' => '');
     //  Copy the form as errors, so the errors will be stored with keys
     //  corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         $post = Validation::factory($_POST);
         //  Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('name', 'required', 'length[3,100]');
         $post->add_rules('email', 'required', 'email', 'length[4,64]');
         $post->add_callbacks('email', array($this, 'email_exists_chk'));
         // If Password field is not blank
         if (!empty($post->password)) {
             $post->add_rules('password', 'required', 'length[5,16]', 'alpha_numeric', 'matches[password_again]');
         }
         if ($post->validate()) {
             $user = ORM::factory('user', $this->user_id);
             if ($user->loaded) {
                 $user->name = $post->name;
                 $user->email = $post->email;
                 $user->notify = $post->notify;
                 $post->password != '' ? $user->password = $post->password : '';
                 $user->save();
             }
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             $form['password'] = "";
             $form['password_again'] = "";
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('auth'));
             $form_error = TRUE;
         }
     } else {
         $user = ORM::factory('user', $this->user_id);
         $form['username'] = $user->username;
         $form['name'] = $user->name;
         $form['email'] = $user->email;
         $form['notify'] = $user->notify;
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->yesno_array = array('1' => 'YES', '0' => 'NO');
     // Javascript Header
 }
Example #22
0
 /**
  * Customer profile
  * @return void
  * @param state to show after return
  */
 public function profile($state = NULL)
 {
     // Messages about success
     $success = array();
     if ($state == "changed") {
         $success[] = Kohana::lang('eshop.succesfully_changed');
     }
     // Check user permission
     if (user::is_logged()) {
         // Settings
         $this->set_title(Kohana::lang('eshop.customer_profile'));
         $this->add_breadcrumb(Kohana::lang('eshop.profile'), url::current());
         // Default values
         if ($this->customer->profile_exists(user::user_email())) {
             $row = $this->customer->get_one(user::user_email());
             $form = array('customer_street' => $row['customer_street'], 'customer_city' => $row['customer_city'], 'customer_postal_code' => $row['customer_postal_code'], 'customer_phone' => $row['customer_phone'], 'billing_name' => $row['billing_name'], 'billing_street' => $row['billing_street'], 'billing_city' => $row['billing_city'], 'billing_postal_code' => $row['billing_postal_code'], 'billing_identity_number' => $row['billing_identity_number'], 'billing_vat_number' => $row['billing_vat_number']);
         } else {
             // empty data
             $form = array('customer_street' => '', 'customer_city' => '', 'customer_postal_code' => '', 'customer_phone' => '', 'billing_name' => '', 'billing_street' => '', 'billing_city' => '', 'billing_postal_code' => '', 'billing_identity_number' => '', 'billing_vat_number' => '');
         }
         $errors = array();
         if ($state == "needed") {
             $errors[] = Kohana::lang('eshop.informations_needed');
         }
         // Validation
         if ($_POST) {
             $post = new Validation($_POST);
             // Some filters
             $post->pre_filter('trim', TRUE);
             // Rules
             $post->add_rules('customer_street', 'required');
             $post->add_rules('customer_city', 'required');
             $post->add_rules('customer_postal_code', 'required', 'length[0,255]');
             $post->add_rules('billing_name', 'length[0,255]');
             $post->add_rules('billing_postal_code', 'length[0,255]');
             $post->add_rules('billing_identity_number', 'length[0,8]');
             $post->add_rules('billing_vat_number', 'length[0,12]');
             if ($post->validate()) {
                 // Everything seems to be ok, insert to db
                 $this->customer->change_data($post, user::user_email());
                 url::redirect('/customer/profile/changed');
             } else {
                 // Repopulate form with error and original values
                 $form = arr::overwrite($form, $post->as_array());
                 $errors = $post->errors('customer_errors');
                 $success = array();
             }
         }
         // View
         $this->template->content = new View('customer_profile');
         $this->template->content->form = $form;
         $this->template->content->errors = $errors;
         $this->template->content->success = $success;
     } else {
         url::redirect('/denied');
     }
 }
Example #23
0
 function index()
 {
     $this->template->content = new View('admin/settings/externalapps/main');
     $this->template->content->title = Kohana::lang('ui_admin.settings');
     // setup and initialize form field names
     $form = array('id' => '', 'name' => '', 'url' => '');
     //	Copy the form as errors, so the errors will be stored with keys
     //	corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('name', 'length[1,255]');
         $post->add_rules('url', 'length[1,255]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // TODO: Save External App Here
             if ($post->action == 'a') {
                 $app = new Externalapp_Model();
                 $app->id = $post->id;
                 $app->name = $post->name;
                 $app->url = $post->url;
                 $app->save();
             } elseif ($post->action == 'd') {
                 $app = new Externalapp_Model($post->id);
                 $app->delete();
             }
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     }
     // Grab all of the external apps from the database
     $this->template->content->externalapps = ORM::factory('externalapp')->find_all();
     $this->template->content->total_items = count($this->template->content->externalapps);
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     // Javascript Header
     $this->template->js = new View('admin/settings/externalapps/externalapps_js');
 }
Example #24
0
 /**
  * Upgrade page.
  *
  */
 public function index()
 {
     $this->template->content = new View('admin/upgrade');
     $form_action = "";
     $this->template->content->title = Kohana::lang('ui_admin.upgrade_ushahidi');
     //$this->template->content->db_version =  Kohana::config('
     //	  settings.db_version');
     $this->template->content->db_version = Kohana::config('settings.db_version');
     //Setup and initialize form fields names
     $form = array('chk_db_backup_box' => '');
     //check if form has been submitted
     if ($_POST) {
         // For sanity sake, validate the data received from users.
         $post = Validation::factory(array_merge($_POST, $_FILES));
         // Add some filters
         $post->pre_filter('trim', TRUE);
         $post->add_rules('chk_db_backup_box', 'between[0,1]');
         if ($post->validate()) {
             $this->upgrade->logger("STARTED UPGRADE\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
             $this->template->content = new View('admin/upgrade_status');
             $this->template->js = new View('admin/upgrade_status_js');
             $this->template->js->backup = $post->chk_db_backup_box;
             $this->template->content->title = Kohana::lang('ui_admin.upgrade_ushahidi_status');
             $this->session->set('ftp_server', $post->ftp_server);
             $this->session->set('ftp_user_name', $post->ftp_user_name);
             $this->session->set('ftp_user_pass', $post->ftp_user_pass);
             $settings = ORM::factory("settings")->find(1);
             $settings->ftp_server = $post->ftp_server;
             $settings->ftp_user_name = $post->ftp_user_name;
             $settings->save();
             // Log file location
             $this->template->js->log_file = url::site() . "admin/upgrade/logfile?f=" . $this->session->get('upgrade_session') . ".txt";
         } else {
             $this->template->js = new View('admin/upgrade_js');
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('upgrade'));
             $form_error = TRUE;
         }
     } else {
         $this->template->js = new View('admin/upgrade_js');
     }
     $settings = ORM::factory("settings")->find(1);
     $this->template->content->ftp_server = $settings->ftp_server;
     $this->template->content->ftp_user_name = $settings->ftp_user_name;
     $this->template->content->form_action = $form_action;
     $this->template->content->current_version = Kohana::config('settings.ushahidi_version');
     $this->template->content->current_db_version = Kohana::config('settings.db_version');
     $this->template->content->environment = $this->_environment();
     $this->template->content->release_version = is_object($this->release) == true ? $this->release->version : "";
     $this->template->content->release_db_version = is_object($this->release) == true ? $this->release->version_db : "";
     $this->template->content->changelogs = is_object($this->release) == true ? $this->release->changelog : array();
     $this->template->content->download = is_object($this->release) == true ? $this->release->download : "";
     $this->template->content->critical = is_object($this->release) == true ? $this->release->critical : "";
 }
Example #25
0
 /**
  * Handles twitter Settings
  */
 function index()
 {
     $this->template->content = new View('admin/settings/twitter/main');
     $this->template->content->title = Kohana::lang('ui_admin.settings');
     // setup and initialize form field names
     $form = array('twitter_api_key' => '', 'twitter_api_key_secret' => '', 'twitter_token' => '', 'twitter_token_secret' => '', 'twitter_hashtags' => '');
     //	Copy the form as errors, so the errors will be stored with keys
     //	corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('twitter_api_key', 'required', 'length[1,150]');
         $post->add_rules('twitter_api_key_secret', 'required', 'length[1,150]');
         $post->add_rules('twitter_token', 'required', 'length[1,150]');
         $post->add_rules('twitter_token_secret', 'required', 'length[1,150]');
         $post->add_rules('twitter_hashtags', 'length[1,150]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             Settings_Model::save_setting('twitter_api_key', $post->twitter_api_key);
             Settings_Model::save_setting('twitter_api_key_secret', $post->twitter_api_key_secret);
             Settings_Model::save_setting('twitter_token', $post->twitter_token);
             Settings_Model::save_setting('twitter_token_secret', $post->twitter_token_secret);
             Settings_Model::save_setting('twitter_hashtags', $post->twitter_hashtags);
             // Delete Settings Cache
             $this->cache->delete('settings');
             $this->cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         $form = array('twitter_api_key' => Settings_Model::get_setting('twitter_api_key'), 'twitter_api_key_secret' => Settings_Model::get_setting('twitter_api_key_secret'), 'twitter_token' => Settings_Model::get_setting('twitter_token'), 'twitter_token_secret' => Settings_Model::get_setting('twitter_token_secret'), 'twitter_hashtags' => Settings_Model::get_setting('twitter_hashtags'));
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     // Javascript Header
     $this->themes->js = new View('admin/settings/twitter/twitter_js');
 }
Example #26
0
 public static function encode_url($array = array())
 {
     $default = array("where" => array(), "orderby" => array(), "limit" => array(), "class" => array());
     $arr = arr::overwrite($default, $array);
     $array = array();
     foreach ($arr as $key => $val) {
         $array[$key] = urlencode(arr::arraytostr($val));
     }
     return 'json/' . $array['class'] . '/' . $array['where'] . '/' . $array['orderby'] . '/' . $array['limit'] . '/';
 }
 public function index()
 {
     $this->template->this_page = 'addons';
     // Standard Settings View
     $this->template->content = new View("admin/plugins_settings");
     $this->template->content->title = "CrowdFlower Settings";
     // Settings Form View
     $this->template->content->settings_form = new View("crowdflower/admin/crowdflower_settings");
     // setup and initialize form field names
     $form = array('crowdflower_apikey' => '', 'crowdflower_jobid' => '');
     //	Copy the form as errors, so the errors will be stored with keys
     //  corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('crowdflower_apikey', 'length[0,100]');
         $post->add_rules('crowdflower_jobid', 'length[0,100]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             $settings = ORM::factory('crowdflower', 1);
             $settings->crowdflower_apikey = $post->crowdflower_apikey;
             $settings->crowdflower_jobid = $post->crowdflower_jobid;
             $settings->save();
             // Transform and roll out
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('crowdflower'));
             $form_error = TRUE;
         }
     } else {
         // Retrieve Current Settings
         $settings = ORM::factory('crowdflower', 1);
         $form = array('crowdflower_apikey' => $settings->crowdflower_apikey, 'crowdflower_jobid' => $settings->crowdflower_jobid);
     }
     // Pass the $form on to the settings_form variable in the view
     $this->template->content->settings_form->form = $form;
     // Other variables
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
 }
Example #28
0
 public function index()
 {
     $this->template->header->this_page = 'contact';
     $this->template->content = new View('contact');
     $this->template->header->page_title .= Kohana::lang('ui_main.contact') . Kohana::config('settings.title_delimiter');
     // Setup and initialize form field names
     $form = array('contact_name' => '', 'contact_email' => '', 'contact_phone' => '', 'contact_subject' => '', 'contact_message' => '', 'captcha' => '');
     // Copy the form as errors, so the errors will be stored with keys
     // corresponding to the form field names
     $captcha = Captcha::factory();
     $errors = $form;
     $form_error = FALSE;
     $form_sent = FALSE;
     // Check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST fields with our own things
         $post = Validation::factory($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('contact_name', 'required', 'length[3,100]');
         $post->add_rules('contact_email', 'required', 'email', 'length[4,100]');
         $post->add_rules('contact_subject', 'required', 'length[3,100]');
         $post->add_rules('contact_message', 'required');
         $post->add_rules('captcha', 'required', 'Captcha::valid');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid - Send email
             $site_email = Kohana::config('settings.site_email');
             $message = Kohana::lang('ui_admin.sender') . ": " . $post->contact_name . "\n";
             $message .= Kohana::lang('ui_admin.email') . ": " . $post->contact_email . "\n";
             $message .= Kohana::lang('ui_admin.phone') . ": " . $post->contact_phone . "\n\n";
             $message .= Kohana::lang('ui_admin.message') . ": \n" . $post->contact_message . "\n\n\n";
             $message .= "~~~~~~~~~~~~~~~~~~~~~~\n";
             $message .= Kohana::lang('ui_admin.sent_from_website') . url::base();
             // Send Admin Message
             email::send($site_email, $post->contact_email, $post->contact_subject, $message, FALSE);
             $form_sent = TRUE;
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('contact'));
             $form_error = TRUE;
         }
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_sent = $form_sent;
     $this->template->content->captcha = $captcha;
     // Rebuild Header Block
     $this->template->header->header_block = $this->themes->header_block();
     $this->template->footer->footer_block = $this->themes->footer_block();
 }
Example #29
0
 function index()
 {
     $this->template->content = new View('admin/themes');
     $this->template->content->title = 'Addons';
     // setup and initialize form field names
     $form = array('site_style' => '');
     //  Copy the form as errors, so the errors will be stored with keys
     //  corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('site_style', 'length[1,50]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             $settings = new Settings_Model(1);
             $settings->site_style = $post->site_style;
             $settings->save();
             //add details to application/config/email.php
             //$this->_add_email_settings($settings);
             // Delete Settings Cache
             $cache = Cache::instance();
             $cache->delete('settings');
             $cache->delete_tag('settings');
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         // Retrieve Current Settings
         $settings = ORM::factory('settings', 1);
         $form = array('site_style' => $settings->site_style);
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $this->template->content->themes = $this->_get_themes();
 }
Example #30
0
 function index()
 {
     $this->template->content = new View('admin/addons/themes');
     $this->template->content->title = 'Addons';
     // setup and initialize form field names
     $form = array('site_style' => '');
     //  Copy the form as errors, so the errors will be stored with keys
     //  corresponding to the form field names
     $errors = $form;
     $form_error = FALSE;
     $form_saved = FALSE;
     // check, has the form been submitted, if so, setup validation
     if ($_POST) {
         // Instantiate Validation, use $post, so we don't overwrite $_POST
         // fields with our own things
         $post = new Validation($_POST);
         // Add some filters
         $post->pre_filter('trim', TRUE);
         // Add some rules, the input field, followed by a list of checks, carried out in order
         $post->add_rules('site_style', 'length[1,50]');
         // Test to see if things passed the rule checks
         if ($post->validate()) {
             // Yes! everything is valid
             Settings_Model::save_setting('site_style', $post->site_style);
             // Everything is A-Okay!
             $form_saved = TRUE;
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
         } else {
             // repopulate the form fields
             $form = arr::overwrite($form, $post->as_array());
             // populate the error fields, if any
             $errors = arr::overwrite($errors, $post->errors('settings'));
             $form_error = TRUE;
         }
     } else {
         $site_style = Settings_Model::get_setting('site_style');
         // Retrieve Current Settings
         $form = array('site_style' => !empty($site_style) ? $site_style : 'default');
     }
     $this->template->content->form = $form;
     $this->template->content->errors = $errors;
     $this->template->content->form_error = $form_error;
     $this->template->content->form_saved = $form_saved;
     $themes = addon::get_addons('theme');
     foreach ($themes as $key => $theme) {
         // We want to hide checkin themes if checkins is not enabled
         if (!Kohana::config('settings.checkins') and $theme['Checkins'] == 1) {
             unset($themes[$key]);
         }
     }
     $this->template->content->themes = $themes;
 }