diff options
author | deva <deva> | 2009-04-25 09:36:19 +0000 |
---|---|---|
committer | deva <deva> | 2009-04-25 09:36:19 +0000 |
commit | 13426bcaab9cdbeebd9ac85fad5fe9fd0e8cbc5a (patch) | |
tree | fa356b28f623836251423e16ef071852c1d56bc6 | |
parent | 9854238d0d44ea269d97509d6d35f49d3b46e834 (diff) |
New ImageComboBox. Added icons to news.
-rw-r--r-- | utils/forms.php | 20 | ||||
-rw-r--r-- | utils/modules/news.php | 46 |
2 files changed, 42 insertions, 24 deletions
diff --git a/utils/forms.php b/utils/forms.php index 8f2238e..3d1050a 100644 --- a/utils/forms.php +++ b/utils/forms.php @@ -209,22 +209,22 @@ class ImageComboBox { public function render($indent = "") { + $width = 64; $str = $indent . "<div class=\"input\">\n"; $str .= $indent . " <div class=\"label\">".$this->label."</div>\n"; $str .= $indent . " <div class=\"widget\">\n"; - $str .= $indent . " <select name=\"vars[".$this->name."]\">\n"; + $str .= $indent . " <div style=\"width:200px;overflow:scroll;\">\n"; + $str .= $indent . " <div style=\"width:".($width + 6)*sizeof($this->values)."px;\">\n"; + $str .= $indent . " <input id=\"".$this->name."\" name=\"vars[".$this->name."]\" type=\"hidden\" value=\"".$this->value."\"/>\n"; foreach($this->values as $k => $v) { - $str .= $indent . " <optgroup style=\"background-image: url(".$v."); height: 100px; width: 100px;\"/>\n"; - $str .= $indent . " <option value=\"".$k."\""; - if($v == $value) $str .= " selected"; - $str .=">".$k."</option>\n"; - $str .= $indent . " </optgroup>\n"; + $str .= $indent . " <img src=\"".$v."\" style=\"max-width:".$width."px;\"\n"; + $str .= $indent . " onclick=\"document.getElementById('".$this->name."').value='".$v."'\"/>\n"; } - - $str .= $indent . " </select>\n"; - $str .= $indent . " </div>\n"; - $str .= $indent . "</div>\n"; + $str .= $indent . " </div>\n"; // box + $str .= $indent . " </div>\n"; // overflow + $str .= $indent . " </div>\n"; // widget + $str .= $indent . "</div>\n"; // input return $str; } } diff --git a/utils/modules/news.php b/utils/modules/news.php index 52b8112..9667e44 100644 --- a/utils/modules/news.php +++ b/utils/modules/news.php @@ -10,6 +10,7 @@ class NewsEntry { public $description; public $category; public $userid; + public $icon; public function show() { @@ -21,8 +22,10 @@ class NewsEntry { htmlspecialchars_decode($this->title, ENT_QUOTES) . "</div>\n"; $str .= " <div class=\"news_time\">" . date("D M jS Y G:i", $this->time) . "</div>\n"; $str .= " <div class=\"news_user\">By: " . $users->findUser($this->userid)->userid . "</div>\n"; - $str .= " <div class=\"news_description\">" . - htmlspecialchars_decode($this->description, ENT_QUOTES) . "</div>\n"; + $str .= " <div class=\"news_description\">\n"; + if($this->icon) $str .= " <img alt=\"icon\" class=\"news_icon\" src=\"" . $this->icon . "\"/>\n"; + $str .= " ".htmlspecialchars_decode($this->description, ENT_QUOTES) . "\n"; + $str .= " </div>\n"; $str .= "</div>\n"; return $str; } @@ -34,6 +37,7 @@ class NewsEntry { fwrite($fp, " time=\"" . $this->time . "\"\n"); fwrite($fp, " category=\"" . $this->category . "\"\n"); fwrite($fp, " userid=\"" . $this->userid . "\"\n"); + fwrite($fp, " icon=\"" . $this->icon . "\"\n"); fwrite($fp, " description=\"" . htmlspecialchars($this->description, ENT_QUOTES, "UTF-8") . "\">\n"); fwrite($fp, " </newsentry>\n"); @@ -44,13 +48,14 @@ class NewsEntry { return $this->title; } - public function NewsEntry($title, $time, $category, $description, $userid) + public function NewsEntry($title, $time, $category, $description, $userid, $icon) { $this->title = $title; $this->time = $time; $this->category = $category; $this->description = $description; $this->userid = $userid; + $this->icon = $icon; } } @@ -72,7 +77,7 @@ class News { switch($action) { case "add": $n = new NewsEntry($vars["title"], DateTimeEdit::toTimestamp($vars, "time"), - $vars["category"], $vars["description"], $UID); + $vars["category"], $vars["description"], $UID, $vars["icon"]); echo "\"" .$n->title . "\" has now been added."; $this->add($n); $this->write(); @@ -80,7 +85,7 @@ class News { case "preview": $n = new NewsEntry($vars["title"], DateTimeEdit::toTimestamp($vars, "time"), - $vars["category"], $vars["description"], $UID); + $vars["category"], $vars["description"], $UID, $vars["icon"]); echo "<div class=\"preview\">\n"; echo "<div class=\"content\">\n"; echo $n->show(); @@ -104,18 +109,19 @@ class News { $category = $vars["category"]; $description = $vars["description"]; default: + $icons = array("http://www.executionroom.com/gfx/logos/die_logo_black_thumb.png", + "http://www.executionroom.com/gfx/logos/die_logo_bloody_thumb.png", + "http://www.executionroom.com/gfx/logos/die_logo_red_thumb_.png", + "http://www.executionroom.com/gfx/logos/die_logo_white_thumb.png", + "http://www.executionroom.com/gfx/die_group_2008_thumb.jpg", + "http://www.executionroom.com/gfx/die_group_thumb.jpg"); + $form = new Form("preview"); $form->addWidget(new LineEdit("Title", "title", $title)); $form->addWidget(new DateTimeEdit("Time", "time", $time)); $form->addWidget(new ComboBox("Category", "category", $category, array("Main" => "main", "Site" => "site"))); $form->addWidget(new TextEdit("Description", "description", $description)); - $form->addWidget(new ImageComboBox("Icon", "icon", $icon, - array("Logo1" => "http://www.executionroom.com/gfx/logos/die_logo_black_thumb.png", - "Logo2" => "http://www.executionroom.com/gfx/logos/die_logo_bloody_thumb.png", - "Logo3" => "http://www.executionroom.com/gfx/logos/die_logo_red_thumb_.png", - "Logo4" => "http://www.executionroom.com/gfx/logos/die_logo_white_thumb.png", - "Logo5" => "http://www.executionroom.com/gfx/die_group_2008_thumb.jpg", - "Logo6" => "http://www.executionroom.com/gfx/die_group_thumb.jpg"))); + $form->addWidget(new ImageComboBox("Icon", "icon", $icon, $icons)); $form->addWidget(new Button("Post news")); $form->render(); break; @@ -133,12 +139,13 @@ class News { $this->news[$vars["newsid"]]->time = DateTimeEdit::toTimestamp($vars, "time"); $this->news[$vars["newsid"]]->category = $vars["category"]; $this->news[$vars["newsid"]]->description = $vars["description"]; + $this->news[$vars["newsid"]]->icon = $vars["icon"]; $this->write(); echo "\"" . $this->news[$vars["newsid"]]->title . "\" has now been edited."; break; case "preview": - $n = new NewsEntry($vars["title"], DatetimeEdit::toTimestamp($vars, "time"), $vars["category"], $vars["description"], $UID); + $n = new NewsEntry($vars["title"], DatetimeEdit::toTimestamp($vars, "time"), $vars["category"], $vars["description"], $UID, $vars["icon"]); echo "<div class=\"preview\">\n"; echo "<div class=\"content\">\n"; echo $n->show(); @@ -158,6 +165,13 @@ class News { case "edit": case "retry": + $icons = array("http://www.executionroom.com/gfx/logos/die_logo_black_thumb.png", + "http://www.executionroom.com/gfx/logos/die_logo_bloody_thumb.png", + "http://www.executionroom.com/gfx/logos/die_logo_red_thumb_.png", + "http://www.executionroom.com/gfx/logos/die_logo_white_thumb.png", + "http://www.executionroom.com/gfx/die_group_2008_thumb.jpg", + "http://www.executionroom.com/gfx/die_group_thumb.jpg"); + if(isset($vars["title"])) $title = $vars["title"]; else $title = $this->news[$vars["newsid"]]->title; if(isset($vars["time_year"])) $time = DateTimeEdit::toTimestamp($vars, "time"); @@ -166,6 +180,8 @@ class News { else $category = $this->news[$vars["newsid"]]->category; if(isset($vars["description"])) $description = $vars["description"]; else $description = $this->news[$vars["newsid"]]->description; + if(isset($vars["icon"])) $icon = $vars["icon"]; + else $icon = $this->news[$vars["newsid"]]->icon; $form = new Form("preview"); $form->addWidget(new Hidden($vars)); @@ -174,6 +190,7 @@ class News { $form->addWidget(new ComboBox("Category", "category", $category, array("Main" => "main", "Site" => "site"))); $form->addWidget(new TextEdit("Description", "description", $description)); + $form->addWidget(new ImageComboBox("Icon", "icon", $icon, $icons)); $form->addWidget(new Button("Post news")); $form->render(); break; @@ -306,7 +323,8 @@ class News { $param->getAttribute('time'), $param->getAttribute('category'), $param->getAttribute('description'), - $param->getAttribute('userid')); + $param->getAttribute('userid'), + $param->getAttribute('icon')); $this->add($newsentry); } |