--- inc/newsEdit.php 2001/09/03 15:52:15 1.6 +++ inc/newsEdit.php 2001/09/19 12:23:57 1.7 @@ -1,4 +1,5 @@ [SQL] $sql
\n"; + #echo "[SQL] $sql
\n"; } - function newsEdit($art, $trigger = "") { - global $phptmp, $picdir, $syspicdir, $section, $section_menu, $dbh, $tpl; - global $ed_id, $ed_cat; + function my_cmp($a, $b) { return MyCompare($a["txt"], $b["txt"]); } + function newsEdit($art, $trigger = "", $isVijest = false) { + global $phptmp, $picdir, $syspicdir, $aupicdir, $sysaupicdir, $section, $section_menu, $dbh, $tpl; + global $ed_id, $ed_cat, $isMed; $i = 1; global $ed_delete_main, $ed_del_main; $delete_main = $ed_delete_main; $del_main = $ed_del_main; global $ed_clear_main, $ed_clr_main; + global $ed_clear_author, $ed_clr_author; $clear_main = $ed_clear_main; $clr_main = $ed_clr_main; + $clear_author = $ed_clear_author; + $clr_author = $ed_clr_author; global $ed_titlepic_url, $ed_titlepic_url2, $ed_titlepic_name; $titlepic_url = $ed_titlepic_url; $titlepic_url2 = $ed_titlepic_url2; - $titlepic_name = $ed_titlepic_name; + $titlepic_name = urldecode($ed_titlepic_name); + # Fix for M$IE if ($titlepic_url == "none") $titlepic_url = ""; + global $ed_author_url, $ed_author_url2, $ed_author_name; + $author_url = $ed_author_url; + $author_url2 = $ed_author_url2; + $author_name = urldecode($ed_author_name); + # Fix for M$IE + if ($author_url == "none") $author_url = ""; while (true) { global ${"ed_text_id_".$i}; if (!isset(${"ed_text_id_".$i})) break; @@ -37,14 +49,36 @@ global ${"ed_clear_".$i}, ${"ed_clr_".$i}; ${"clear_".$i} = ${"ed_clear_".$i}; ${"clr_".$i} = ${"ed_clr_".$i}; - global ${"ed_textpic_url_".$i}, - ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i}; + global ${"ed_textpic_url_".$i}, ${"ed_textpic_url2_".$i}, ${"ed_textpic_name_".$i}; ${"textpic_url_".$i} = ${"ed_textpic_url_".$i}; ${"textpic_url2_".$i} = ${"ed_textpic_url2_".$i}; - ${"textpic_name_".$i} = ${"ed_textpic_name_".$i}; + ${"textpic_name_".$i} = urldecode(${"ed_textpic_name_".$i}); + # Fix for M$IE if (${"textpic_url_".$i} == "none") ${"textpic_url_".$i} = ""; $i++; } + // ----- + $categories = array(); + $sql = "SELECT cat_id, text FROM news_categories ORDER BY text"; +sql($sql); + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + while ($row = $sth->fetchrow_array()) array_push($categories, + array("id" => $row[0], "txt" => $row[1])); + $sth->finish(); + usort($categories, "my_cmp"); + // ----- + $specs = array(); + $sql = "SELECT spec_id, opis FROM specijalizacije WHERE (NOT link)"; +sql($sql); + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + while ($row = $sth->fetchrow_array()) array_push($specs, array("id" => $row[0], "txt" => $row[1])); + $sth->finish(); + usort($specs, "my_cmp"); + // ----- global $cancel, $save; if ($cancel || $save) { if ($save) { @@ -60,22 +94,36 @@ $row = array_shift($row); if ($row) MyDelete($syspicdir."/".$row); } + if (ereg("$phptmp", $author_url2) && $ed_id > 0) { + $sql = "SELECT author_pic FROM news WHERE (news_id = $ed_id)"; +sql($sql); + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + $row = $sth->fetchrow_array(); + $sth->finish(); + $row = array_shift($row); + if ($row) MyDelete($sysaupicdir."/".$row); + } global $ed_title, $ed_lead, $ed_titlepic_alt, $ed_titlepic_pos, $ed_more, $ed_more_title, - $ed_cat; + $ed_cat, $ed_author_alt, $ed_author_info; $ed_title = MyQuote($ed_title); $ed_lead = MyQuote($ed_lead); - $ed_titlepic_nm = MyQuote(basename($titlepic_name)); + $ed_author_nm = urldecode(MyQuote(basename($author_name))); + $ed_author_alt = MyQuote($ed_author_alt); + $ed_author_info = MyQuote($ed_author_info); + $ed_titlepic_nm = urldecode(MyQuote(basename($titlepic_name))); $ed_titlepic_alt = MyQuote($ed_titlepic_alt); $ed_more = MyQuote($ed_more); $ed_more_title = MyQuote($ed_more_title); if (!$ed_titlepic_pos) $ed_titlepic_pos = 0; if ($ed_id > 0) { - $sql = "UPDATE news SET category = '$ed_cat', title = $ed_title, lead = $ed_lead, title_pic = $ed_titlepic_nm, title_alt = $ed_titlepic_alt, title_pos = $ed_titlepic_pos, url = $ed_more, url_title = $ed_more_title, date = CURRENT_TIMESTAMP WHERE (news_id = $ed_id)"; + $sql = "UPDATE news SET category = '$ed_cat', title = $ed_title, lead = $ed_lead, title_pic = $ed_titlepic_nm, title_alt = $ed_titlepic_alt, title_pos = $ed_titlepic_pos, author_pic = $ed_author_nm, author_alt = $ed_author_alt, author_info = $ed_author_info, url = $ed_more, url_title = $ed_more_title, plivamed = ".($isMed?"true":"false").", d_change = NOW() WHERE (news_id = $ed_id)"; sql($sql); $dbh->dbh_do($sql); } else { - $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, url, url_title, date) VALUES ('$ed_cat', $ed_title, $ed_lead, $ed_titlepic_nm, $ed_titlepic_alt, $ed_titlepic_pos, $ed_more, $ed_more_title, CURRENT_TIMESTAMP)"; + $sql = "INSERT INTO news (category, title, lead, title_pic, title_alt, title_pos, author_pic, author_alt, author_info, url, url_title, plivamed, d_orig, d_change) VALUES ('$ed_cat', $ed_title, $ed_lead, $ed_titlepic_nm, $ed_titlepic_alt, $ed_titlepic_pos, $ed_author_nm, $ed_author_alt, $ed_author_info, $ed_more, $ed_more_title, ".($isMed?"true":"false").", NOW(), NOW())"; sql($sql); $dbh->dbh_do($sql); $sql = "SELECT news_id FROM news WHERE (title = $ed_title)"; @@ -90,19 +138,21 @@ if (is_array($row)) $row = array_shift($row); if ($row) $ed_id = $row; } - if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", "$syspicdir/$titlepic_name"); + if ($titlepic_url2) MyMove("$syspicdir/$titlepic_url2", urldecode("$syspicdir/$titlepic_name")); + if ($author_url2) MyMove("$sysaupicdir/$author_url2", urldecode("$sysaupicdir/$author_name")); $i = 1; while ($ed_id > 0 && isset(${"ed_text_id_".$i})) { global ${"ed_text_title_".$i}, ${"ed_text_".$i}, ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, - ${"ed_text_level_".$i}; - list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev) = array( + ${"ed_text_level_".$i}, ${"ed_hl_".$i}; + list($id, $tit, $txt, $pic, $orig, $alt, $pos, $del, $lev, $hl) = array( ${"ed_text_id_".$i}, ${"ed_text_title_".$i}, ${"ed_text_".$i}, ${"textpic_url2_".$i}, ${"textpic_name_".$i}, ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, - ${"del_".$i}, ${"ed_text_level_".$i}); + ${"del_".$i}, ${"ed_text_level_".$i}, ${"ed_hl_".$i}); $tit = MyQuote($tit); $txt = MyQuote($txt); + $hl = MyQuote($hl); $orig = basename($orig); $org = MyQuote($orig); $alt = MyQuote($alt); @@ -121,11 +171,11 @@ $sth->finish(); } if ($del) $sql = "DELETE FROM paragraphs WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; - else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, pic = $org, alt = $alt, pos = $pos WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; + else $sql = "UPDATE paragraphs SET title = $tit, level = $lev, text = $txt, hl = $hl, pic = $org, alt = $alt, pos = $pos WHERE (news_id = $ed_id) AND (paragraph_id = $id)"; sql($sql); $dbh->dbh_do($sql); } else if (!$del) { - $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos)"; + $sql = "INSERT INTO paragraphs (news_id, title, level, text, pic, alt, pos, hl) VALUES ($ed_id, $tit, $lev, $txt, $org, $alt, $pos, $hl)"; sql($sql); $dbh->dbh_do($sql); $sql = "SELECT paragraph_id FROM paragraphs WHERE (text = $txt)"; @@ -143,10 +193,33 @@ if ($pic) MyMove("$syspicdir/$pic", "$syspicdir/$orig"); $i++; } + if ($ed_id) { + $sql = "DELETE FROM spec_news WHERE (news_id = $ed_id)"; +sql($sql); + $dbh->dbh_do($sql); + for ($k = 0; $k < count($specs); $k++) { + $var = "ed_spec_".$specs[$k]["id"]; global $$var; + if (!$$var) continue; + $sql = "INSERT INTO spec_news (news_id, spec_id) VALUES ($ed_id, ".$specs[$k]["id"].")"; +sql($sql); + $dbh->dbh_do($sql); + } + $sql = "DELETE FROM cat_news WHERE (news_id = $ed_id)"; +sql($sql); + $dbh->dbh_do($sql); + for ($k = 0; $k < count($categories); $k++) { + $var = "ed_cat_".$categories[$k]["id"]; + global $$var; + if (!$$var) continue; + $sql = "INSERT INTO cat_news (news_id, cat_id) VALUES ($ed_id, '".$categories[$k]["id"]."')"; +sql($sql); + $dbh->dbh_do($sql); + } + } } else { // Delete temp pics. - if (ereg("$phptmp", $titlepic_url2)) - MyDelete($syspicdir."/".$titlepic_url2); + if (ereg("$phptmp", $titlepic_url2)) MyDelete($syspicdir."/".$titlepic_url2); + if (ereg("$phptmp", $author_url2)) MyDelete($sysaupicdir."/".$author_url2); $i = 1; while (isset(${"ed_textpic_id_".$i})) { $tmp = ${"textpic_url2_".$i}; @@ -170,14 +243,22 @@ if ($tname == "none") continue; $nm = basename($tname); $ext = ereg_replace('^.*(\..+)$', '\1', $name); - move_uploaded_file($tname, $syspicdir."/".$nm.$ext); if ($key == "ed_titlepic_url") { + move_uploaded_file($tname, $syspicdir."/".$nm.$ext); $titlepic_url = $nm.$ext; $titlepic_name = $name; $u = $titlepic_url2; if (ereg("$phptmp", $u)) MyDelete($syspicdir."/".$u); unset($clear_main, $clr_main); + } else if ($key == "ed_author_url") { + move_uploaded_file($tname, $sysaupicdir."/".$nm.$ext); + $author_url = $nm.$ext; + $author_name = $name; + $u = $author_url2; + if (ereg("$phptmp", $u)) MyDelete($sysaupicdir."/".$u); + unset($clear_author, $clr_author); } else if (ereg("^ed_textpic_url_([1-9][0-9]*)$", $key, $regs)) { + move_uploaded_file($tname, $syspicdir."/".$nm.$ext); $n = $regs[1]; ${"textpic_url_".$n} = $nm.$ext; ${"textpic_name_".$n} = $name; @@ -191,16 +272,6 @@ // ----- $tp = new Smarty(); // ----- - $categories = array(); - $sql = "SELECT cat_id, text FROM news_categories ORDER BY text"; -sql($sql); - $sth = $dbh->prepare($sql); - if (!$sth) error("Cannot prepare query: \"$sql\""); - if (!$sth->execute()) error("Cannot execute query: \"$sql\""); - while ($row = $sth->fetchrow_array()) array_push($categories, array("id" => $row[0], "txt" => $row[1])); - $sth->finish(); - $tp->assign("categories", $categories); - // ----- $levels = array(); $sql = "SELECT level_id, class, name FROM par_levels ORDER BY name"; sql($sql); @@ -213,7 +284,8 @@ // ----- global $ed_id, $ed_title, $ed_lead, $ed_titlepic_pos, $ed_titlepic_alt, $ed_cat, $ed_more, - $ed_more_title; + $ed_more_title, $ed_author_url, $ed_author_alt, + $ed_author_info; global $ed_edit, $ed_preview, $preview, $add; if (!$ed_preview) $ed_preview = ($preview ? true : false); if ($ed_edit) $ed_preview = false; @@ -221,20 +293,36 @@ $delete = count(preg_grep('/^ed_delete_[0-9]+$/', array_keys(array_merge($HTTP_GET_VARS, $HTTP_POST_VARS)))) > 0; - $clear = (count(preg_grep('/^ed_clear_(main|[0-9]+)$/', + global $ed_clear_author; + $clear = (count(preg_grep('/^ed_clear_(main|author|[0-9]+)$/', array_keys(array_merge($HTTP_GET_VARS, $HTTP_POST_VARS)))) > 0); $ed_pgfs = array(); $ed_warning = 0; + $nspecs = array(); + $ncats = array(); + // Transfer data if ($ed_edit || $ed_preview || $add || $delete || $clear) { + for ($i = 0; $i < count($specs); $i++) { + $var = "ed_spec_".$specs[$i]["id"]; + global $$var; + $nspecs[$specs[$i]["id"]] = $$var ? true : false; + } + for ($i = 0; $i < count($categories); $i++) { + $var = "ed_cat_".$categories[$i]["id"]; + global $$var; + $ncats[$categories[$i]["id"]] = $$var ? true : false; + } global $ed_title, $ed_lead, $ed_titlepic_pos, $ed_titlepic_alt, $ed_cat, $ed_more, - $ed_more_title; + $ed_more_title, $ed_author_url, + $ed_author_alt, $ed_author_info; if (!$HTTP_POST_FILES["ed_titlepic_url"]["name"]) $titlepic_url = ""; if (!$titlepic_url) $titlepic_url = $titlepic_url2; - if (!$titlepic_url && !($clear_main || $clr_main)) - $titlepic_url = $art["pic_url"]; + if (!$titlepic_url && !($clear_main || $clr_main)) $titlepic_url = $art["pic_url"]; + if (!$author_url && !($clear_author || $clr_author)) $author_url = $art["au_pic"]; list($width, $height) = PicSize($titlepic_url); + list($width2, $height2) = PicSize($author_url, $sysaupicdir); global $ed_title_force; if ($titlepic_url && !$ed_titlepic_pos && !$ed_title_force) $ed_warning = 2; $i = 1; @@ -242,7 +330,7 @@ $id = ${"ed_text_id_".$i}; global ${"ed_text_".$i}, ${"ed_text_title_".$i}, ${"ed_text_level_".$i}, ${"ed_textpic_alt_".$i}, - ${"ed_textpic_pos_".$i}; + ${"ed_textpic_pos_".$i}, ${"ed_hl_".$i}; $pic_url = ($HTTP_POST_FILES["ed_textpic_url_".$i]["name"]) ? ${"textpic_url_".$i} : ""; if (!$pic_url) $pic_url = ${"textpic_url2_".$i}; @@ -258,32 +346,63 @@ ${"ed_text_".$i}, ${"ed_text_title_".$i}, $level, $class, $pic_url, ${"textpic_name_".$i}, ${"ed_textpic_alt_".$i}, ${"ed_textpic_pos_".$i}, - false)); + 0, 0, ${"ed_hl_".$i}, false)); $i++; } } else { + if ($ed_id) { + $sql = "SELECT spec_id FROM spec_news WHERE (news_id = $ed_id)"; +sql($sql); + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + while ($row = $sth->fetchrow_array()) $nspecs[$row[0]] = true; + $sth->finish(); + $sql = "SELECT cat_id FROM cat_news WHERE (news_id = $ed_id)"; +sql($sql); + $sth = $dbh->prepare($sql); + if (!$sth) error("Cannot prepare query: \"$sql\""); + if (!$sth->execute()) error("Cannot execute query: \"$sql\""); + while ($row = $sth->fetchrow_array()) $ncats[$row[0]] = true; + $sth->finish(); + } list($ed_title, $ed_lead, $ed_titlepic_pos, $titlepic_url, $titlepic_url2, $titlepic_name, $ed_titlepic_alt, - $ed_cat, $ed_more, $ed_more_title, $width, $height) = + $ed_cat, $ed_more, $ed_more_title, $width, $height, + $author_url, $author_url2, $author_name, + $ed_author_alt, $ed_author_info, $width2, $height2) = array($art["title"], $art["lead"], $art["pic_pos"], - $art["pic_url"], $art["pic_url"], $art["pic_url"], + $art["pic_url"], $art["pic_url"], urldecode($art["pic_url"]), $art["pic_alt"], $art["category"], $art["more"], - $art["more_title"], $art["pic_w"], $art["pic_h"]); + $art["more_title"], $art["pic_w"], $art["pic_h"], + $art["au_pic"], $art["au_pic"], urldecode($art["au_pic"]), + $art["au_alt"], $art["au_info"], $art["au_w"], $art["au_h"]); while ($art["text"] && list($id, $val) = each($art["text"])) { list($id, $txt, $title, $lev, $cls, $pic, $alt, $pos, $w, $h) = array( $val["id"], $val["text"], $val["title"], $val["level"], - $val["class"], $val["pic"], $val["alt"], $val["pos"], + $val["class"], urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"], $val["h"]); - array_push($ed_pgfs, array($id, $txt, $title, $lev, $cls, $pic, $pic, $alt, - $pos, $w, $h, false)); + array_push($ed_pgfs, array($val["id"], $val["text"], $val["title"], + $val["level"], $val["class"], urldecode($val["pic"]), + urldecode($val["pic"]), $val["alt"], $val["pos"], $val["w"], + $val["h"], $val["hl"], false)); } $ed_id = $art["id"]; if (!$ed_id) $ed_id = -1; } + $ncats[$ed_cat] = true; + for ($i = 0; $i < count($specs); $i++) $specs[$i]["check"] = $nspecs[$specs[$i]["id"]]; + for ($i = 0; $i < count($categories); $i++) $categories[$i]["check"] = $ncats[$categories[$i]["id"]]; + $tp->assign("specs", $specs); + $tp->assign("categories", $categories); + if ($ed_more && !strstr($ed_more, "://")) { + $pos = strpos($ed_more, "?"); + if ($pos === false || $pos != 0) $ed_more = "http://".$ed_more; + } if ($add) { global $add_num; for ($i = 0; $i < intval($add_num); $i++) - array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", 0, 0, 0, true)); + array_push($ed_pgfs, array(-1, "", "", -1, "", "", "", "", 0, 0, 0, "", true)); } $ed_empty = ($ed_title || $ed_lead || $ed_titlepic_pos || $ed_more) ? false : true; $ed_text = array(); @@ -291,23 +410,32 @@ $ed_warnings = ($ed_warning ? true : false); $i = 1; while (list($key, $val) = each($ed_pgfs)) { - list($id, $txt, $tit, $lev, $cls, $pic, $name, $alt, $pos, $w, $h, $new) = $val; + list($id, $txt, $tit, $lev, $cls, $pic, $name, $alt, $pos, $w, $h, $hl, $new) = $val; $del = ((${"delete_".$i} || ${"del_".$i}) ? true : false); array_push($ed_records, array("val" => $del, "id" => $id)); if ($del) { $i++; continue; } $picurl = ${"textpic_url_".$id}; if (!$picurl) $picurl = $pic; $class = ""; - while (list($key, $val) = each($levels)) - if ($val["id"] == $lev) $class = $val["class"]; + while (list($key, $val) = each($levels)) if ($val["id"] == $lev) $class = $val["class"]; if ((${"clear_".$i} || ${"clr_".$i}) && $ed_preview && (${"textpic_name_".$i} != ${"textpic_url2_".$i})) { $tmp = ${"textpic_url2_".$i}; if (ereg("$phptmp", $tmp)) MyDelete($syspicdir."/".$tmp); $picurl = ${"textpic_url_".$i} = ${"textpic_url2_".$i} = $name = ""; } if (!$name) $name = $picurl; - $txt = MyEscape(convert_html($txt)); + $txt = MyEscape(convert_html($txt), false); $txt2 = ParseNewline($txt, true); + $txt3 = str_replace("&", "&", $txt); + $txt3 = str_replace("\"", """, $txt3); + $txt3 = str_replace("<", "<", $txt3); + $txt3 = str_replace(">", ">", $txt3); + $hl = MyEscape(convert_html($hl), false); + $hl2 = ParseNewline($hl, true); + $hl3 = str_replace("&", "&", $hl); + $hl3 = str_replace("\"", """, $hl3); + $hl3 = str_replace("<", "<", $hl3); + $hl3 = str_replace(">", ">", $hl3); global ${"ed_text_force_".$i}; $force = ${"ed_text_force_".$i}; $empty = (($ed_preview && !$txt && !$pos && !$new) ? true : false); @@ -321,6 +449,10 @@ "n" => $i, "txt" => $txt2, "txt2" => $txt, + "txt3" => $txt3, + "hl" => $hl2, + "hl2" => $hl, + "hl3" => $hl3, "title" => MyEscape(convert_html($tit)), "level" => $lev, "class" => MyEscape(convert_html($class)), @@ -349,15 +481,34 @@ $tp->assign("ed_titlepic_alt", MyEscape(convert_html($ed_titlepic_alt))); $tp->assign("ed_titlepic_width", $width); $tp->assign("ed_titlepic_height", $height); + $tp->assign("ed_author_url", MyEscape(convert_html($author_url))); + $tp->assign("ed_author_url2", MyEscape(convert_html($author_url2))); + $tp->assign("ed_author_name", MyEscape(convert_html($author_name))); + $tp->assign("ed_author_alt", MyEscape(convert_html($ed_author_alt))); + $tp->assign("ed_author_info", MyEscape(convert_html($ed_author_info))); + $tp->assign("ed_author_width", $width2); + $tp->assign("ed_author_height", $height2); $tp->assign("ed_more", MyEscape($ed_more)); + $tp->assign("ed_more_new", strstr($ed_more, "://") ? true : false); $tp->assign("ed_more_title", MyEscape($ed_more_title)); $tp->assign("ed_clr_main", ($clear_main || $clr_main || !$titlepic_url) ? true : false); + $tp->assign("ed_clr_author", ($clear_author || $clr_author || !$author_url) ? true : false); $tp->assign("ed_text", $ed_text); $tp->assign("ed_empty", $ed_empty); $tp->assign("ed_warning", $ed_warning); $tp->assign("ed_warnings", $ed_warnings); $tp->assign("ed_records", $ed_records); $tp->assign("newspicdir", "$picdir/"); + $tp->assign("aupicdir", "$aupicdir/"); + $tp->assign("vijest", $isVijest ? true : false); + if ($ed_preview) { + include_once("author.php"); + $tp->assign("AUTHOR", GetAuthor(MyEscape(convert_html($author_url)), + MyEscape(convert_html($ed_author_alt)), + MyEscape(convert_html($ed_author_info)), + $width2, $height2)); + } + $tp->assign("med", $isMed ? true : false); $params = array(); if ($section) array_push($params, "section=$section"); if ($section_menu) array_push($params, "section_menu=$section_menu"); @@ -366,8 +517,10 @@ if ($trigger) array_push($params, "$trigger=1"); global $PHP_SELF; $tp->assign("FORM_ACTION", $PHP_SELF.HTMLSpecialChars("?".implode("&", $params))); - global $onload; - $onload .= "document.forms[0].elements[0].focus();"; + if (!$ed_preview) { + global $onload; + $onload .= "document.forms[0].elements[0].focus();"; + } return $tp->fetch("edit.tpl"); } ?>