/** * Generate dynamic config file * * @since 1.0 * @param boolean Frontend true/false * @param string Templateid * @param string A2 Languageid * @return string */ public static function GenerateConfig($frontend = false, $templateid = "", $languageid = "en") { $mod = cms_utils::get_module('MicroTiny'); // Check if we are in object instance if (!is_object($mod)) { return false; } // TODO: return static file if this fails, or something // Init $config = cms_utils::get_config(); $result = ""; $linker = ""; if ($frontend) { $mod->smarty->assign("isfrontend", true); } else { $mod->smarty->assign("isfrontend", false); $result .= self::GetCMSLinker(); $linker = "cmslinker,"; } if (count(self::$_textareas)) { $tmp = implode(',', self::$_textareas); self::$_textareas = array(); $mod->smarty->assign('textareas', $tmp); } if ($templateid <= 0) { $pageinfo = cmsms()->get_variable('pageinfo'); if (is_object($pageinfo)) { $templateid = $pageinfo->template_id; } else { $contentobj = cms_utils::get_app_data('editing_content'); if (is_object($contentobj)) { $templateid = $contentobj->TemplateId(); } else { $templateops = cmsms()->GetTemplateOperations(); $dflt_template = $templateops->LoadDefaultTemplate(); if (is_object($dflt_template)) { $templateid = $dflt_template->id; } } } } if ($templateid > 0) { $mod->smarty->assign('templateid', $templateid); } $urlext = ""; if (isset($_SESSION[CMS_USER_KEY])) { $urlext = CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY]; } $mod->smarty->assign("urlext", $urlext); //,pasteword,,|,undo,redo $image = ""; if ($mod->GetPreference("allowimages", 0) && !$frontend) { $image = ",image,|"; } $toolbar = "undo,|,bold,italic,underline,|,cut,copy,paste,pastetext,removeformat,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|," . $linker . "link,unlink,|" . $image . ",formatselect"; //,separator,styleselect // handle css styles... newline OR comma separated (why, kinda dumb?) $tmp = $mod->GetPreference('css_styles'); $tmp = str_replace("\r\n", "\n", $tmp); $tmp = explode("\n", $tmp); $tmp2 = array(); foreach ($tmp as $one) { $one = trim($one); if (empty($one)) { continue; } $tmp3 = explode(',', $one); foreach ($tmp3 as $one2) { $tmp2[] = trim($one2); } } $tmp3 = array(); foreach ($tmp2 as $one) { $tmp4 = explode('=', trim($one), 2); if (count($tmp4) == 1) { $tmp3[$tmp4[0]] = $tmp4[0]; } else { $tmp3[$tmp4[0]] = $tmp4[1]; } } $css_styles = ''; foreach ($tmp3 as $key => $value) { $css_styles .= $key . '=' . $value . ';'; } $css_styles = substr($css_styles, 0, -1); if ($css_styles != '') { $toolbar .= ",separator,styleselect"; $mod->smarty->assign("css_styles", $css_styles); } // give the rest to smarty. $mod->smarty->assign('show_statusbar', $mod->GetPreference('show_statusbar', 0)); $mod->smarty->assign('allow_resize', $mod->GetPreference('allow_resize', 0)); $mod->smarty->assign('strip_background', $mod->GetPreference('strip_background', 1)); $mod->smarty->assign('force_blackonwhite', $mod->GetPreference('force_blackonwhite', 0)); $mod->smarty->assign("toolbar", $toolbar); $mod->smarty->assign("language", $languageid); $mod->smarty->assign("filepickertitle", $mod->Lang("filepickertitle")); $fpurl = $mod->create_url("", "filepicker"); $fpurl = str_replace("&", "&", $fpurl); $mod->smarty->assign("filepickerurl", $fpurl); $result .= $mod->ProcessTemplate('microtinyconfig.tpl'); return $result; }
/** * Generate dynamic config file * * @since 1.0 * @param boolean Frontend true/false * @param string Templateid * @param string A2 Languageid * @return string */ public static function GenerateConfig($frontend = false, $templateid = "", $languageid = "en") { $mod = cms_utils::get_module('MicroTiny'); // Check if we are in object instance if (!is_object($mod)) { return false; } // TODO: return static file if this fails, or something // Init $config = cms_utils::get_config(); $result = ""; $linker = ""; if ($frontend) { $mod->smarty->assign("isfrontend", true); } else { $mod->smarty->assign("isfrontend", false); $result .= self::GetCMSLinker(); $linker = "cmslinker,"; } if (count(self::$_textareas)) { $tmp = implode(',', self::$_textareas); self::$_textareas = array(); $mod->smarty->assign('textareas', $tmp); } if ($templateid == '') { $pageinfo = cmsms()->get_variable('pageinfo'); if (is_object($pageinfo)) { $templateid = $pageinfo->template_id; } else { $templateops = cmsms()->GetTemplateOperations(); $dflt_template = $templateops->LoadDefaultTemplate(); if (is_object($dflt_template)) { $templateid = $dflt_template->id; } } } if ($templateid) { $mod->smarty->assign('templateid', $templateid); } $mod->smarty->assign("rooturl", $config["root_url"]); $urlext = ""; if (isset($_SESSION[CMS_USER_KEY])) { $urlext = CMS_SECURE_PARAM_NAME . '=' . $_SESSION[CMS_USER_KEY]; } $mod->smarty->assign("urlext", $urlext); //,pasteword,,|,undo,redo $image = ""; if ($mod->GetPreference("allowimages", 0) && !$frontend) { $image = ",image,|"; } $toolbar = "undo,|,bold,italic,underline,|,cut,copy,paste,pastetext,removeformat,|,justifyleft,justifycenter,justifyright,justifyfull,|,bullist,numlist,|," . $linker . "link,unlink,|" . $image . ",formatselect"; //,separator,styleselect $css_styles = $mod->GetPreference('css_styles'); $css_styles = str_replace("\n", ",", $css_styles); $css_styles = str_replace("\r", ",", $css_styles); if ($css_styles != "") { $toolbar .= ",separator,styleselect"; $mod->smarty->assign("css_styles", $css_styles); } $mod->smarty->assign('show_statusbar', $mod->GetPreference('show_statusbar', 0)); $mod->smarty->assign('allow_resize', $mod->GetPreference('allow_resize', 0)); $mod->smarty->assign("toolbar", $toolbar); $mod->smarty->assign("language", $languageid); $mod->smarty->assign("filepickertitle", $mod->Lang("filepickertitle")); $result .= $mod->ProcessTemplate('microtinyconfig.tpl'); return $result; }