/** * Call a template run-time helper. Do not call directly. * @param string helper name * @param array arguments * @return mixed */ public function __call($name, $args) { $lname = strtolower($name); if (!isset($this->helpers[$lname])) { foreach ($this->helperLoaders as $loader) { $helper = $loader->invoke($lname); if ($helper) { $this->registerHelper($lname, $helper); return $this->helpers[$lname]->invokeArgs($args); } } return parent::__call($name, $args); } return $this->helpers[$lname]->invokeArgs($args); }
function __call($name, $args) { $function = 'image' . $name; if (function_exists($function)) { foreach ($args as $key => $value) { if ($value instanceof self) { $args[$key] = $value->getImageResource(); } elseif (is_array($value) && isset($value['red'])) { $args[$key] = imagecolorallocatealpha($this->getImageResource(), $value['red'], $value['green'], $value['blue'], $value['alpha']); } } array_unshift($args, $this->getImageResource()); $res = call_user_func_array($function, $args); return is_resource($res) && get_resource_type($res) === 'gd' ? $this->setImageResource($res) : $res; } return parent::__call($name, $args); }
function __call($name, $args) { $name = strtolower($name); $silent = strncmp($name, 'try', 3) === 0; $func = $silent ? substr($name, 3) : $name; static $aliases = array('sslconnect' => 'ssl_connect', 'getoption' => 'get_option', 'setoption' => 'set_option', 'nbcontinue' => 'nb_continue', 'nbfget' => 'nb_fget', 'nbfput' => 'nb_fput', 'nbget' => 'nb_get', 'nbput' => 'nb_put'); $func = 'ftp_' . (isset($aliases[$func]) ? $aliases[$func] : $func); if (!function_exists($func)) { return parent::__call($name, $args); } NTools::tryError(); if ($func === 'ftp_connect' || $func === 'ftp_ssl_connect') { $this->state = array($name => $args); $this->resource = call_user_func_array($func, $args); $res = NULL; } elseif (!is_resource($this->resource)) { NTools::catchError($msg); throw new NFtpException("Not connected to FTP server. Call connect() or ssl_connect() first."); } else { if ($func === 'ftp_login' || $func === 'ftp_pasv') { $this->state[$name] = $args; } array_unshift($args, $this->resource); $res = call_user_func_array($func, $args); if ($func === 'ftp_chdir' || $func === 'ftp_cdup') { $this->state['chdir'] = array(ftp_pwd($this->resource)); } } if (NTools::catchError($msg) && !$silent) { throw new NFtpException($msg); } return $res; }