<?Phpnamespace Addons\survey\controller; //name Space UseHome\controller\addonscontroller;//calling the plug-in controller classclassQuestioncontrollerextendsAddonscontroller {//defining the problem controller var $model;//Setting the model variable var $survey _id;//Setting the survey_id variable function_initialize () {//initialization functionParent::_initialize ();//calling the parent class controller initialization $this->model =$this->getmodel (' survey_question ');//get model data for the problem method $param[' survey_id '] =$this->survey_id =intval($_request[' survey_id ']);//get and set the questionnaire ID $res[' title '] = ' micro research ';//set the array and assign a value to the title $res[' url '] = Addons_url (' survey://survey/lists ');//set the URL in the array $res[' class '] = '; $nav[] =$res;//give the array to Nav $res[' title '] = ' problem management ';//set the data again $res[' url '] = Addons_url (' survey://question/lists ',$param);//Set URL $res[' class '] = ' current ';//Set class value $nav[] =$res;//to the array $nav, to form a two-dimensional array $this->assign (' Nav ',$nav);//hand over to the foreground template display } //list model for generic plug-ins Public functionLists () {//List Method $param[' survey_id '] =$this->survey_id;//set the questionnaire ID of the parameter array $param[' model '] =$this->model [' id '];//Setting the Model value $add _url= U (' Add ',$param);//The u method gets the URL $this->assign (' Add_url ',$add _url);//Presented to the template $map[' survey_id '] =$this->survey_id;//set Condition array mapSession (' Common_condition ',$map);//Set SessionParent:: Common_lists ($this->model, 0, ",er= ' sort asc,id asc ');//get data on the model list and sort } //editing models for Universal Plugins Public functionedit () {$id= I (' id ');//Get ID if(Is_post) {//If there is a reference $Model= D (Parse_name (Get_table_name ($this->model [' id ']), 1));//instance model//Get field information for the model $Model=$this->checkattr ($Model,$this->model [' ID '] ); if($Model->create () &&$Model->save ()) {//If the data is added $param[' survey_id '] =$this->survey_id;//Set Array survey_id $param[' model '] =$this->model [' id '];//set the model ID $url= U (' lists ',$param);//Jump URL $this->success (' Save ').$this->model [' title ']. Success ‘,$url);//edit successful, prompt and jump}Else { $this->error ($Model->geterror ());//Failure Error}} Parent:: Common_edit ($this->model,$id);//Public editing methods } //add-on model for Universal plug-ins Public functionAdd () {if(Is_post) {//If there is a reference $Model= D (Parse_name (Get_table_name ($this->model [' id ']), 1));//get and instantiate the model//Get field information for the model $Model=$this->checkattr ($Model,$this->model [' ID '] ); if($Model->create () &&$id=$Model->add ()) {//added successfully, $param[' survey_id '] =$this->survey_id;//define the questionnaire ID in the array param $param[' model '] =$this->model [' id '];//defining the Model ID $url= U (' lists ',$param);//Skip URL $this->success (' Add '.$this->model [' title ']. Success ‘,$url);//Success and Jump}Else { $this->error ($Model->geterror ());//failure, error } Exit (); } $normal _tips= ' field type is single, multi-select parameter format line one, the value and title of each item is separated by a colon in English. such as: <br/>0: Male <br/>1: Female <br/>2: Confidentiality ';//hint String $this->assign (' Normal_tips ',$normal _tips);//give template display tipsParent:: Common_add ($this->model);//To perform a parent class Add method } //generic plug-in removal model Public functionDel () {//call the Delete method of the parent classParent::common_del ($this-model); }}
Micro Survey Setup Problem controller