if ($function == 'add') { $attributes = rex_setAttributes('ctype', $ctypes, ''); $attributes = rex_setAttributes('modules', $modules, $attributes); $attributes = rex_setAttributes('categories', $categories, $attributes); $TPL->setValue('attributes', addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $info = $I18N->msg('template_added'); } else { $warning = $TPL->getError(); } } else { $attributes = rex_setAttributes('ctype', $ctypes, $attributes); $attributes = rex_setAttributes('modules', $modules, $attributes); $attributes = rex_setAttributes('categories', $categories, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue('attributes', addslashes($attributes)); $TPL->addGlobalUpdateFields(); if ($TPL->update()) { $info = $I18N->msg('template_updated'); } else { $warning = $TPL->getError(); } } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['GENERATED_PATH'] . '/templates', 0); if ($goon != '') { $function = 'edit';
if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $attributes = rex_setAttributes("modules", $modules, $attributes); $attributes = rex_setAttributes("categories", $categories, $attributes); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $info = $I18N->msg("template_added"); } else { $warning = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $attributes = rex_setAttributes("modules", $modules, $attributes); $attributes = rex_setAttributes("categories", $categories, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); if ($TPL->update()) { $info = $I18N->msg("template_updated"); } else { $warning = $TPL->getError(); } } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0); if ($goon != "") { $function = "edit";
$TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $attributes = rex_setAttributes("modules", $modules, $attributes); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $info = $I18N->msg("template_added"); } else { $warning = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $attributes = rex_setAttributes("modules", $modules, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); if ($TPL->update()) { $info = $I18N->msg("template_updated"); } else { $warning = $TPL->getError(); } } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0); if ($goon != "") { $function = "edit";
$TPL->setTable($REX['TABLE_PREFIX'] . "template"); $TPL->setValue("name", $templatename); $TPL->setValue("active", $active); $TPL->setValue("content", $content); if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $message = $I18N->msg("template_added"); } else { $message = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); $message = $TPL->update($I18N->msg("template_updated")); } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['INCLUDE_PATH'] . "/generated/templates", 0); if (isset($goon) and $goon != "") { $function = "edit"; $save = "nein"; } else { $function = ""; }
protected function createTemplate($params) { global $REX, $I18N; $function = 'add'; $active = Watson::arrayCastVar($params, 'active', 'int', 0); $templatename = Watson::arrayCastVar($params, 'templatename', 'string', ''); $content = Watson::arrayCastVar($params, 'content', 'string', ''); $ctypes = Watson::arrayCastVar($params, 'ctype', 'array', array()); $categories = Watson::arrayCastVar($params, 'categories', 'array', array()); $modules = Watson::arrayCastVar($params, 'modules', 'array', array()); /* * following Code is from REDAXO * include/pages/template.inc.php * * change rex_sql > \rex_sql */ $num_ctypes = count($ctypes); if ($ctypes[$num_ctypes] == "") { unset($ctypes[$num_ctypes]); if (isset($ctypes[$num_ctypes - 1]) && $ctypes[$num_ctypes - 1] == '') { unset($ctypes[$num_ctypes - 1]); } } // Daten wieder in den Rohzustand versetzen, da für serialize()/unserialize() // keine Zeichen escaped werden dürfen for ($i = 1; $i < count($ctypes) + 1; $i++) { $ctypes[$i] = stripslashes($ctypes[$i]); } // leerer eintrag = 0 if (count($categories) == 0 || !isset($categories["all"]) || $categories["all"] != 1) { $categories["all"] = 0; } // leerer eintrag = 0 if (count($modules) == 0) { $modules[1]["all"] = 0; } foreach ($modules as $k => $module) { if (!isset($module["all"]) || $module["all"] != 1) { $modules[$k]["all"] = 0; } } $TPL = \rex_sql::factory(); $TPL->setTable($REX['TABLE_PREFIX'] . "template"); $TPL->setValue("name", $templatename); $TPL->setValue("active", $active); $TPL->setValue("content", $content); $attributes = rex_setAttributes("ctype", $ctypes, ""); $attributes = rex_setAttributes("modules", $modules, ""); $attributes = rex_setAttributes("categories", $categories, ""); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($function == "add") { $attributes = rex_setAttributes("ctype", $ctypes, ""); $attributes = rex_setAttributes("modules", $modules, $attributes); $attributes = rex_setAttributes("categories", $categories, $attributes); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalCreateFields(); if ($TPL->insert()) { $template_id = $TPL->getLastId(); $info = $I18N->msg("template_added"); } else { $warning = $TPL->getError(); } } else { $attributes = rex_setAttributes("ctype", $ctypes, $attributes); $attributes = rex_setAttributes("modules", $modules, $attributes); $attributes = rex_setAttributes("categories", $categories, $attributes); $TPL->setWhere("id='{$template_id}'"); $TPL->setValue("attributes", addslashes($attributes)); $TPL->addGlobalUpdateFields(); if ($TPL->update()) { $info = $I18N->msg("template_updated"); } else { $warning = $TPL->getError(); } } // werte werden direkt wieder ausgegeben $templatename = stripslashes($templatename); $content = stripslashes($content); rex_deleteDir($REX['GENERATED_PATH'] . "/templates", 0); if ($goon != "") { $function = "edit"; $save = "nein"; } else { $function = ""; } return array('success' => $info, 'error' => $warning); }