Get template functions

Source: Internet
Author: User
Public Function Actionchangetemplate () {$status =true; $interactive _id= (int) filter_input (input_post, ' id '),//post[id] $template _id= (int) filter_input (input_post            , ' MB '); Find page $interactives = Interactives::model ()->findbypk ($interactive _id);//get template $interactivetemplate =                Interactivetemplate::model ()->findbypk ($template _id);//modify Template $interactives->template_id = $template _id; $interactives->save ();//Set different content according to the template selected by the user $template_info = $interactiveTemplate->template_content;$ Interactivecontent = new Interactivecontent (); $interactivePic = new Interactivepic (); Add content, following regular expression matching based on content, generating corresponding contentif (Preg_match_all ('/preview_t_[0-9]+/', $template _info, $arr)) {//delete $res = Interactivecontent::model ()->deleteall ("Interactive_id=:id", Array (": id" = = $interactive _id)); foreach ($arr [0] as $key = $value) {$content = new interactivecontent (); $content->interactive_id = $interactive _id; $content-≫color = "Rgba (0,0,0,0.1)"; $content->content = ' 

\n\t text input box <\/strong><\/span>\n<\/p>\n

\n\tYou can make text input, copy, paste, adjust font size, color, alignment, line spacing, or you can set the corresponding background color and transparency for the text box itself. <\/span>\n<\/p> '; $content->c_time = Date ("y-m-d h:i:s"); $ret = $content->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} Add Picture if (Preg_match_all ('/preview_p_[0-9]+/', $template _info, $arr)) {//delete $res = Interactivepic::m Odel ()->deleteall ("Interactive_id=:id", Array (": id" =>$_post [' ID '])), for ($i = 1; $i <= count ($arr [0]); $i + + {$interactivePic = new Interactivepic (), $interactivePic->interactive_id = $_post [' id ']; $interactivePic->pic_ Scale = 2.2; $interactivePic->pic_src = "/images/editinteractive/pcover_000.jpg"; $interactivePic->pic_width = $interactivePic->pic_height =30, $interactivePic->pic_x = 0; $interactivePic->pic_y =0; $interactivePic- >tag = $i; $interactivePic->c_time = Date ("y-m-d h:i:s");$ret = $interactivePic->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if (Preg_match_all ('/preview_s1_1_p[0-9]+/', $template _info, $arr)) {//Remove $res = Interactivepic::model () DeleteAll ("Interactive_id=:id", Array (": id" =>$_post [' ID '])), for ($i = 1; $i <= count ($arr [0]); $i + +) {$interact Ivepic = new Interactivepic (), $interactivePic->interactive_id = $_post [' id ']; $interactivePic->pic_scale = 2.2;$ INTERACTIVEPIC-&GT;PIC_SRC = "/images/editinteractive/pcover_000.jpg"; $interactivePic->pic_width = 33;$ Interactivepic->pic_height =44, $interactivePic->pic_x = $interactivePic->pic_y =44; $interactivePic- >tag = $interactivePic->c_time = Date ("y-m-d h:i:s"), $ret = $interactivePic->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if (Preg_match_all ('/preview_s1_1_t[0-9]+/', $template _info, $arr)) {//Remove $res = Interactivecontent::model () DeleteAll ("Interactive_id=:id", Array (": id" =>$_post [' ID '])); foreach ($arr [0] as $key = = $value) {$content = new Interactivecontent (); $content->interactive_id = $_post [' id ']; $content->color = "Rgba (0,0,0,0.1)"; $content- >content = '

\n\t text input box <\/strong><\/span>\n<\/p>\n

\n\t You can text input, copy, paste, adjust font size, color, alignment, line spacing, or you can set the corresponding background color and transparency of the text box itself. <\/span>\n<\/p> '; $content->c_time = Date ("y-m-d h:i:s"); $ret = $content->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if (Preg_match_all ('/preview_s1_1_t_[0-9]+/', $template _info, $arr)) {//Remove $res = Interactivecontent::model () DeleteAll ("Interactive_id=:id", Array (": id" =>$_post [' ID '])); foreach ($arr [0] as $key = = $value) {$content = new Interactivecontent (); $content->interactive_id = $_post [' id ']; $content->color = "Rgba (0,0,0,0.1)"; $content- >content = '

\n\t text input box <\/strong><\/span>\n<\/p>\n

\n\t You can text input, copy, paste, adjust font size, color, alignment, line spacing, or you can set the corresponding background color and transparency of the text box itself. <\/span>\n<\/p> '; $content->c_time = Date ("y-m-d h:i:s"); $ret = $content->save (); if ($ret >0)//If correct, the result is true $status = $status &true; else $status = $status &false;}} if ($status) {echo json_encode (array (//success ' status ' = ' success '));} else {echo json_encode (' status ' = > ' fail ');}}


The above describes the get template functions, including aspects of the content, you want to be interested in PHP tutorial friends helpful.

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.