mySQLlanguage) ? $sql->mySQLlanguage : $pref['sitelanguage']; if (e_QUERY) { $tmp = explode(".", e_QUERY); $action = $tmp[0]; $sub_action = varset($tmp[1]); $id = intval(varset($tmp[2], 0)); $from = intval(varset($tmp[3], 0)); } if(isset($_POST['submitPage'])) { $page->submitPage(); } if(isset($_POST['uploadfiles'])) { $page->uploadPage(); $id = intval(varset($_POST['pe_id'], 0)); $sub_action = ($_POST['pe_id']) ? "edit" : ""; $page->createPage($_POST['mode']); } if(isset($_POST['submitMenu'])) { $page->submitPage("", TRUE); } if(isset($_POST['updateMenu'])) { $page->submitPage($_POST['pe_id'], TRUE); } if(isset($_POST['updatePage'])) { $page->submitPage($_POST['pe_id']); } if(isset($_POST['delete'])) { foreach(array_keys($_POST['delete']) as $pid) { $page->delete_page($pid); } } if (isset($_POST['saveOptions'])) { $page->saveSettings(); } if(!e_QUERY) { $page->showExistingPages(); } else { $function = $action."Page"; $page->$function(); } require_once(e_ADMIN."footer.php"); class page { function showExistingPages() { global $sql, $e107, $emessage; $text = "
".CUSLAN_5." "; if(!$sql->db_Select("page", "*", "ORDER BY page_datestamp DESC", "nowhere")) { $text .= " "; } else { $pages = $sql->db_getList('ALL', FALSE, FALSE); foreach($pages as $pge) { //title='".LAN_DELETE."' $title_text = $pge['page_title'] ? $pge['page_title'] : ($pge['page_theme'] ? CUSLAN_43.$pge['page_theme'] : CUSLAN_44); $text .= " "; } } $text .= "
".ID." ".CUSLAN_1." ".CUSLAN_2." ".CUSLAN_3."
".CUSLAN_42."
{$pge['page_id']} {$title_text} ".($pge['page_theme'] ? "menu" : "page")." ".ADMIN_EDIT_ICON."
"; $e107->ns->tablerender(CUSLAN_5, $emessage->render().$text); } function createmPage() { $this->createPage(TRUE); } function uploadPage() { global $pref; $pref['upload_storagetype'] = "1"; require_once(e_HANDLER."upload_handler.php"); $uploaded = file_upload(e_IMAGE."custom/"); } function createPage($mode=FALSE) { /* mode: FALSE == page, mode: TRUE == menu */ global $sql, $tp, $e107, $sub_action, $id, $frm, $e_userclass; $edit = ($sub_action == 'edit'); $caption =(!$mode ? ($edit ? CUSLAN_23 : CUSLAN_24) : ($edit ? CUSLAN_25 : CUSLAN_26)); if ($sub_action == "edit" && !isset($_POST['preview']) && !isset($_POST['submit'])) { $query = "SELECT p.*,l.link_name,m.menu_name FROM #page AS p LEFT JOIN #links AS l ON l.link_url='page.php?".$id."' LEFT JOIN #menus AS m ON m.menu_path='{$id}' WHERE p.page_id ='{$id}' LIMIT 1"; if ($sql->db_Select_gen($query)) { $row = $sql->db_Fetch(); $page_class = $row['page_class']; $page_password = $row['page_password']; $page_title = $tp->toForm($row['page_title']); $page_rating_flag = $row['page_rating_flag']; $page_comment_flag = $row['page_comment_flag']; $page_display_authordate_flag = $row['page_author']; $page_link = varset($row['link_name'],''); $data = $tp->toForm($row['page_text']); $edit = TRUE; $menu_name = $tp->toForm($row['menu_name']); } } $text = "
".CUSLAN_47." "; if($mode) // menu mode. { $text .= " "; } $text .= " "; if(!$mode) { $text .= "
".CUSLAN_7." ".$frm->text('menu_name', $menu_name, 50)."
".CUSLAN_8." ".$frm->text('page_title', $page_title, 250)."
".CUSLAN_9." "; require_once(e_HANDLER."ren_help.php"); $insertjs = (!e_WYSIWYG)? " rows='15' onselect='storeCaret(this);' onclick='storeCaret(this);' onkeyup='storeCaret(this);' style='width:95%'": "rows='25' style='width:100%' "; $data = $tp->toForm($data,FALSE,TRUE); // Make sure we convert HTML tags to entities $text .= ""; $text .= "
".display_help('cpage-help', 'cpage')."
".LAN_UPLOAD_IMAGES." ".$tp->parseTemplate("{UPLOADFILE=".e_IMAGE."custom/}")."
".CUSLAN_3." "; } $text .= "
".CUSLAN_10." ".$frm->radio_switch('page_rating_flag', $page_rating_flag)."
".CUSLAN_13." ".$frm->radio_switch('page_comment_flag', $page_comment_flag)."
".CUSLAN_41." ".$frm->radio_switch('page_display_authordate_flag', $page_display_authordate_flag)."
".CUSLAN_14." ".$frm->text('page_password', $page_password, 50)."
".CUSLAN_15."
".CUSLAN_16." ".$frm->text('page_link', $page_link, 50)."
".CUSLAN_17."
".CUSLAN_18." ".$e_userclass->uc_dropdown('page_class', $page_class, '', "tabindex='".$frm->getNext()."'")."
". (!$mode ? ($edit ? $frm->admin_button('updatePage', CUSLAN_19, 'update')."" : $frm->admin_button('submitPage', CUSLAN_20, 'create')) : ($edit ? $frm->admin_button('updateMenu', CUSLAN_21, 'update')."" : $frm->admin_button('submitMenu', CUSLAN_22, 'create'))) ."
"; $e107->ns->tablerender($caption, $text); } // Write new/edited page/menu to the DB // $mode - zero for new page, page id for existing // $type = FALSE for page, TRUE for menu function submitPage($mode = FALSE, $type=FALSE) { global $sql, $tp, $e107cache, $admin_log; $page_title = $tp->toDB($_POST['page_title']); $page_text = $tp->toDB($_POST['data']); $pauthor = ($_POST['page_display_authordate_flag'] ? USERID : 0); if ($mode) { // Don't think $_POST['page_ip_restrict'] is ever set. $update = $sql->db_Update("page", "page_title='{$page_title}', page_text='{$page_text}', page_author='{$pauthor}', page_rating_flag='".intval($_POST['page_rating_flag'])."', page_comment_flag='".intval($_POST['page_comment_flag'])."', page_password='".$_POST['page_password']."', page_class='".$_POST['page_class']."', page_ip_restrict='".varset($_POST['page_ip_restrict'],'')."' WHERE page_id='{$mode}'"); $admin_log->log_event('CPAGE_02',$mode.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,''); $e107cache->clear("page_{$mode}"); $e107cache->clear("page-t_{$mode}"); if($type) { $menu_name = $tp->toDB($_POST['menu_name']); // not to be confused with menu-caption. $sql->db_Update("menus", "menu_name='{$menu_name}' WHERE menu_path='{$mode}' "); $update++; } if ($_POST['page_link']) { if ($sql->db_Select("links", "link_id", "link_url='page.php?".$mode."' && link_name!='".$tp->toDB($_POST['page_link'])."'")) { $sql->db_Update("links", "link_name='".$tp->toDB($_POST['page_link'])."' WHERE link_url='page.php?".$mode."'"); $update++; $e107cache->clear("sitelinks"); } else if (!$sql->db_Select("links", "link_id", "link_url='page.php?".$mode."'")) { $sql->db_Insert("links", "0, '".$tp->toDB($_POST['page_link'])."', 'page.php?".$mode."', '', '', 1, 0, 0, 0, ".$_POST['page_class']); $update++; $e107cache->clear("sitelinks"); } } else { if ($sql->db_Select("links", "link_id", "link_url='page.php?".$mode."'")) { $sql->db_Delete("links", "link_url='page.php?".$mode."'"); $update++; $e107cache->clear("sitelinks"); } } admin_update($update, 'update', LAN_UPDATED, false, false); } else { // New page/menu $menuname = ($type ? $tp->toDB($_POST['menu_name']) : ""); admin_update($sql->db_Insert("page", "0, '{$page_title}', '{$page_text}', '{$pauthor}', '".time()."', '".intval($_POST['page_rating_flag'])."', '".intval($_POST['page_comment_flag'])."', '".$_POST['page_password']."', '".$_POST['page_class']."', '', '".$menuname."'"), 'insert', CUSLAN_27, LAN_CREATED_FAILED, false); $admin_log->log_event('CPAGE_01',$menuname.'[!br!]'.$page_title.'[!br!]'.$pauthor,E_LOG_INFORMATIVE,''); if($type) { $sql->db_Insert("menus", "0, '$menuname', '0', '0', '0', '', '".mysql_insert_id()."' "); } if($_POST['page_link']) { $link = "page.php?".mysql_insert_id(); if (!$sql->db_Select("links", "link_id", "link_name='".$tp->toDB($_POST['page_link'])."'")) { $linkname = $tp->toDB($_POST['page_link']); $sql->db_Insert("links", "0, '{$linkname}', '{$link}', '', '', 1, 0, 0, 0, ".$_POST['page_class']); $e107cache->clear("sitelinks"); } } } } function delete_page($del_id) { global $sql, $e107cache, $admin_log; admin_update($sql->db_Delete("page", "page_id='{$del_id}' "), 'delete', CUSLAN_28, false, false); $sql->db_Delete("menus", "menu_path='$del_id' "); $admin_log->log_event('CPAGE_03','ID: '.$del_id,E_LOG_INFORMATIVE,''); if ($sql->db_Select("links", "link_id", "link_url='page.php?".$del_id."'")) { $sql->db_Delete("links", "link_url='page.php?".$del_id."'"); $e107cache->clear("sitelinks"); } } function optionsPage() { global $e107, $pref, $frm, $emessage; if(!isset($pref['pageCookieExpire'])) $pref['pageCookieExpire'] = 84600; //XXX Lan - Options $text = "
".CUSLAN_3."
".CUSLAN_29." ".$frm->radio_switch('listPages', $pref['listPages'])."
".CUSLAN_30." ".$frm->text('pageCookieExpire', $pref['pageCookieExpire'], 10)."
".$frm->admin_button('saveOptions', CUSLAN_40, 'submit')."
"; $e107->ns->tablerender(CUSLAN_3, $emessage->render().$text); } function saveSettings() { global $pref, $admin_log, $emessage; $temp['listPages'] = $_POST['listPages']; $temp['pageCookieExpire'] = $_POST['pageCookieExpire']; if ($admin_log->logArrayDiffs($temp, $pref, 'CPAGE_04')) { save_prefs(); // Only save if changes $emessage->add(CUSLAN_45, E_MESSAGE_SUCCESS); } else { $emessage->add(CUSLAN_46); } } function show_options($action) { if ($action == "") { $action = "main"; } $var['main']['text'] = CUSLAN_11; $var['main']['link'] = e_SELF; $var['create']['text'] = CUSLAN_12; $var['create']['link'] = e_SELF."?create"; $var['createm']['text'] = CUSLAN_31; $var['createm']['link'] = e_SELF."?createm"; $var['options']['text'] = LAN_OPTIONS; $var['options']['link'] = e_SELF."?options"; e_admin_menu(CUSLAN_33, $action, $var); } } function cpage_adminmenu() { global $page; global $action; $page->show_options($action); } /** * Handle page DOM within the page header * * @return string JS source */ function headerjs() { require_once(e_HANDLER.'js_helper.php'); $ret = " "; return $ret; } ?>