public function loadTemplate($templateName, $vars = array()) { $class = new self(); $class->viewname = $this->viewname; $class->set($vars); return $class->output($templateName); }
static function QuickDraw($name, $vars = null) { $o = new self($name); if ($vars) { $o->import($vars); } $o->output(); }
/** * Export record to PDF file * @param int $recordId - id of a record * @param string $moduleName - name of records module * @param int $templateId - id of pdf template * @param string $filePath - path name for saving pdf file * @param string $saveFlag - save option flag */ public function export($recordId, $moduleName, $templateId, $filePath = '', $saveFlag = '') { $template = Vtiger_PDF_Model::getInstanceById($templateId, $moduleName); $template->setMainRecordId($recordId); $pageOrientation = $template->get('page_orientation') == 'PLL_PORTRAIT' ? 'P' : 'L'; $pdf = new self('c', $template->get('page_format'), 0, '', $template->get('margin_left'), $template->get('margin_right'), $template->get('margin_top'), $template->get('margin_bottom'), $template->get('margin_top'), $template->get('margin_bottom'), $pageOrientation); $pdf->setTemplateId($templateId); $pdf->setRecordId($recordId); $pdf->setModuleName($moduleName); $pdf->setLanguage($template->get('language')); $pdf->setFileName($template->get('filename')); $origLanguage = vglobal('default_language'); vglobal('default_language', $template->get('language')); $pdf->parseParams($template->getParameters()); $pdf->setHeader('Header', $template->getHeader()); $pdf->setFooter('Footer', $template->getFooter()); $html = $template->getBody(); $pdf->loadHTML($html); vglobal('default_language', $origLanguage); $pdf->output($filePath, $saveFlag); }
/** * xml定義からhandlerを処理する * @param string $file アプリケーションXMLのファイルパス */ public static final function load($file = null) { if (!isset($file)) { $file = App::mode() . App::called_filename(); } if (!self::$is_app_cache || !Store::has($file)) { $parse_app = self::parse_app($file, false); if (self::$is_app_cache) { Store::set($file, $parse_app); } } if (self::$is_app_cache) { $parse_app = Store::get($file); } if (empty($parse_app['apps'])) { throw new RuntimeException('undef app'); } $app_result = null; $in_app = $match_handle = false; $app_index = 0; try { foreach ($parse_app['apps'] as $app) { switch ($app['type']) { case 'handle': $self = new self('_inc_session_=false'); foreach ($app['modules'] as $module) { $self->add_module(self::import_instance($module)); } if ($self->has_module('flow_handle_begin')) { $self->call_module('flow_handle_begin', $self); } try { if ($self->handler($app['maps'], $app_index++)->is_pattern()) { $self->cp(self::execute_var($app['vars'])); $src = $self->read(); if ($self->has_module('flow_handle_end')) { $self->call_module('flow_handle_end', $src, $self); } print $src; $in_app = true; $match_handle = true; if (!$parse_app["handler_multiple"]) { exit; } } } catch (Exception $e) { Log::warn($e); if (isset($app['on_error']['status'])) { Http::status_header((int) $app['on_error']['status']); } if (isset($app['on_error']['redirect'])) { $this->save_exception($e); $this->redirect($app['on_error']['redirect']); } else { if (isset($app['on_error']['template'])) { if (!$e instanceof Exceptions) { Exceptions::add($e); } $self->output($app['on_error']['template']); } else { throw $e; } } } break; case 'invoke': $class_name = isset($app['class']) ? Lib::import($app['class']) : get_class($app_result); $ref_class = new ReflectionClass($class_name); foreach ($app['methods'] as $method) { $invoke_class = $ref_class->getMethod($method['method'])->isStatic() ? $class_name : (isset($app['class']) ? new $class_name() : $app_result); $args = array(); foreach ($method['args'] as $arg) { if ($arg['type'] === 'result') { $args[] =& $app_result; } else { $args[] = $arg['value']; } } if (is_object($invoke_class)) { foreach ($app['modules'] as $module) { $invoke_class->add_module(self::import_instance($module)); } } $app_result = call_user_func_array(array($invoke_class, $method['method']), $args); $in_app = true; } break; } } if (!$match_handle) { Log::debug("nomatch"); if ($parse_app["nomatch_redirect"] !== null) { Http::redirect(App::url($parse_app["nomatch_redirect"])); } if ($parse_app["nomatch_template"] !== null) { Http::status_header(404); $self = new self(); $self->output($parse_app["nomatch_template"]); } } if (!$in_app) { Http::status_header(404); } } catch (Exception $e) { if (!$e instanceof Exceptions) { Exceptions::add($e); } } exit; }
/** * Factory method */ public static function make() { $widget = new self(); $widget->output(); }
/** * 出力する * @param array $maps */ public static function out($maps) { $self = new self(); $self->output($maps); }
public static function outputMessage($message) { $response = new self(); $response->setData('SystemMessage', $message); $response->output(); }
/** * Export record to PDF file * @param int $recordId - id of a record * @param string $moduleName - name of records module * @param int $templateId - id of pdf template * @param string $filePath - path name for saving pdf file * @param string $saveFlag - save option flag */ public function export($recordId, $moduleName, $templateId, $filePath = '', $saveFlag = '') { $pdf = new self(); $pdf->setTemplateId($templateId); $pdf->setRecordId($recordId); $pdf->setModuleName($moduleName); $template = Vtiger_PDF_Model::getInstanceById($templateId, $moduleName); $template->setMainRecordId($recordId); $pdf->setLanguage($template->get('language')); $pdf->setFileName($template->get('filename')); $origLanguage = vglobal('default_language'); vglobal('default_language', $template->get('language')); $pdf->parseParams($template->getParameters()); $html = ''; $pdf->setHeader('Header', $template->getHeader()); $pdf->setFooter('Footer', $template->getFooter()); $html = $template->getBody(); $pdf->loadHTML($html); vglobal('default_language', $origLanguage); $pdf->output($filePath, $saveFlag); }
/** * 生成静态方法 * * @param int $w 验证码的宽度 * @param int $h 验证码的高度 * @param int $len 验证码的字符数量 */ public static function genImg($w = 130, $h = 80, $len = 4) { $fCaptcha = new self(); $fCaptcha->setWidth($w); $fCaptcha->setHeight($h); $fCaptcha->setLength($len); $fCaptcha->output(); }