_files = array(); $this->_code = ''; $this->_events = array(); } /** * Adds a new file to the list of scripts * * @param string $filename The name of the file to include * @param bool $conditional_ie Whether to wrap the script tag in * conditional comments for IE * * @return void */ public function addFile($filename, $conditional_ie = false) { $link = PMA_includeJS($filename, $conditional_ie); if (! in_array($link, $this->_files)) { $this->_files[] = $link; } } /** * Adds a new code snippet to the code to be executed * * @param string $code The JS code to be added * * @return void */ public function addCode($code) { $this->_code .= "$code\n"; } /** * Adds a new event to the list of events * * @param string $event The name of the event to register * @param string $function The code to execute when the event fires * E.g: 'function () { doSomething(); }' * or 'doSomething' * * @return void */ public function addEvent($event, $function) { $this->_events[] = array( 'event' => $event, 'function' => $function ); } /** * Renders all the JavaScript file inclusions, code and events * * @return string */ public function getDisplay() { $retval = ''; foreach ($this->_files as $file) { $retval .= $file; } $retval .= ''; return $retval; } }