<?php class TemplateEngine { /* Rysuje szablon */ public function drawTemplate($sTitle) { echo '<script type="text/javascript"> tinyMCE.init({ // General options mode : "textareas", theme : "advanced", skin : "o2k7", plugins : "pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,in
sertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,f
ullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template,inlinepopups,au
tosave", // Theme options theme_advanced_buttons1 : "save,newdocument,|,bold,italic,underline,strikethrough,|,justifyleft,justif
ycenter,justifyright,justifyfull,styleselect,formatselect,fontselect,fontsizesele
ct", theme_advanced_buttons2 : "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,out
dent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|
,insertdate,inserttime,preview,|,forecolor,backcolor", theme_advanced_buttons3 : "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iesp
ell,media,advhr,|,print,|,ltr,rtl,|,fullscreen", theme_advanced_buttons4 : "insertlayer,moveforward,movebackward,absolute,|,styleprops,|,cite,abbr,acro
nym,del,ins,attribs,|,visualchars,nonbreaking,template,pagebreak,restoredraft", theme_advanced_toolbar_location : "top", theme_advanced_toolbar_align : "left", theme_advanced_statusbar_location : "bottom", theme_advanced_resizing : true, // Example content CSS (should be your site CSS) content_css : "css/content.css", // Drop lists for link/image/media/template dialogs template_external_list_url : "lists/template_list.js", external_link_list_url : "lists/link_list.js", external_image_list_url : "lists/image_list.js", media_external_list_url : "lists/media_list.js", // Replace values for the template plugin template_replace_values : { username : "Some User", staffid : "991234" } }); </script>'; } /* Wycztuje szablon */ public function loadTemplate($sTemplateName) { if(file_exists($_SERVER['DOCUMENT_ROOT'] . APP_WEB_PATH . '/_administrator/_templates/' . $sTemplateName . '.tpl')) { $template = fopen($_SERVER['DOCUMENT_ROOT'] . APP_WEB_PATH . '/_administrator/_templates/' . $sTemplateName . '.tpl', 'r'); } } } public function readContentMode($sModeTemplate) { $this->_tpl = str_replace('<input type="hidden" value="%_content_%">', $this->loadTemplate($sModeTemplate), $this->_tpl); } public function changeString($stringToChange) { } public function changeIntroducedString($sIntroducedString, $sStringToChange) { } private $_tpl; } ?>
Szablon zapisany w pliku .tpl:
Wywołuję najpierw metodę loadTemplate następnie:
/* Edycja artykułu */ } else if($_GET['mode'] == 'edit-article') { $objCategory = new category(); $result = $objCategory->getCategoryList(); $html = '<select name="category_id">'; foreach ($result as $value) { $html .= '<option value="' . $value['wp_category_id'] . '">' . $value['wp_category_name'] . '</option>'; } $html .= '</select>'; $objTpl->changeString($html); $objTpl->changeIntroducedString('%_article_short_description_%', 'fds'); } $objTpl->drawTemplate('Witaj ' . $_SESSION['user_name'] . ' w panelu zarządzania treścią!');
niestety druga instrukcja $objTpl->changeIntroducedString('%_article_short_description_%', 'fds'); nie zamienia mi łańcucha na 'fds' przy czym '%_article_short_description_%' nie jest drukowany w oknie przeglądarki.