<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

   

  	function create_slug_ch($string){
		$slug_a = url_title(convert_accented_characters($string), 'dash', true);
		//$slug_b = preg_replace ('/[0-9]+$/','', $slug_a );
		$slug_c = auto_link($slug_a, 'url');
		return reduce_multiples(trim($slug_c), "-", TRUE);
	}
	
	function filter_array($array,$term,$field_name){
		$matches = array();
		foreach($array as $a){
			if($a["$field_name"] == $term)
				$matches[]=$a;
		}
		return $matches;
	}
	
	function filter_array_three($array,$term,$field_name,$term_1,$field_name_1,$term_2,$field_name_2){
		$matches = array();
		foreach($array as $a){
			if($a["$field_name"] == $term && $a["$field_name_1"] == $term_1 && $a["$field_name_2"] == $term_2)
				$matches[]=$a;
		}
		return $matches;
	}
	
	function filter_array_two($array,$term,$field_name,$term_1,$field_name_1){
		$matches = array();
		foreach($array as $a){
			if($a["$field_name"] == $term && $a["$field_name_1"] == $term_1)
				$matches[]=$a;
		}
		return $matches;
	}
	
	function filter_array_two_or_con($array,$term,$field_name,$term_1,$field_name_1){
		$matches = array();
		foreach($array as $a){
			if($a["$field_name"] == $term || $a["$field_name_1"] == $term_1)
				$matches[]=$a;
		}
		return $matches;
	}
	
	function get_multidimension_array_key_ch($products, $field, $value){

		foreach($products as $key => $product){

			if($product[$field]===$value){

				return $key;

			}	 

		}

		return false;

	}

	

	function get_widgets_data_ch(){

		$CI = & get_instance();

		$CI->load->model('Widgets_mdl');

		return $CI->Widgets_mdl->widgets_list();

	}

	

	function get_cmsmeta_fields_h($page_id){

		$CI = & get_instance();

		$CI->load->model('Master_data_mdl');

		return $CI->Master_data_mdl->get_cmsmeta_fields($page_id);

 	}

	

	function get_widgetsmeta_fields_h($widget_id){

		$CI = & get_instance();

		$CI->load->model('Widgets_mdl');

		return $CI->Widgets_mdl->get_widgetsmeta_fields($widget_id);

 	}

	

	function get_widgetmeta_options_h($widgetsmeta_id){

 		$CI = & get_instance();

		$CI->load->model('Widgets_mdl');

		return $CI->Widgets_mdl->get_widgetmeta_options($widgetsmeta_id);

	}

	

	function get_master_course_level_list_h(){

		$CI = & get_instance();

		$CI->load->model('Master_data_mdl');

		return $CI->Master_data_mdl->get_master_course_level_list();

 	}