如何在控制器中添加功能


How to add function in controller

我正在使用Kumbia框架,我正试图在控制器中添加功能ordenar_array(),以便在控制器内的不同位置使用。

但是当我尝试调用这个函数时,浏览器告诉我这个函数没有定义。

错误:在C:'xampp'htdocs'shbarcelona'app'controllers'whoweare_controller.php中调用未定义函数orderar_array ()

我可以在控制器中添加功能吗?

如何?

编辑:所有控制器代码。
class WhoweareController extends ApplicationController
{
    public $staff;
    public $prueba;
    public $selectedCategory;
    public $experiences;
    public $offices;
    public function initialize()
    {
        parent::initialize();
    }
    public function ordenar_array() { 
      $n_parametros = func_num_args(); // Obenemos el número de parámetros 
      if ($n_parametros<3 || $n_parametros%2!=1) { // Si tenemos el número de parametro mal... 
        return false; 
      } else { // Hasta aquí todo correcto...veamos si los parámetros tienen lo que debe ser... 
        $arg_list = func_get_args(); 
        if (!(is_array($arg_list[0]) && is_array(current($arg_list[0])))) { 
          return false; // Si el primero no es un array...MALO! 
        } 
        for ($i = 1; $i<$n_parametros; $i++) { // Miramos que el resto de parámetros tb estén bien... 
          if ($i%2!=0) {// Parámetro impar...tiene que ser un campo del array... 
            if (!array_key_exists($arg_list[$i], current($arg_list[0]))) { 
              return false; 
            } 
          } else { // Par, no falla...si no es SORT_ASC o SORT_DESC...a la calle! 
            if ($arg_list[$i]!=SORT_ASC && $arg_list[$i]!=SORT_DESC) { 
              return false; 
            } 
          } 
        } 
        $array_salida = $arg_list[0]; 
        // Una vez los parámetros se que están bien, procederé a ordenar... 
        $a_evaluar = "foreach ('$array_salida as '$fila){'n"; 
        for ($i=1; $i<$n_parametros; $i+=2) { // Ahora por cada columna... 
          $a_evaluar .= "  '$campo{$i}[] = '$fila['$arg_list[$i]'];'n"; 
        } 
        $a_evaluar .= "}'n"; 
        $a_evaluar .= "array_multisort('n"; 
        for ($i=1; $i<$n_parametros; $i+=2) { // Ahora por cada elemento... 
          $a_evaluar .= "  '$campo{$i}, SORT_REGULAR, '$arg_list[".($i+1)."],'n"; 
        } 
        $a_evaluar .= "  '$array_salida);"; 
        // La verdad es que es más complicado de lo que creía en principio... :) 
        eval($a_evaluar); 
        return $array_salida; 
      } 
    } 
    public function index()
    {//Bookingsend::new_pdf_turismo('6375');
        if($_SERVER['REMOTE_ADDR']=='88.2.48.198'){

        }   
        $this->javascripts[] = 'http://www.shbarcelona.com/javascript/whoweare.js';
        $this->javascripts[] = 'http://www.shbarcelona.com/javascript/jquery-fancybox.js';
        $this->javascripts[] = 'http://www.shbarcelona.com/javascript/jquery-scrollTo.js';
        $this->javascripts[] = 'http://www.shbarcelona.com/javascript/autoFancybox.js';
        $this->styleSheets[] = 'http://www.shbarcelona.com/css/jquery-fancybox.css';
        $this->styleSheets[] = array('path'=>'http://www.shbarcelona.com/css/jquery-fancybox-mobile.css', 'mobile' => true, 'media' => 'all');
        $this->javascripts[] = 'http://maps.google.com/maps/api/js?sensor=false';
        $staff = new Staff();
        $service = new GhPro();
        $this->departamentos = Language::getTs('departamentos');
        $this->prueba = $service->getStaff();
        $this->prueba = ordenar_array($this->prueba, 'foto_visible');
        $this->selectedCategory = $this->action_name;
        $this->staff[0] = $staff->getStaffFromDept(array(1, 2));
        $this->staff[1] = $staff->getStaffFromDept(array(3, 4));
        $this->staff[2] = $staff->getStaffFromDept(5);
        $this->staff[3] = $staff->getStaffFromDept(6);
        $this->staff[4] = $staff->getStaffFromDept(7);
        $this->staff[5] = $staff->getStaffFromDept(8);
        $this->offices[0] = $this->config['maps']['oficina1'];
        $this->offices[1] = $this->config['maps']['oficina2'];
    }
    public function philosophy()
    {
        $this->view = 'index';
        $this->index();
    }
    public function project()
    {
        $this->view = 'index';
        $this->index();
    }
    public function ourAgencies()
    {
        $this->view = 'index';
        $this->index();
    }
    public function internationalTeam()
    {
        $this->view = 'index';
        $this->index();
    }
    public function references()
    {
        $this->view = 'index';
        $this->index();
    }
    public function debug(){
        $this->view = '_index';
        $this->index(); 
    }
    public function experiences()
    {
        $experiences = new Experiences();
        $this->experiences = $experiences->getExperiences();
    }
    public function architectureDepartment()
    {
        $this->javascripts[] = 'http://www.shbarcelona.com/javascript/architectureDepartment.js';
    }
}

试试这个

class <Clssname> extends CI_Controller
{
   public function __construct()
   {
   }
   public function ordenar_array()
  {
     <add your code here...>
  } 
}