Exemplo n.º 1
0
 /**
  * @module org.rhaco.Template
  * @param org.rhaco.lang.Str $obj
  */
 public function before_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     $this->replace('rt:exceptions', $src);
     $this->replace('rt:invalid', $src);
     $obj->set($src);
 }
Exemplo n.º 2
0
 /**
  * @module org.rhaco.Template
  * @param org.rhaco.lang.Str $obj
  */
 public function after_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     $src = str_replace("{\$t.package_method_url('class_info',", "{\$f.class_html_filename(", $src);
     $src = str_replace("{\$t.package_method_url('method_info',", "{\$f.method_html_filename(", $src);
     $src = str_replace("{\$t.package_method_url('class_module_info',", "{\$f.module_html_filename(", $src);
     $obj->set($src);
 }
Exemplo n.º 3
0
 /**
  * @module org.rhaco.Template
  * @param \org\rhaco\lang\Str $obj
  */
 public function before_exec_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     if (preg_match_all('/\\$_t_->print_variable\\((.+?)\\);/ms', $src, $match)) {
         $src = str_replace($match[0], array_map(array($this, 'add_escape'), $match[1]), $src);
         $obj->set($src);
     }
 }
Exemplo n.º 4
0
 public function after_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     \org\rhaco\Xml::set($tag, '<:>' . $src . '</:>');
     foreach ($tag->in('form') as $form) {
         if ($form->in_attr('action') == '' || strpos($form->in_attr('action'), '$t.map_url') !== false) {
             $form->escape(false);
             $form->value(sprintf('<input type="hidden" name="csrftoken" value="%s" />', $this->no) . $form->value());
             $src = str_replace($form->plain(), $form->get(), $src);
         }
     }
     $obj->set($src);
 }
 /**
  * @module org.rhaco.Template
  * @param org.rhaco.lang.Str $obj
  */
 public function before_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     if (strpos($src, 'rt:paginator') !== false) {
         while (Xml::set($tag, $src, 'rt:paginator')) {
             $param = '$' . $tag->in_attr('param', 'paginator');
             $func = sprintf('<?php try{ ?><?php if(%s instanceof \\org\\rhaco\\Paginator){ ?>', $param);
             $func .= '<div class="pagination"><ul>';
             $uniq = uniqid('');
             $name = '$__pager__' . $uniq;
             $counter_var = '$__counter__' . $uniq;
             $href = $tag->in_attr('href', '?');
             $stag = '<li%s>';
             $etag = '</li>';
             $navi = array_change_key_case(array_flip(explode(',', $tag->in_attr('navi', 'prev,next,first,last,counter'))));
             $counter = $tag->in_attr('counter', 10);
             $total = '$__pagertotal__' . $uniq;
             if (isset($navi['prev'])) {
                 $func .= sprintf('<?php if(%s->is_prev()){ ?><li class="prev"><a href="%s{%s.query_prev()}" rel="prev"><?php }else{ ?><li class="prev disabled"><a><?php } ?>%s</a></li>', $param, $href, $param, '&larr; Previous');
             }
             if (isset($navi['first'])) {
                 $func .= sprintf('<?php if(!%s->is_dynamic() && %s->is_first(%d)){ ?><li><a href="%s{%s.query(%s.first())}">{%s.first()}</a></li><li class="disabled"><a>...</a></li><?php } ?>', $param, $param, $counter, $href, $param, $param, $param);
             }
             if (isset($navi['counter'])) {
                 $func .= sprintf('<?php if(!%s->is_dynamic()){ ?>', $param);
                 $func .= sprintf('<?php %s = %s; if(!empty(%s)){ ?>', $total, $param, $total);
                 $func .= sprintf('<?php for(%s=%s->which_first(%d);%s<=%s->which_last(%d);%s++){ ?>', $counter_var, $param, $counter, $counter_var, $param, $counter, $counter_var);
                 $func .= sprintf('<?php if(%s == %s->current()){ ?>', $counter_var, $param);
                 $func .= sprintf('<li class="active"><a>{%s}</a></li>', $counter_var);
                 $func .= '<?php }else{ ?>';
                 $func .= sprintf('<li><a href="%s{%s.query(%s)}">{%s}</a></li>', $href, $param, $counter_var, $counter_var);
                 $func .= '<?php } ?>';
                 $func .= '<?php } ?>';
                 $func .= '<?php } ?>';
                 $func .= '<?php } ?>';
             }
             if (isset($navi['last'])) {
                 $func .= sprintf('<?php if(!%s->is_dynamic() && %s->is_last(%d)){ ?><li class="disabled"><a>...</a></li><li><a href="%s{%s.query(%s.last())}">{%s.last()}</a></li><?php } ?>', $param, $param, $counter, $href, $param, $param, $param);
             }
             if (isset($navi['next'])) {
                 $func .= sprintf('<?php if(%s->is_next()){ ?><li class="next"><a href="%s{%s.query_next()}" rel="next"><?php }else{ ?><li class="next disabled"><a><?php } ?>%s</a></li>', $param, $href, $param, 'Next &rarr;', $etag);
             }
             $func .= "<?php } ?><?php }catch(\\Exception \$e){} ?>";
             $func .= '</ul></div>';
             $src = str_replace($tag->plain(), $func, $src);
         }
     }
     $obj->set($src);
 }
Exemplo n.º 6
0
 /**
  * @module org.rhaco.Template
  * @param org.rhaco.lang.Str $obj
  */
 public function before_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     if (strpos($src, 'rt:paginator') !== false) {
         while (Xml::set($tag, $src, 'rt:paginator')) {
             $param = '$' . $tag->in_attr('param', 'paginator');
             $func = sprintf('<?php try{ ?><?php if(%s instanceof \\org\\rhaco\\Paginator){ ?>', $param);
             if ($tag->value() != '') {
                 $func .= $tag->value();
             } else {
                 $uniq = uniqid('');
                 $name = '$__pager__' . $uniq;
                 $counter_var = '$__counter__' . $uniq;
                 $tagtype = $tag->in_attr('tag');
                 $href = $tag->in_attr('href', '?');
                 $stag = empty($tagtype) ? '' : '<' . $tagtype . ' class="%s">';
                 $etag = empty($tagtype) ? '' : '</' . $tagtype . '>';
                 $navi = array_change_key_case(array_flip(explode(',', $tag->in_attr('navi', 'prev,next,first,last,counter'))));
                 $counter = $tag->in_attr('counter', 50);
                 $total = '$__pagertotal__' . $uniq;
                 if (isset($navi['prev'])) {
                     $func .= sprintf('<?php if(%s->is_prev()){ ?>%s<a href="%s{%s.query_prev()}" rel="prev">%s</a>%s<?php } ?>', $param, sprintf($stag, 'prev'), $href, $param, 'prev', $etag);
                 }
                 if (isset($navi['first'])) {
                     $func .= sprintf('<?php if(!%s->is_dynamic() && %s->is_first(%d)){ ?>%s<a href="%s{%s.query(%s.first())}">{%s.first()}</a>%s%s...%s<?php } ?>', $param, $param, $counter, sprintf($stag, 'first'), $href, $param, $param, $param, $etag, sprintf($stag, 'first_gt'), $etag);
                 }
                 if (isset($navi['counter'])) {
                     $func .= sprintf('<?php if(!%s->is_dynamic()){ ?>', $param);
                     $func .= sprintf('<?php %s = %s; if(!empty(%s)){ ?>', $total, $param, $total);
                     $func .= sprintf('<?php for(%s=%s->which_first(%d);%s<=%s->which_last(%d);%s++){ ?>', $counter_var, $param, $counter, $counter_var, $param, $counter, $counter_var);
                     $func .= sprintf('%s<?php if(%s == %s->current()){ ?><strong>{%s}</strong><?php }else{ ?><a href="%s{%s.query(%s)}">{%s}</a><?php } ?>%s', sprintf($stag, 'count'), $counter_var, $param, $counter_var, $href, $param, $counter_var, $counter_var, $etag);
                     $func .= '<?php } ?>';
                     $func .= '<?php } ?>';
                     $func .= '<?php } ?>';
                 }
                 if (isset($navi['last'])) {
                     $func .= sprintf('<?php if(!%s->is_dynamic() && %s->is_last(%d)){ ?>%s...%s%s<a href="%s{%s.query(%s.last())}">{%s.last()}</a>%s<?php } ?>', $param, $param, $counter, sprintf($stag, 'last_lt'), $etag, sprintf($stag, 'last'), $href, $param, $param, $param, $etag);
                 }
                 if (isset($navi['next'])) {
                     $func .= sprintf('<?php if(%s->is_next()){ ?>%s<a href="%s{%s.query_next()}" rel="next">%s</a>%s<?php } ?>', $param, sprintf($stag, 'next'), $href, $param, 'next', $etag);
                 }
             }
             $func .= "<?php } ?><?php }catch(\\Exception \$e){} ?>";
             $src = str_replace($tag->plain(), $func, $src);
         }
     }
     $obj->set($src);
 }
Exemplo n.º 7
0
 public function after_exec_template(\org\rhaco\lang\Str $obj)
 {
     $obj->set($obj->get() . 'AFTER_EXEC_TEMPLATE' . PHP_EOL);
 }
Exemplo n.º 8
0
 /**
  * @module org.rhaco.Template
  */
 public function after_exec_template(\org\rhaco\lang\Str $obj)
 {
     $src = $obj->get();
     $src = preg_replace("/<alert>(.+?)<\\/alert>/ms", '<p class="alert alert-error">\\1</p>', $src);
     $src = preg_replace("/<information>(.+?)<\\/information>/ms", '<p class="alert alert-info">\\1</p>', $src);
     $src = preg_replace("/!!!(.+?)!!!/ms", '<span style="font-weight:bold">\\1</span>', $src);
     $src = preg_replace("/##(.+?)##/ms", '<span class="label label-warning">\\1</span>', $src);
     $src = str_replace('<table>', '<table class="table table-striped table-bordered table-condensed">', $src);
     $src = str_replace(array('__RTD__', '__RTE__'), array('$', '='), $src);
     $obj->set($src);
 }
Exemplo n.º 9
0
 public function before_flow_print_template(\org\rhaco\lang\Str $obj)
 {
     $obj->set($obj->get() . "10");
 }