コード例 #1
0
ファイル: View.php プロジェクト: Kuzat/kofradia
 /**
  * Create a view and get its content
  *
  * @param string  Name of view
  * @param array   Data to pass to the view
  * @return \Kofradia\Viev
  */
 public static function forge($name, $data = array())
 {
     $path = PATH_APP . "/views/{$name}.php";
     $view = new static($path);
     $view->setData($data);
     return $view->render();
 }
コード例 #2
0
ファイル: Thumb.php プロジェクト: ronaldborla/thumb
 /**
  * Create a thumbnail
  */
 static function create($source, $options = array())
 {
     // Create thumb
     $thumb = new static();
     // Load
     $thumb->load($source);
     // Set properties
     $properties = array('type', 'quality', 'alignX', 'alignY', 'background');
     // Loop
     foreach ($properties as $property) {
         // If set
         if (isset($options[$property])) {
             // Set it
             $thumb->{$property} = $options[$property];
         }
     }
     // If there's width
     if (isset($options['width']) && ($width = $options['width'])) {
         // Set width
         $thumb->width = $width;
     }
     // If there's height
     if (isset($options['height']) && ($height = $options['height'])) {
         // Set height
         $thumb->height = $height;
     }
     // Resize
     $thumb->resize();
     // Render and return
     return $thumb->render();
 }
コード例 #3
0
ファイル: PhtmlTemplate.php プロジェクト: cawaphp/cawa
 /**
  * @param string $templatePath
  * @param array $data
  *
  * @return string
  */
 public static function renderTemplate(string $templatePath, array $data = []) : string
 {
     if (substr($templatePath, 0, 1) != '/') {
         $templatePath = AbstractApp::getAppRoot() . '/' . $templatePath;
     }
     $phtml = new static($templatePath);
     $phtml->addDatas($data);
     return $phtml->render();
 }
コード例 #4
0
 public static function factory(RendererInterface $renderer, DataObject $object, $urlType, array $attributes = array())
 {
     $element = new static();
     $element->setView($renderer);
     $element->setObject($object);
     $element->setAttributes($attributes);
     $element->setUrlType($urlType);
     return $element->render();
 }
コード例 #5
0
ファイル: Json.php プロジェクト: akeeba/fof
 /**
  * Render a HAL document in JSON format
  *
  * @param   array  $options  Rendering options. You can currently only set json_options (json_encode options)
  *
  * @return  string  The JSON representation of the HAL document
  */
 public function render($options = array())
 {
     if (isset($options['data_key'])) {
         $this->_dataKey = $options['data_key'];
     }
     if (isset($options['json_options'])) {
         $jsonOptions = $options['json_options'];
     } else {
         $jsonOptions = 0;
     }
     $serialiseThis = new \stdClass();
     // Add links
     $collection = $this->_document->getLinks();
     $serialiseThis->_links = new \stdClass();
     foreach ($collection as $rel => $links) {
         if (!is_array($links)) {
             $serialiseThis->_links->{$rel} = $this->_getLink($links);
         } else {
             $serialiseThis->_links->{$rel} = array();
             foreach ($links as $link) {
                 array_push($serialiseThis->_links->{$rel}, $this->_getLink($link));
             }
         }
     }
     // Add embedded documents
     $collection = $this->_document->getEmbedded();
     if (!empty($collection)) {
         $serialiseThis->_embedded = new \stdClass();
         foreach ($collection as $rel => $embeddeddocs) {
             $serialiseThis->_embedded->{$rel} = array();
             if (!is_array($embeddeddocs)) {
                 $embeddeddocs = array($embeddeddocs);
             }
             foreach ($embeddeddocs as $embedded) {
                 $renderer = new static($embedded);
                 array_push($serialiseThis->_embedded->{$rel}, $renderer->render($options));
             }
         }
     }
     // Add data
     $data = $this->_document->getData();
     if (is_object($data)) {
         if ($data instanceof DataModel) {
             $data = $data->toArray();
         } else {
             $data = (array) $data;
         }
         if (!empty($data)) {
             foreach ($data as $k => $v) {
                 $serialiseThis->{$k} = $v;
             }
         }
     } elseif (is_array($data)) {
         $serialiseThis->{$this->_dataKey} = $data;
     }
     return json_encode($serialiseThis, $jsonOptions);
 }
コード例 #6
0
ファイル: CoreHelpers.php プロジェクト: betasyntax/framework
 public static function helpers()
 {
     static::$app = app();
     $link_to = new \Twig_SimpleFunction('link_to', function ($text, $route_alias, $data = [], $attributes = []) {
         $url = urlHelper($route_alias, $data);
         if (isset($attributes)) {
             $cnt = '';
             foreach ($attributes as $key => $value) {
                 $cnt .= $value[0] . '="' . $value[1] . '" ';
             }
         }
         echo '<a href="' . $url . '" ' . $cnt . '>' . $text . '</a>';
     });
     $link_to_remote = new \Twig_SimpleFunction('link_to_remote', function ($text, $url, $attributes) {
         if (isset($attributes)) {
             $cnt = '';
             foreach ($attributes as $key => $value) {
                 $cnt .= $value[0] . '="' . $value[1] . '" ';
             }
         }
         echo '<a href="' . $url . '" ' . $cnt . '>' . $text . '</a>';
     });
     $debugBarHead = new \Twig_SimpleFunction('debugBarHead', function () {
         $app = app();
         if (!$app->isProd()) {
             static::$debugbarRender = $app->debugbar;
             $test = static::$debugbarRender;
             static::$render = $test->getJsRender();
             echo static::$render->renderHead();
         } else {
             echo '';
         }
     });
     $debugBarBody = new \Twig_SimpleFunction('debugBarBody', function () {
         $app = app();
         if (!$app->isProd()) {
             echo static::$debugbarRender->render();
         } else {
             echo '';
         }
     });
     $flash = new \Twig_SimpleFunction('flash', function () {
         echo flash()->display(null, false);
     });
     $dd = new \Twig_SimpleFunction('dd', function ($data) {
         dd($data);
     });
     return ['flash' => $flash, 'debugBarHead' => $debugBarHead, 'debugBarBody' => $debugBarBody, 'link_to' => $link_to, 'link_to_remote' => $link_to_remote, 'dd' => $dd];
 }
コード例 #7
0
ファイル: Help.php プロジェクト: pugphp/framework
 /**
  * Execute the command.
  *
  * @param Application $app The application instance
  *
  * @return mixed
  */
 public static function execute(Application $app)
 {
     static::$base = dirname(__DIR__) . '/templates/help/';
     $help = new static($app->command ?: 'help');
     $help->render();
 }
コード例 #8
0
ファイル: PhpRenderer.php プロジェクト: rokite/windwalker
 /**
  * load
  *
  * @param string $file
  * @param array  $data
  *
  * @return  string
  */
 public function load($file, $data = null)
 {
     $data = $this->data->bind(new Data($data));
     $renderer = new static($this->paths, $this->config);
     return $renderer->render($file, $data);
 }
コード例 #9
0
 /**
  * Prepare a response from the given value.
  *
  * If the value is not a response, it will be converted into a response
  * instance and the content will be cast to a string.
  *
  * @param  mixed     $response
  * @return Response
  */
 public static function prepare($response)
 {
     if (!$response instanceof Response) {
         $response = new static($response);
     }
     // We'll need to force the response to be a string before closing the session,
     // since the developer may be using the session within a view, and we can't
     // age the flash data until the view is rendered.
     //
     // Since this method is used by both the Route and Controller classes, it is
     // a convenient spot to cast the application response to a string before it
     // is returned to the main request handler.
     $response->render();
     return $response;
 }
コード例 #10
0
ファイル: BasicRender.php プロジェクト: fuelphp/fieldset
 /**
  * Adds a fieldset object to the table.
  *
  * @param  Fieldset $fieldset
  *
  * @since 2.0
  */
 public function renderFieldset(Fieldset $fieldset)
 {
     // Create a new renderer and render the content
     $fieldsetRenderer = new static($this->csrfProvider);
     // Generate all the content
     foreach ($fieldset as $item) {
         $fieldsetRenderer->render($item);
     }
     $content = $fieldsetRenderer->getRenderedForm();
     // Create the fieldset tag and add the content
     $tag = Html::tag('fieldset', $fieldset->getAttributes(), $content);
     // Make sure everything is added to the parent table
     $cell = new Table\Cell($tag);
     $cell->setAttributes(['colspan' => 2]);
     $this->table->addCell($cell);
     $this->table->addRow();
     return '';
 }
コード例 #11
0
ファイル: Console.php プロジェクト: robertodormepoco/zf2
 /**
  * Export
  *
  * @param Di $di
  * @param array $runtimeClasses
  * @return void
  */
 public static function export(Di $di, array $runtimeClasses = array())
 {
     $console = new static($di);
     $console->addRuntimeClasses($runtimeClasses);
     $console->render($di);
 }
コード例 #12
0
ファイル: Debugger.php プロジェクト: antistupid/Hasty
 public static function setRender($render)
 {
     static::$render = $render;
 }
コード例 #13
0
ファイル: View.php プロジェクト: sohoa/framework
 public function import($in, $data = null)
 {
     $new = new static($in, $this->getOutputStream(), $this->getRouter(), $data);
     $new->render();
     return;
 }
コード例 #14
0
ファイル: HelperTag.php プロジェクト: renatomartins/cognosys
 /**
  * Initializes a helper with access to the template, and if needed, some
  * parameters and content,
  * validates its properties and returns its HTML representation
  * @static
  * @param Cognosys\Template $template
  * @param array $params
  * @param mixed $content Tipically, a string, an array or a Closure
  * @return string
  */
 public static function create($template, array $params = array(), $content = null)
 {
     $helper = new static($template, $params, $content);
     $helper->validate();
     return $helper->render($content);
 }
コード例 #15
0
ファイル: Smarty.php プロジェクト: brokencube/hodgepodge
 public static function page($template, $data = array())
 {
     $tpl = new static();
     $tpl->assign('data', $data);
     echo $tpl->render($template);
 }
コード例 #16
0
ファイル: ProgressBar.php プロジェクト: armannadim/restpos
 private function generateFromArray($attributes)
 {
     $bar = new static();
     foreach ($attributes as $attribute) {
         $exploded = explode('=', $attribute);
         $method = $exploded[0];
         $vars = isset($exploded[1]) ? $exploded[1] : null;
         if (isset($vars)) {
             $bar->{$method}($vars);
         } else {
             $bar->{$method}();
         }
     }
     // Now to remove the outer divs
     $string = $bar->render();
     $string = str_replace('<div class=\'progress\'>', '', $string);
     $string = str_replace('</div></div>', '</div>', $string);
     return $string;
 }
コード例 #17
0
ファイル: braces.php プロジェクト: biggtfish/anchor-cms
 public static function compile($path, $vars = array())
 {
     $braces = new static($path);
     return $braces->render($vars);
 }
コード例 #18
0
 /**
  * @param float|int $number
  * @param string $outUnit
  * @param Number\NumberFormat $format
  * @return Number\INumberFormat
  */
 public static function recount($number, $outUnit = NULL, Number\NumberFormat $format = NULL)
 {
     $unit = new static($outUnit);
     $unit->setNumber($number);
     if ($format) {
         $unit->setFormat($format);
     }
     return $unit->render();
 }
コード例 #19
0
ファイル: SiteController.php プロジェクト: jarick/bx
 /**
  * Run render site
  *
  * @return \BX\MVC\SiteController
  */
 public static function run()
 {
     $instanse = new static();
     return $instanse->render();
 }
コード例 #20
0
ファイル: Debug.php プロジェクト: logocomune/debug
 /**
  * Debug main method
  *
  * @param $var var to see
  * @param int $debugTracePosition
  */
 public static function debug($var, $debugTracePosition = 1)
 {
     $deb = null;
     if (static::$conf['debug'] == true) {
         $deb = new static();
         $deb->setVar($var)->setDebugTracePosition($debugTracePosition);
         if (static::$conf['render_local'] == true) {
             $deb->render();
         }
     }
     return $deb;
 }
コード例 #21
0
ファイル: file.php プロジェクト: shamsbd71/canvas-framework
 /**
  * Render a layout with the same include paths & options
  *
  * @param   object  $layoutId     Object which properties are used inside the layout file to build displayed output
  * @param   mixed   $displayData  Data to be rendered
  *
  * @return  string  The necessary HTML to display the layout
  *
  * @since   3.2
  */
 public function sublayout($layoutId, $displayData)
 {
     // Sublayouts are searched in a subfolder with the name of the current layout
     if (!empty($this->layoutId)) {
         $layoutId = $this->layoutId . '.' . $layoutId;
     }
     $sublayout = new static($layoutId, $this->basePath, $this->options);
     $sublayout->includePaths = $this->includePaths;
     return $sublayout->render($displayData);
 }
コード例 #22
0
ファイル: WY_View.php プロジェクト: reny-ahmad/WayangCMS
 /**
  * mengambil output dari suatu file view
  * @param string $view nama file view yang akan di fetch
  * @param array $data variable-variable yang akan di outputkan
  * @return View instance dari kelas ini
  */
 public static function fetch($view = null, $data = null)
 {
     $instance = new static($view);
     return $instance->render(false, $data);
 }