Example #1
0
if (!isset($_GET['page'])) {
    $render = true;
    $thisPage = 'Templates';
    $emailFolders = $template->getFolders('emails');
    foreach ($emailFolders as &$f) {
        $f['contents'] = $template->getTemplatesInFolder($f['folder_id']);
        $f['content_count'] = $template->getCountTemplatesInFolder($f['folder_id']);
    }
    unset($f);
    $letterFolders = $template->getFolders('letters');
    foreach ($letterFolders as &$f) {
        $f['contents'] = $template->getTemplatesInFolder($f['folder_id']);
        $f['content_count'] = $template->getCountTemplatesInFolder($f['folder_id']);
    }
    unset($f);
    $emailTemplates = $template->getTemplates('email', 0);
    $letterTemplates = $template->getTemplates('letter', 0);
    $l10n->addResource(__DIR__ . '/l10n/templates.json');
    $viewFile = 'views/templates.php';
} elseif ($_GET['page'] === "create") {
    $template->insertTemplate($_POST);
    $loggers['audit']->info("Template created");
    header('location:templates.php');
    exit;
} elseif ($_GET['page'] === "fetch") {
    $content = $template->getTemplate($_GET['templateid']);
    $content[0]['content'] = htmlspecialchars_decode($content[0]['content']);
    header('Content-Type: application/json; charset=utf-8');
    echo json_encode($content);
    exit;
} elseif ($_GET['page'] === "update-folder") {
Example #2
0
 public function tmpl()
 {
     $article = $this->_postInit();
     App::import("vendor", "model/template");
     App::import('Sanitize');
     $this->js[] = "forum.tmpl.js";
     $this->css[] = "post.css";
     $this->_getNotice();
     $this->notice[] = array("url" => "", "text" => "ๆจก็‰ˆๅ‘ๆ–‡");
     if (isset($this->params['url']['tmplid'])) {
         //template question
         $id = trim($this->params['url']['tmplid']);
         try {
             $t = Template::getInstance($id, $this->_board);
         } catch (TemplateNullException $e) {
             $this->error(ECode::$TMPL_ERROR);
         }
         $info = array();
         try {
             foreach (range(0, $t->CONT_NUM - 1) as $i) {
                 $q = $t->getQ($i);
                 $info[$i] = array("text" => Sanitize::html($q['TEXT']), "len" => $q['LENGTH']);
             }
         } catch (TemplateQNullException $e) {
             $this->error();
         }
         $this->set("tmplId", $id);
         $this->set("bName", $this->_board->NAME);
         $this->set("info", $info);
         $this->set("num", $t->NUM);
         $this->set("tmplTitle", Sanitize::html($t->TITLE));
         $this->set("title", $t->TITLE_TMPL);
         $this->render("tmpl_que");
     } else {
         //template list
         try {
             $page = new Pagination(Template::getTemplates($this->_board));
         } catch (TemplateNullException $e) {
             $this->error(ECode::$TMPL_ERROR);
         }
         $info = $page->getPage(1);
         foreach ($info as &$v) {
             $v = array("name" => Sanitize::html($v->TITLE), "num" => $v->CONT_NUM);
         }
         $this->set("info", $info);
         $this->set("bName", $this->_board->NAME);
     }
 }