예제 #1
0
 protected function toAttrString($arrayOrObject)
 {
     $array = ArrayUtil::fromObject($arrayOrObject);
     $out = '';
     foreach ($array as $key => $value) {
         $out .= $key . '="' . htmlentities($value, ENT_COMPAT, 'UTF-8') . '" ';
     }
     return trim($out);
 }
예제 #2
0
파일: Mail.php 프로젝트: hofmeister/Pimple
 public static function preview($view, $data, $containerViewFile = 'mail', $textonly = false)
 {
     $mailViewFile = "mail/{$view}";
     if (!$containerViewFile) {
         $containerViewFile = 'mail';
     }
     $mailContainer = new View($containerViewFile);
     $mailView = new View($mailViewFile);
     if (!is_array($data)) {
         $data = ArrayUtil::fromObject($data);
     }
     $data['textonly'] = $textonly;
     $container = $data;
     $container['body'] = $mailView->render($data);
     return $mailContainer->render($container);
 }
예제 #3
0
 /**
  * Renders a button. All attributes not listed below will be forwarded to the actual html element
  * @param string elm | tag type - defaults to a
  * @param string class | CSS class to apply to button 
  * @param string event | event to trigger when clicked
  * @deprecated
  * @container
  */
 protected function tagButton($attrs, $view)
 {
     if (!$attrs->elm) {
         $attrs->elm = 'a';
     }
     if (!$attrs->class) {
         $attrs->class = '';
     }
     $class = $this->evt2css($attrs->event);
     $attrs->class = trim(trim(self::CSS_BTN . ' ' . $class) . ' ' . $attrs->class);
     $elmAttr = ArrayUtil::fromObject($attrs);
     unset($elmAttr['elm']);
     unset($elmAttr['event']);
     $elm = new HtmlElement($attrs->elm, $elmAttr);
     $elm->addChild(new HtmlText(trim($this->body())));
     return $elm;
 }
예제 #4
0
파일: Pdf.php 프로젝트: hofmeister/Pimple
 public static function append(MPdf $pdf, $template, $data, $containerViewFile = null)
 {
     require_once Pimple::instance()->getRessource('lib/mpdf50/mpdf.php');
     if ($containerViewFile) {
         $container = new View($containerViewFile);
     }
     $view = new View($template);
     if (!is_array($data)) {
         $data = ArrayUtil::fromObject($data);
     }
     $cData = $data;
     $cData['body'] = $view->render($data);
     $css = "";
     if ($container) {
         $html = $container->render($cData);
         self::readCss($pdf, $container);
     } else {
         $html = $cData['body'];
     }
     self::readCss($pdf, $view);
     $pdf->WriteHTML($html);
 }
예제 #5
0
 protected function getElementAttr($attrs)
 {
     $this->handleBehaviour($attrs);
     $elmAttr = ArrayUtil::fromObject($attrs);
     $this->handleOptions($attrs, $elmAttr);
     $this->clearNonHtmlAttributes($elmAttr);
     return $elmAttr;
 }
예제 #6
0
 /**
  * Renders an img tag - src is relative to the basepath.
  * @param string src | path to image - relative to basepath of site
  */
 protected function tagImg($attrs)
 {
     $attrs->src = Url::basePath() . $attrs->src;
     return new HtmlElement('img', ArrayUtil::fromObject($attrs), false);
 }