mirror of
				https://git.code.sf.net/p/seeddms/code
				synced 2025-10-31 13:18:06 +00:00 
			
		
		
		
	run hook preRun and postRun before and after the view
This commit is contained in:
		
							parent
							
								
									a6e4202132
								
							
						
					
					
						commit
						67f4ca35ee
					
				|  | @ -43,6 +43,7 @@ class SeedDMS_View_Common { | |||
| 	} | ||||
| 
 | ||||
| 	public function __invoke($get=array()) { | ||||
| 		$this->callHook('preRun', isset($get['action']) ? $get['action'] : 'show'); | ||||
| 		if(isset($get['action']) && $get['action']) { | ||||
| 			if(method_exists($this, $get['action'])) { | ||||
| 				$this->{$get['action']}(); | ||||
|  | @ -51,6 +52,7 @@ class SeedDMS_View_Common { | |||
| 			} | ||||
| 		} else | ||||
| 			$this->show(); | ||||
| 		$this->callHook('postRun', isset($get['action']) ? $get['action'] : 'show'); | ||||
| 	} | ||||
| 
 | ||||
| 	public function setParams($params) { | ||||
|  | @ -97,10 +99,17 @@ class SeedDMS_View_Common { | |||
| 	 * function returns | ||||
| 	 */ | ||||
| 	public function callHook($hook) { /* {{{ */ | ||||
| 		$tmps = array(); | ||||
| 		$tmp = explode('_', get_class($this)); | ||||
| 		$tmps[] = $tmp[2]; | ||||
| 		$tmp = explode('_', get_parent_class($this)); | ||||
| 		$tmps[] = $tmp[2]; | ||||
| 		/* Run array_unique() in case the parent class has the same suffix */ | ||||
| 		$tmps = array_unique($tmps); | ||||
| 		$ret = null; | ||||
| 		if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])])) { | ||||
| 			foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp[2])] as $hookObj) { | ||||
| 		foreach($tmps as $tmp) | ||||
| 		if(isset($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)])) { | ||||
| 			foreach($GLOBALS['SEEDDMS_HOOKS']['view'][lcfirst($tmp)] as $hookObj) { | ||||
| 				if (method_exists($hookObj, $hook)) { | ||||
| 					switch(func_num_args()) { | ||||
| 						case 1: | ||||
|  | @ -183,12 +192,12 @@ class SeedDMS_View_Common { | |||
| 		return false; | ||||
| 	} /* }}} */ | ||||
| 
 | ||||
| 	public function jsTranslations($keys) { | ||||
| 	public function jsTranslations($keys) { /* {{{ */ | ||||
| 		echo "var trans = {\n"; | ||||
| 		foreach($keys as $key) { | ||||
| 			echo "	'".$key."': '".str_replace("'", "\\\'", getMLText($key))."',\n"; | ||||
| 		} | ||||
| 		echo "};\n"; | ||||
| 	} | ||||
| 	} /* }}} */ | ||||
| } | ||||
| ?>
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Uwe Steinmann
						Uwe Steinmann