function unique_dynamic_route($route, $current_route = '') { $route = trim($route, '/'); $regex = "(\\/?([a-zA-Z0-9+\$_-]\\.?)+)*\\/?"; // Path $regex .= "(\\?[a-zA-Z+&\$_.-][a-zA-Z0-9;:@&%=+\\/\$_.-]*)?"; // GET Query $regex .= "(#[a-zA-Z_.-][a-zA-Z0-9+\$_.-]*)?"; // Anchor if (preg_match("/^{$regex}\$/", $route)) { $Content_types = new Content_types_model(); $Content_types->get_by_dynamic_route($route); if ($Content_types->exists() && $route != stripslashes($current_route)) { $this->form_validation->set_message('unique_dynamic_route', 'This %s provided is already in use.'); return FALSE; } else { return $route; } } else { $this->form_validation->set_message('unique_dynamic_route', 'The %s provided is not valid.'); return FALSE; } }
function change_content_type($old_content_type_id, $current_content_type_id) { $this->CI->load->model('content/content_types_model'); $this->Entry->content_type_id = $current_content_type_id; // Check if a content type exists with this id $Content_type = new Content_types_model(); $Content_type->get_by_id($old_content_type_id); if ($Content_type->exists()) { // Get and set the new fields array which will now // be used for validating and processing instead of the fields array $this->old_fields = new Content_fields_model(); $this->old_fields->order_by('sort', 'ASC')->include_related('content_field_types', array('model_name'))->get_by_content_type_id($old_content_type_id); // Get entry data $this->_get_entry_data(); foreach ($this->fields as $Field) { // If the field has a value set try to find // a matching tag name in the new content type's fields foreach ($this->old_fields as $Old_field) { if ($Field->short_tag == $Old_field->short_tag) { $this->Entry_data->{'field_id_' . $Field->id} = $this->Entry_data->{'field_id_' . $Old_field->id}; } } } // Set old fields to NULL foreach ($this->old_fields as $Old_field) { $this->Entry_data->{'field_id_' . $Old_field->id} = NULL; } } }