コード例 #1
0
 function zone_format()
 {
     $this->output->admin();
     $f = $this->input->f;
     $field_types = $this->default[field_types];
     // Loadup the zone
     $z = $this->db->getsql("SELECT * FROM adrev_zones WHERE id=?", array($f['id']));
     if (count($f[ad_format]) == 0) {
         $f[ad_format] = unserialize(stripslashes($z[0][ad_format]));
     }
     // Error finding zone
     if (!$z[0][id]) {
         $this->output->redirect(lib_lang("The zone could not be found"), "index.php?section=zone", 3);
         exit;
     }
     // Save the data
     if ($f[submit]) {
         // Cleanup the ad_format array();
         reset($f[ad_format]);
         $n = count($f[ad_format]);
         for ($x = 0; $x <= $n; $x++) {
             if (!$f[ad_format][$x][type]) {
                 unset($f[ad_format][$x]);
             }
         }
         $i = array();
         $i[ad_sort] = iif($z[0][rtype] == 2, "bid", $f[ad_sort]);
         $i[urls_target] = $f[urls_target];
         $i[urls_hide] = $f[urls_hide] ? 1 : 0;
         $i[urls_tracking] = $f[urls_tracking] ? 1 : 0;
         $i[ad_format] = serialize($f[ad_format]);
         $i[template] = trim(stripslashes($f[template]));
         $this->db->update("adrev_zones", "id", $f[id], $i);
         $this->output->redirect(lib_lang("Zone Format options were updated"), "index.php?section=zone&action=zone_format&f[id]={$f['id']}", 1);
         exit;
     }
     // Show the form
     $tpl = new XTemplate("templates/zone_format.html");
     $sortlist = array("asc" => lib_lang("Oldest at top"), "desc" => lib_lang("Newest at Top"), "rand" => lib_lang("Random"), "bid" => lib_lang("By Bid Price"));
     $tpl->assign("AD_SORT", lib_htlist_array($sortlist, $z[0][ad_sort]));
     $target = array("_self" => lib_lang("Open ad in same window"), "_new" => lib_lang("Open ad in new window"));
     $tpl->assign("URLS_TARGET", lib_htlist_array($target, $z[0][urls_target]));
     $tpl->assign("URLS_HIDE", $z[0][urls_hide] ? "CHECKED" : "");
     $tpl->assign("URLS_TRACKING", $z[0][urls_tracking] ? "CHECKED" : "");
     // Show the rows
     $row = 0;
     while (list($key, $val) = each($field_types)) {
         $row++;
         $tpl->assign("NAME", iif($f[ad_format][$row][name], $f[ad_format][$row][name], $val));
         $tpl->assign("TYPE", $key);
         $tpl->assign("ROW", $row);
         $tpl->assign("CHECKED", iif($f[ad_format][$row][type], "CHECKED", ""));
         $tpl->assign("BGCOLOR", iif($f[ad_format][$row][type], "#D2FFC4", "#FFFFFF"));
         // Non Image formats
         if ($key != "IMAGE") {
             $font = iif(!$f[ad_format][$row][font], "Verdana,Arial,Helvetica,sans-serif", $f[ad_format][$row][font]);
             $tpl->assign("FONT", "<input type=text name=\"f[ad_format][{$row}][font]\" value=\"{$font}\" size=10>");
             $size = iif(!$f[ad_format][$row][size], "1", $f[ad_format][$row][size]);
             $tpl->assign("SIZE", "<input type=text name=\"f[ad_format][{$row}][size]\" value=\"{$size}\" size=1>");
             $color = iif(!$f[ad_format][$row][color], "black", $f[ad_format][$row][color]);
             $tpl->assign("COLOR", "<input type=text name=\"f[ad_format][{$row}][color]\" value=\"{$color}\" size=6>");
             $bold = iif(!$f[ad_format][$row][bold], "", "CHECKED");
             $tpl->assign("BOLD", "<input type=checkbox name=\"f[ad_format][{$row}][bold]\" value=\"1\" {$bold}>");
             // Set some better default sizes
             $size = 20;
             if ($key == "TITLE") {
                 $size = 25;
             }
             if ($key == "DESCRIPTION") {
                 $size = 64;
             }
             if ($key == "URL") {
                 $size = 512;
             }
             if ($key == "DISPLAY_URL") {
                 $size = 25;
             }
             if ($key == "EMAIL") {
                 $size = 64;
             }
             if ($key == "PHONE") {
                 $size = 15;
             }
             if ($key == "FAX") {
                 $size = 15;
             }
             if ($key == "CONTENT") {
                 $size = 8192;
             }
             if (preg_match('/CUSTOM/', $key)) {
                 $size = 32;
             }
             $max_length = iif(!$f[ad_format][$row][max_length], $size, $f[ad_format][$row][max_length]);
             $tpl->assign("MAX_LENGTH", "<input type=text name=\"f[ad_format][{$row}][max_length]\" value=\"{$max_length}\" size=5>");
             $tpl->assign("MAX_UPLOAD", "&nbsp;");
             $tpl->assign("HEIGHT", "&nbsp;");
             $tpl->assign("WIDTH", "&nbsp;");
         } else {
             $tpl->assign("BOLD", "&nbsp;");
             $tpl->assign("COLOR", "&nbsp;");
             $tpl->assign("SIZE", "&nbsp;");
             $tpl->assign("FONT", "&nbsp;");
             $tpl->assign("MAX_LENGTH", "&nbsp;");
             $max_upload = iif(!$f[ad_format][$row][max_length], "65536", $f[ad_format][$row][max_length]);
             $tpl->assign("MAX_UPLOAD", "<input type=text name=\"f[ad_format][{$row}][max_length]\" value=\"{$max_upload}\" size=5>");
             $height = iif(!$f[ad_format][$row][height], "60", $f[ad_format][$row][height]);
             $tpl->assign("HEIGHT", "<input type=text name=\"f[ad_format][{$row}][height]\" value=\"{$height}\" size=4>");
             $width = iif(!$f[ad_format][$row][width], "480", $f[ad_format][$row][width]);
             $tpl->assign("WIDTH", "<input type=text name=\"f[ad_format][{$row}][width]\" value=\"{$width}\" size=4>");
         }
         $tpl->parse("main.formatlist");
     }
     // Grab the ad type for this zone
     $style = $z[0][style];
     $s = $this->db->getsql("SELECT * FROM adrev_ad_types WHERE id=?", array($style));
     $tpl->assign("FIELD_TYPES", lib_htlist_array($field_types, '0'));
     $tpl->assign("ID", $f[id]);
     $tpl->assign("ZONE_MENU", $this->zone_menu($f[id]));
     $tpl->assign("TEMPLATE", htmlentities(stripslashes($z[0][template]), ENT_QUOTES));
     // Preview the template
     $ad = $this->db->getsql("SELECT zid FROM adrev_ads WHERE zone=? LIMIT 1", array($f['id']));
     if (!$ad[0][zid]) {
         $tpl->assign("PREVIEW", lib_lang("You need to place at least one ad in this zone for a preview to be generated"));
     } else {
         include_once "modules/preview.php";
         $p = new preview();
         $p->main();
         $p->zid = $ad[0][zid];
         $preview = $p->display();
         $tpl->assign("PREVIEW", $preview);
     }
     $tpl->parse("main");
     $this->title = lib_lang("Manage") . " [" . stripslashes($z[0][name]) . "] : " . lib_lang("Format");
     $this->content = $tpl->text("main");
     $this->display();
     $this->printpage();
     exit;
 }