<?php // KioCMS - Kiofol Content Managment System // modules/news/admin/settings.php $info = new Infobox(); $save = $_POST['save'] ? true : false; $form = $save ? $_POST['form'] : $news; $form['bbcode'] = $save ? $_POST['bbcode'] : $news['bbcode'] ? 1 : 0; $form['sort'] = $save ? $form['sort'] : explode(' ', $form['sort']); $form['blocks'] = $save ? array_diff($blocks, $_POST['blocks']) : ($news['blocks'] ? explode(', ', $news['blocks']) : ''); if ($save) { $errors[0] = !$form['limit'] ? 'Pole <strong>wpisów na stronę</strong> nie może zostać puste.' : ''; $errors[1] = !$form['sort'] ? 'Należy określić <strong>sortowanie wpisów</strong>.' : ''; if (!in_array(true, $errors)) { $form['sort'] = $form['sort'][0] . ' ' . $form['sort'][1]; save_config($news, 'news', HREF . 'admin/modules/news/settings'); } else { $info->negative($errors); } } else { $info->neutral(array($lang_admin['MODULE_SETTINGS'], $lang_system['REQUIRED'])); } $tpl = new PHPTAL('modules/news/admin/settings.html'); $tpl->form = $form; $tpl->lang2 = $lang2; $tpl->lang_admin = $lang_admin; $tpl->info = $info->show(); $tpl->columns = form_columns(); $tpl->blocks = form_blocks(); echo $tpl->execute();
function ShowBody() { global $edit, $s, $m, $x, $page, $page_display_name, $lang, $type; // check $edit against $x - they need to represent the same page, if not redirect. $checkid = safe_field('page_id', 'pixie_core', "page_name='{$x}'"); if (isset($edit) && $edit && $m == 'static') { if ($edit != $checkid) { echo "<div class=\"helper\"><h3>" . $lang['help'] . "</h3><p>" . $lang['unknown_edit_url'] . "</p></div>"; $cancel = TRUE; } } if (isset($cancel)) { } else { $cancel_not_set = 1; } if ($cancel_not_set == 1) { $Nams = explode('|', substr($this->Nam, 0, strlen($this->Nam) - 1)); $Type = explode('|', substr($this->Typ, 0, strlen($this->Typ) - 1)); $Leng = explode('|', substr($this->Len, 0, strlen($this->Len) - 1)); $Flag = explode('|', substr($this->Flg, 0, strlen($this->Flg) - 1)); $Fild = explode('|', substr($this->Res, 0, strlen($this->Res) - 1)); if (!$page) { $page = 1; } if (isset($s) && $s == 'settings') { if (strpos($this->tablename, 'module')) { $formtitle = $lang['advanced'] . " " . $lang['page_settings']; } else { if (strpos($this->tablename, 'dynamic')) { $formtitle = $lang['advanced'] . " " . $lang['page_settings']; } else { $formtitle = $lang['page_settings']; } } } else { if (isset($edit) && $edit) { if ($m == 'static') { $formtitle = $lang['edit'] . " {$page_display_name} " . $lang['settings_page']; } else { $formtitle = $lang['edit'] . " {$page_display_name} " . str_replace('.', "", $lang['entry']) . " (#{$edit})"; } } else { $formtitle = $lang['new_entry'] . " {$page_display_name} " . str_replace('.', "", $lang['entry']); } } if (isset($s) && $s == 'settings') { $post = "?s={$s}&x={$x}"; } else { if ($m == 'static' && isset($edit)) { $post = "?s={$s}&m={$m}&x={$x}&edit={$edit}&page={$page}"; } else { $post = "?s={$s}&m={$m}&x={$x}&page={$page}"; } } echo "<form accept-charset=\"UTF-8\" action=\"{$post}\" method=\"post\" id=\"form_addedit\" class=\"form\">\n"; echo "\t\t\t\t\t\t<fieldset>\n\t\t\t\t\t\t<legend>{$formtitle}</legend>\n"; echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"table_name\" value=\"{$this->tablename}\" maxlength=\"80\" />\n"; for ($j = 0; $j < count($Nams); $j++) { // clears out the form as some of the fields populate if (!isset($edit) or !$edit) { $Fild[$j] = ""; } // if comments are disabled then hide the field if ($Nams[$j] == 'comments' && !public_page_exists('comments')) { echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"no\" maxlength=\"" . $Leng[$j] . "\" />\n"; $j++; } if (!in_array($Nams[$j], $this->exclude)) { //fields populated and output depending on type etc. //$searchfor = "_".first_word($Nams[$j]); if ($Leng[$j] < 40) { $ln = $Leng[$j]; } else { if ($Leng[$j] <= 400) { $ln = 50; } } $nullf = explode(" ", $Flag[$j]); if ($nullf[0] == 'not_null') { // label required fields if (isset($lang['form_' . $Nams[$j]])) { if ($Nams[$j] != 'page_name' or $type == 'static' or !isset($edit) or !$edit) { /* Prevents the editing of page_name which does not work in modules and dynamic pages */ $displayname = $lang['form_' . $Nams[$j]] . " <span class=\"form_required\">" . $lang['form_required'] . "</span>"; } else { $displayname = " <span style=\"display:none\" class=\"form_required\">" . $lang['form_required'] . "</span>"; } } else { $displayname = simplify($Nams[$j]) . " <span class=\"form_required\">" . $lang['form_required'] . "</span>"; } } else { if (isset($lang['form_' . $Nams[$j]]) && $lang['form_' . $Nams[$j]]) { $displayname = $lang['form_' . $Nams[$j]] . " <span class=\"form_optional\">" . $lang['form_optional'] . "</span>"; } else { $displayname = simplify($Nams[$j]) . " <span class=\"form_optional\">" . $lang['form_optional'] . "</span>"; } } // check language file for any form help if (isset($lang['form_help_' . $Nams[$j]]) && $lang['form_help_' . $Nams[$j]]) { if ($Nams[$j] != 'page_name' or $type == 'static' or !isset($edit) or !$edit) { /* Prevents the editing of page_name which does not work in modules and dynamic pages */ $form_help = "<span class=\"form_help\">" . $lang['form_help_' . $Nams[$j]] . "</span>"; } else { $form_help = "<span style=\"display:none\" class=\"form_help\">" . $lang['form_help_' . $Nams[$j]] . "</span>"; } } else { $form_help = ""; } if ($GLOBALS['rich_text_editor'] == 1) { $containsphp = strlen(stristr(utf8_decode($Fild[$j]), '<?php')) > 0; if ($containsphp) { $form_help .= " <span class=\"alert\">" . $lang['form_php_warning'] . '</span>'; } } echo "\t\t\t\t\t\t\t<div class=\"form_row\">\n\t\t\t\t\t\t\t\t<div class=\"form_label\">\n\t\t\t\t\t<label for=\"{$Nams[$j]}\">" . $displayname . "</label>{$form_help}</div>\n"; //$Type[$j] $Leng[$j] $Flag[$j] for field info //echo "$Nams[$j] - $Type[$j] - $Leng[$j] - $Flag[$j]"; // see form field properties if ($Type[$j] == 'timestamp' && !isset($edit) && !$edit) { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n"; if (isset($date)) { date_dropdown($date); } else { $date = NULL; date_dropdown($date); } echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if ($Type[$j] == 'timestamp' && isset($edit) && $edit) { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n"; date_dropdown($Fild[$j]); echo "\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; //} else if ($Type[$j] == "blob") { // echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea\">\n\t\t\t\t\t\t\t\t<textarea name=\"$Nams[$j]\" class=\"form_item_textarea_no_ckeditor\">$Fild[$j]</textarea>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if ($Type[$j] == 'longtext' or $Leng[$j] > 800 or $Type[$j] == 'blob') { if ($GLOBALS['rich_text_editor'] == 1) { if (!$containsphp) { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea_ckeditor\">\n\t\t\t\t\t\t\t\t\t\t<textarea name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" cols=\"50\" class=\"ck-textarea\" rows=\"10\">" . htmlentities($Fild[$j], ENT_QUOTES, 'UTF-8') . "</textarea>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</div>\n"; // id=\"$Nams[$j]\" } else { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea\">\n\t\t\t\t\t\t\t\t<textarea name=\"{$Nams[$j]}\" class=\"form_item_textarea_no_ckeditor\">" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "</textarea>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; // id=\"$Nams[$j]\" } } else { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_textarea\">\n\t\t\t\t\t\t\t\t<textarea name=\"{$Nams[$j]}\" class=\"form_item_textarea_no_ckeditor\">" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "</textarea>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; // id=\"$Nams[$j]\" } } else { if ($Type[$j] == "set'yes','no'" or $Flag[$j] == 'not_null set') { if ($Fild[$j] == 'no') { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_radio\">\n\t\t\t\t\t\t\t\tYes<input type=\"radio\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" class=\"form_radio\" value=\"yes\" />\n\t \t\t\t\t\t\t \tNo<input checked=\"checked\" type=\"radio\" name=\"{$Nams[$j]}\" class=\"form_radio\" value=\"{$Fild[$j]}\" />\n\t\t\t\t\t\t\t\t</div>\n\n\t\t\t\t\t\t\t</div>\n"; } else { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_radio\">\n\t\t\t\t\t\t\t\tYes<input checked=\"checked\" type=\"radio\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" class=\"form_radio\" value=\"yes\" />\n\t \t\t\t\t\t\t \tNo<input type=\"radio\" name=\"{$Nams[$j]}\" class=\"form_radio\" value=\"no\"/>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } } else { if (first_word($Nams[$j]) == 'image') { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop image_preview\">\n"; db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Image' order by file_id desc"); echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if (first_word($Nams[$j]) == 'document') { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n"; db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Other' order by file_id desc"); echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if (first_word($Nams[$j]) == 'video') { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n"; db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Video' order by file_id desc"); echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if (first_word($Nams[$j]) == 'audio') { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n"; db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_type = 'Audio' order by file_id desc"); echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if (first_word($Nams[$j]) == 'file') { echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n"; db_dropdown('pixie_files', $Fild[$j], $Nams[$j], "file_id >= '0' order by file_id desc"); echo "\n\t\t\t\t\t\t\t\t<span class=\"more_upload\">or <a href=\"#\" onclick=\"upswitch('" . $Nams[$j] . "'); return false;\" title=\"" . $lang['upload'] . "\">" . strtolower($lang['upload']) . "...</a></span>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if ($Nams[$j] == 'tags') { $tableid = 0; $condition = $tableid . " >= '0'"; form_tag($this->tablename, $condition); echo "\t\t\t\t\t\t\t\t<div class=\"form_item\">\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" size=\""; if (isset($ln)) { echo $ln; } else { $ln = 25; echo $ln; } echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if ($Nams[$j] == 'page_blocks') { form_blocks(); echo "\t\t\t\t\t\t\t\t<div class=\"form_item\">\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" size=\""; if (isset($ln)) { echo $ln; } else { $ln = 25; echo $ln; } echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if ($Nams[$j] == 'privs') { if ($Fild[$j] == 2) { $adminclass = "selected=\"selected\""; $everyoneclass = NULL; } else { $everyoneclass = "selected=\"selected\""; $adminclass = NULL; } echo "\t\t\t\t\t\t\t\t<div class=\"form_item_drop\">\n\t\t\t\t\t\t\t\t\t<select class=\"form_select\" name=\"{$Nams[$j]}\" name=\"{$Nams[$j]}\">\n\t\t\t\t\t\t\t\t\t\t<option value=\"2\" {$adminclass}>Administrators only</option>\n\t\t\t\t\t\t\t\t\t\t<option value=\"1\" {$everyoneclass}>Administrators & Clients</option>\n\t\t\t\t\t\t\t\t\t</select>\n\t \t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</div>\n"; } else { if ($Nams[$j] != 'page_name' or $type == 'static' or !isset($edit) or !$edit) { /* Prevents the editing of page_name which does not work in modules and dynamic pages */ echo "\t\t\t\t\t\t\t\t<div class=\"form_item\">\n\t\t\t\t\t\t\t\t<input type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "\" size=\""; if (isset($ln)) { echo $ln; } else { $ln = 25; echo $ln; } echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>"; } else { echo "\t\t\t\t\t\t\t\t<div style=\"display:none\" class=\"form_item\">\n\t\t\t\t\t\t\t\t<input style=\"display:none\" type=\"text\" class=\"form_text\" name=\"{$Nams[$j]}\" id=\"{$Nams[$j]}\" value=\"" . htmlspecialchars($Fild[$j], ENT_QUOTES, 'UTF-8') . "\" size=\""; if (isset($ln)) { echo $ln; } else { $ln = 25; echo $ln; } echo "\" maxlength=\"" . $Leng[$j] . "\" />\n\t\t\t\t\t\t\t\t</div>"; } echo "\n\t\t\t\t\t\t\t</div>\n"; } } } } } } } } } } } } //other field types still to come: File uploads...? //hidden fields populated } else { if ($Nams[$j] == 'page_id' && isset($s) && $s == 'publish' && $m == 'dynamic') { $page_id = get_page_id($x); echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"{$page_id}\" maxlength=\"" . $Leng[$j] . "\" />\n"; } else { if (last_word($Nams[$j]) == 'id') { echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" maxlength=\"" . $Leng[$j] . "\" />\n"; } else { if ($Nams[$j] == 'author') { if (isset($edit) && $edit) { $output = $Fild[$j]; } else { if (!isset($GLOBALS['pixie_user'])) { $GLOBALS['pixie_user'] = NULL; } $output = $GLOBALS['pixie_user']; } echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"" . $output . "\" maxlength=\"" . $Leng[$j] . "\" />\n"; } else { if ($Type[$j] == "timestamp") { echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"" . returnSQLtimestamp(time()) . "\" maxlength=\"" . $Leng[$j] . "\" />\n"; } else { if ($Nams[$j] == 'page_type') { if ($type) { $output = $type; } else { if (isset($edit)) { $output = safe_field('page_type', 'pixie_core', "page_id='{$edit}'"); } } echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"" . $output . "\" maxlength=\"" . $Leng[$j] . "\" />\n"; } else { if ($Nams[$j] == 'publish' && !$edit) { echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"yes\" maxlength=\"0\" />\n"; } else { if ($Nams[$j] == 'page_content') { // do nothing } else { if ($Nams[$j] == 'admin') { // do nothing } else { echo "\t\t\t\t\t\t\t<input type=\"hidden\" class=\"form_text\" name=\"{$Nams[$j]}\" value=\"{$Fild[$j]}\" maxlength=\"" . $Leng[$j] . "\" />\n"; } } } } } } } } } } if (isset($edit) && $edit) { echo "\t\t\t\t\t\t\t<div class=\"form_row_button\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" name=\"submit_edit\" class=\"form_submit\" value=\"" . $lang['form_button_update'] . "\" />\n\t\t\t\t\t\t\t</div>\n"; } else { if (isset($go) && $go == 'new') { // do a save draft and save button button?? - when everything can be saved as a draft and is autosaved using AJAX } else { echo "\t\t\t\t\t\t\t<div class=\"form_row_button\" id=\"form_button\">\n\t\t\t\t\t\t\t\t<input type=\"submit\" name=\"submit_new\" class=\"form_submit\" value=\"" . $lang['form_button_save'] . "\" />\n\t\t\t\t\t\t\t</div>\n"; } } if ($m != 'static') { echo "\t\t\t\t\t\t\t<div class=\"form_row_button\">\n\t\t\t\t\t\t\t\t<span class=\"form_button_cancel\"><a href=\"?s={$s}&m={$m}&x={$x}\" title=\"" . $lang['form_button_cancel'] . "\">" . $lang['form_button_cancel'] . "</a></span>\n\t\t\t\t\t\t\t</div>\n"; } echo "\t\t\t\t\t\t\t<div class=\"safclear\"></div>\n\t\t\t\t\t\t</fieldset>\n"; echo "\t\t\t\t\t</form>"; } }