ParseLinkTemplateEvent, and handlers for text_score, numeric_score and rating
git-svn-id: file:///home/shish/svn/shimmie2/trunk@611 7f39781d-f577-437e-ae19-be835c7a54ca
This commit is contained in:
		
							parent
							
								
									d880c8cac0
								
							
						
					
					
						commit
						ac2af2d1c0
					
				| @ -69,6 +69,10 @@ class NumericScore extends Extension { | ||||
| 			$sb->add_bool_option("numeric_score_anon", "Allow anonymous votes: "); | ||||
| 			$event->panel->add_block($sb); | ||||
| 		} | ||||
| 
 | ||||
| 		if(is_a($event, 'ParseLinkTemplateEvent')) { | ||||
| 			$event->replace('$score', $event->image->numeric_score); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private function install() { | ||||
|  | ||||
| @ -67,6 +67,10 @@ class Ratings extends Extension { | ||||
| 			$sb->add_choice_option("ext_rating_user_privs", $privs, "<br>Logged in: "); | ||||
| 			$event->panel->add_block($sb); | ||||
| 		} | ||||
| 
 | ||||
| 		if(is_a($event, 'ParseLinkTemplateEvent')) { | ||||
| 			$event->replace('$rating', $this->theme->rating_to_name($event->image->rating)); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private function install() { | ||||
|  | ||||
| @ -17,6 +17,15 @@ class RatingsTheme extends Themelet { | ||||
| 		";
 | ||||
| 		$page->add_block(new Block(null, $html, "main", 7)); | ||||
| 	} | ||||
| 
 | ||||
| 	public function rating_to_name($rating) { | ||||
| 		switch($rating) { | ||||
| 			case 's': return "Safe"; | ||||
| 			case 'q': return "Questionable"; | ||||
| 			case 'e': return "Explicit"; | ||||
| 			default: return "Unknown"; | ||||
| 		} | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
|  | ||||
| @ -69,6 +69,10 @@ class TextScore extends Extension { | ||||
| 			$sb->add_bool_option("text_score_anon", "Allow anonymous votes: "); | ||||
| 			$event->panel->add_block($sb); | ||||
| 		} | ||||
| 
 | ||||
| 		if(is_a($event, 'ParseLinkTemplateEvent')) { | ||||
| 			$event->replace('$text_score', $this->theme->score_to_name($event->image->text_score)); | ||||
| 		} | ||||
| 	} | ||||
| 
 | ||||
| 	private function install() { | ||||
|  | ||||
| @ -4,13 +4,7 @@ class TextScoreTheme extends Themelet { | ||||
| 	public function display_scorer($page, $image_id, $score) { | ||||
| 		$i_image_id = int_escape($image_id); | ||||
| 		 | ||||
| 		$words = array(); | ||||
| 		$words[-2] = "Delete"; | ||||
| 		$words[-1] = "Bad"; | ||||
| 		$words[ 0] = "Ok"; | ||||
| 		$words[ 1] = "Good"; | ||||
| 		$words[ 2] = "Favourite"; | ||||
| 		$s_score = $words[$score]; | ||||
| 		$s_score = $this->score_to_name($score); | ||||
| 		$html = " | ||||
| 			Current score is \"$s_score\" | ||||
| 			<br><form action='".make_link("text_score/vote")."' method='POST'> | ||||
| @ -25,6 +19,17 @@ class TextScoreTheme extends Themelet { | ||||
| 		";
 | ||||
| 		$page->add_block(new Block(null, $html, "main", 7)); | ||||
| 	} | ||||
| 
 | ||||
| 	public function score_to_name($score) { | ||||
| 		$words = array(); | ||||
| 		$words[-2] = "Delete"; | ||||
| 		$words[-1] = "Bad"; | ||||
| 		$words[ 0] = "Ok"; | ||||
| 		$words[ 1] = "Good"; | ||||
| 		$words[ 2] = "Favourite"; | ||||
| 		$s_score = $words[$score]; | ||||
| 		return $s_score; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| ?>
 | ||||
|  | ||||
							
								
								
									
										17
									
								
								core/events/parselinktemplate.event.php
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										17
									
								
								core/events/parselinktemplate.event.php
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,17 @@ | ||||
| <?php | ||||
| class ParseLinkTemplateEvent extends Event { | ||||
| 	var $link; | ||||
| 	var $original; | ||||
| 	var $image; | ||||
| 
 | ||||
| 	public function ParseLinkTemplateEvent($link, $image) { | ||||
| 		$this->link = $link; | ||||
| 		$this->original = $link; | ||||
| 		$this->image = $image; | ||||
| 	} | ||||
| 
 | ||||
| 	public function replace($needle, $replace) { | ||||
| 		$this->link = str_replace($needle, $replace, $this->link); | ||||
| 	} | ||||
| } | ||||
| ?>
 | ||||
| @ -155,6 +155,10 @@ class Image { | ||||
| 		$tmpl = str_replace('$filename', $_escape($base_fname), $tmpl); | ||||
| 		$tmpl = str_replace('$title', $_escape($config->get_string("title")), $tmpl); | ||||
| 
 | ||||
| 		$plte = new ParseLinkTemplateEvent($tmpl, $this); | ||||
| 		send_event($plte); | ||||
| 		$tmpl = $plte->link; | ||||
| 
 | ||||
| 		return $tmpl; | ||||
| 	} | ||||
| } | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user