Ejemplo n.º 1
0
 public static function load($cssFile, $media = 'all')
 {
     if (empty($media)) {
         $media = 'all';
     }
     return HTML::tag('link', NULL, array('rel' => 'stylesheet', 'media' => $media, 'type' => 'text/css', 'href' => $cssFile))->setOption('selfClosing', TRUE);
 }
Ejemplo n.º 2
0
 public function testConstructors_String_HTMLInterface()
 {
     $html = HTML::tag('form', HTML::tag('input'))->addClass('main');
     $htmlPage = new \Psc\HTML\Page();
     $this->assertInstanceOf($this->c, new jQuery('form.main', $html));
     $this->assertInstanceOf($this->c, new jQuery('form.main', $htmlPage));
 }
Ejemplo n.º 3
0
 public function setTitleForProject(Project $project)
 {
     $config = $project->getConfiguration();
     $title = $config->get('project.title', 'Psc - CMS');
     $title .= ' ' . $config->get('version');
     $this->setTitle(HTML::tag('title', HTML::esc($title)));
 }
Ejemplo n.º 4
0
 public function html()
 {
     $lis = array();
     foreach ($this->content as $li) {
         $lis[] = \Psc\HTML\HTML::tag('li', $this->wrapText($li, $inline = TRUE)->convert());
     }
     return \Psc\HTML\HTML::tag('ul', $lis, array('class' => 'roll'));
 }
Ejemplo n.º 5
0
 public function testWTFBug()
 {
     $content = NULL;
     $divcontent = \Psc\UI\Form::group('Sounds', $content, \Psc\UI\Form::GROUP_COLLAPSIBLE);
     $tagggggg = \Psc\HTML\HTML::tag('div', $divcontent);
     //$tagggggg->debug = TRUE;
     $tagggggg->chain(new \Psc\JS\Code("pling"));
     ob_start();
     print $tagggggg->html();
     ob_end_clean();
 }
Ejemplo n.º 6
0
 public static function provideNormalConversions()
 {
     $tests = array();
     $testHTML = function ($expectedHTML, $body, Request $request = NULL) use(&$tests) {
         $tests[] = array($expectedHTML, $body, ServiceResponse::HTML, $request);
     };
     $testJSON = function ($expectedJSON, $body, Request $request = NULL) use(&$tests) {
         $tests[] = array($expectedJSON, $body, ServiceResponse::JSON, $request);
     };
     $testHTML('<html><body><form></form></body></html>', '<html><body><form></form></body></html>');
     $testHTML('<input type="hidden" name="nix" />', \Psc\HTML\HTML::Tag('input', NULL, array('type' => 'hidden', 'name' => 'nix')));
     // php array
     $testJSON(json_encode(array('eins', 'zwei')), array('eins', 'zwei'));
     // php object
     $o = new \stdClass();
     $o->eins = 'v1';
     $o->zwei = 'v2';
     $testJSON(json_encode((object) array('eins' => 'v1', 'zwei' => 'v2')), $o);
     // interface JSON
     $testJSON(json_encode(array('eins' => TRUE, 'zwei' => 'f')), new ArrayCollection(array('eins' => TRUE, 'zwei' => 'f')));
     return $tests;
 }
Ejemplo n.º 7
0
 /**
  * Gibt den Wert als HTML-Klasse zurück
  */
 protected function classify($value)
 {
     return HTML::string2class($value);
 }
Ejemplo n.º 8
0
 public static function esc($value)
 {
     return \Psc\HTML\HTML::esc($value);
 }
Ejemplo n.º 9
0
 protected function expectJooseBridgeDefaults()
 {
     $this->jooseBridge->expects($this->once())->method('link')->with($this->isInstanceOf('Psc\\HTML\\Tag'))->will($this->returnSelf());
     $this->jooseBridge->expects($this->once())->method('html')->will($this->returnValue(\Psc\HTML\HTML::tag('a', 'the html')));
 }
Ejemplo n.º 10
0
 public function html()
 {
     $img = \Psc\HTML\HTML::tag('img', NULL, array('src' => $this->getHTMLUrl(), 'alt' => $this->getLabel()));
     if (isset($this->align)) {
         $img->addClass('align' . $this->align);
     }
     return $img;
 }
Ejemplo n.º 11
0
 /**
  * Returns a Script-Tag for a script file
  */
 public static function load($jsFile)
 {
     return HTML::tag('script', NULL, array('type' => 'text/javascript', 'src' => $jsFile))->setOption('br.closeTag', TRUE);
 }
Ejemplo n.º 12
0
 protected function walkHeadline($headline)
 {
     return HTML::tag('h1', HTML::tag('img', NULL, array('src' => $headline->getImage())), array('id' => 'headline'));
 }
Ejemplo n.º 13
0
 public static function reformat($html, $withPFirst = TRUE)
 {
     /* compile regex */
     $blockElements = array('h1', 'h2', 'h3', 'div', 'h3', 'table', 'tr', 'td', 'ol', 'li', 'ul', 'pre', 'p');
     $blemRx = '(?:' . implode('|', $blockElements) . ')';
     $blemStartRx = '<' . $blemRx . '[^>]*(?<!\\/)>';
     // ignores self-closing
     $blemEndRx = '<\\/' . $blemRx . '[^>]*>';
     $blemBothRx = '<\\/?' . $blemRx . '[^>]*>';
     $debug = FALSE;
     $log = NULL;
     $log .= 'Starte mit Text: "' . $html . '"<br />' . "\n";
     $level = 0;
     $pOpen = FALSE;
     $matching = NULL;
     $ret = NULL;
     $firstP = $withPFirst;
     $x = 0;
     while ($html != '' && $x <= 100000000) {
         $x++;
         $log .= "level: " . $level . ":  ";
         /* $html abschneiden (schritt) */
         if (isset($matching)) {
             $html = mb_substr($html, mb_strlen($matching));
             $ret .= $matching;
             $matching = NULL;
         }
         /* normaler text */
         $match = array();
         if (Preg::match($html, '/^([^\\n<>]+)/', $match) > 0) {
             /* p öffnen, wenn es nicht offen ist */
             if ($level == 0 && !$pOpen) {
                 $pOpen = TRUE;
                 $log .= "open p<br />\n";
                 if ($firstP && mb_strlen(trim($ret)) == 0) {
                     $ret .= '<p class="first">';
                     $firstP = FALSE;
                 } else {
                     $ret .= '<p>';
                 }
             }
             $matching = $match[1];
             $log .= "text(" . mb_strlen($matching) . "): " . str_replace(array("\n", "\r"), array("-n-\n", "-r-\r"), $matching) . "<br />\n";
             continue;
         }
         /* absatz */
         $match = array();
         if (S::startsWith($html, "\n\n")) {
             $matching = "\n\n";
             if ($level == 0 && $pOpen) {
                 $log .= "Absatz (close p)<br />\n";
                 $pOpen = FALSE;
                 $ret .= '</p>';
                 //$ret .= "\n"; // da matching hinzugefügt wird
             }
             continue;
         }
         /* zeilenumbruch  */
         if (S::startsWith($html, "\n")) {
             $matching = "\n";
             $log .= "\\n gefunden<br />\n";
             /* wir machen ein <br /> aus dem \n, wenn wir im p modus sind */
             if ($pOpen) {
                 $ret .= '<br />';
                 $log .= "in br umwandeln<br />\n";
             }
             continue;
         }
         /* prüfen auf html tags (block start, block end, inline tag */
         $match = array();
         if (Preg::match($html, '/^<(\\/)?([^\\s>]+)((?>[^>])*)>/', $match) > 0) {
             list($full, $op, $tagName, $rest) = $match;
             if (in_array($tagName, $blockElements)) {
                 $matching = $full;
                 if ($op != '/') {
                     /* block element start */
                     if ($pOpen) {
                         $ret .= '</p>';
                         $log .= "close p<br />\n";
                         $pOpen = FALSE;
                     }
                     $log .= "block level(" . $level . ") start : '" . $matching . "'<br />\n";
                     $level++;
                 } else {
                     /* block element end */
                     $log .= "block level(" . $level . ") end: '" . $matching . "'<br />\n";
                     $level--;
                 }
             } else {
                 /* html tag (kein block element) */
                 $matching = $full;
                 /* p öffnen, wenn es nicht offen ist */
                 if ($level == 0 && !$pOpen) {
                     $pOpen = TRUE;
                     $log .= "open p<br />\n";
                     if ($firstP && mb_strlen(trim($ret)) == 0) {
                         $ret .= '<p class="first">';
                         $firstP = FALSE;
                     } else {
                         $ret .= '<p>';
                     }
                 }
                 $log .= "inline-tag: '" . $matching . "'<br />\n";
             }
             continue;
         }
         /* kein fall hat gegriffen, wir verkürzen um 1 Zeichen */
         $matching = HTML::esc(mb_substr($html, 0, 1));
         $log .= "zeichen: " . $matching . "<br />\n";
     }
     /* letztes <p> schließen */
     if ($pOpen) {
         $ret .= '</p>' . "\n";
     }
     if ($debug) {
         print $log;
     }
     return $ret;
 }
Ejemplo n.º 14
0
 public function guid($set = NULL)
 {
     if (func_num_args() == 1) {
         $guid = $this->guid;
         if ($set != NULL) {
             if (!S::startsWith($set, 'psc-guid-')) {
                 $set = 'psc-guid-' . $set;
             }
             $set = HTML::string2id($set);
         }
         $this->guid = $set;
         if ($this->guid != $guid && $this->hasClass($guid)) {
             $this->removeClass($guid);
             //unpublish
             $this->publishGUID();
         }
         return $this;
     }
     if (!isset($this->guid)) {
         $this->generateGUID();
     }
     return $this->guid;
 }
Ejemplo n.º 15
0
 public function setTitleString($title)
 {
     $this->title = new Tag('title', HTML::esc($title));
     return $this;
 }
Ejemplo n.º 16
0
 /**
  * @param array $htmlSnippets see Webforge\CMS\Navigation\NestedSetConverter::toHTMLList()
  */
 public function getHTML($locale, array $htmlSnippets = array(), NestedSetConverter $converter = NULL, \Closure $qbHook = NULL)
 {
     $that = $this;
     $htmlSnippets = array_merge(array('rootOpen' => function ($root) {
         return '<ul id="nav">';
     }, 'nodeDecorator' => function ($node) use($that, $locale) {
         $url = $that->getUrl($node, $locale);
         $html = '<li><a href="' . $url . '">';
         if ($node->getDepth() === 0 && $node->getImage() != NULL) {
             $html .= '<img src="' . \Psc\HTML\HTML::escAttr($node->getImage()) . '" alt="' . \Psc\HTML\HTML::escAttr($node->getTitle($locale)) . '" />';
         }
         $html .= \Psc\HTML\HTML::esc($node->getTitle($locale));
         $html .= '</a>';
         return $html;
     }), $htmlSnippets);
     $qb = $this->childrenQueryBuilder(NULL, $qbHook ?: $this->getDefaultQueryBuilderHook());
     $query = $qb->getQuery();
     $nodes = $query->getResult();
     $converter = $converter ?: new NestedSetConverter();
     return $converter->toHTMLList($nodes, $htmlSnippets);
 }
Ejemplo n.º 17
0
 public function getInnerHTML()
 {
     return HTML::tag('span', (object) array('date' => $this->datePicker->getInnerHTML(), 'time' => $this->timeField->getInnerHTML()));
 }
Ejemplo n.º 18
0
 protected function doInit()
 {
     $this->html = \Psc\HTML\HTML::tag('div');
     parent::doInit();
 }
Ejemplo n.º 19
0
 public function addSection($headline, array $content, $index = self::END, $openAllIcon = FALSE)
 {
     $class = \Psc\HTML\HTML::string2class($headline);
     $this->addRow('<a href="#">' . HTML::esc($headline) . '</a>' . ($openAllIcon ? '<span class="ui-icon open-all-list psc-cms-ui-icon-secondary ui-icon-newwin" title="Alle öffnen"></span>' : ''), $content, $index, $class);
     return $this;
 }
Ejemplo n.º 20
0
 public static function replaceLinksMarkup($text)
 {
     $link = function ($url, $label) {
         // label is already escaped
         if (Preg::match($url, '~^([a-zA-Z0-9]+://|www\\.)~')) {
             return HTML::tag('a', $label, array('href' => $url, 'class' => 'external', 'target' => '_blank'));
         } else {
             return HTML::tag('a', $label, array('href' => $url, 'class' => 'internal'));
         }
     };
     $openLink = preg_quote('[[');
     $closeLink = preg_quote(']]');
     $sepLink = preg_quote('|');
     // [[http://www.google.com|This Link points to google]]
     $text = \Psc\Preg::replace_callback($text, '/' . $openLink . '(.*?)' . $sepLink . '(.*?)' . $closeLink . '/', function ($match) use($link) {
         return $link($match[1], $match[2]);
     });
     // [[http://www.google.com]]
     $text = \Psc\Preg::replace_callback($text, '/' . $openLink . '(.*?)' . $closeLink . '/', function ($match) use($link) {
         return $link($match[1], $match[1]);
     });
     return $text;
 }
Ejemplo n.º 21
0
 public static function camelCaseToDash($camelCaseString)
 {
     return \Psc\HTML\HTML::string2class($camelCaseString);
 }
Ejemplo n.º 22
0
 /**
  * Gibt Informationen für die Fehler die angezeigt werden sollen, für das JavaScript zurück
  * 
  * @return HTMLTag|NULL
  */
 public function html()
 {
     $html = NULL;
     if (count($this->jsonArray) > 0) {
         $content = json_encode($this->jsonArray, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP);
         $html = HTML::tag('div', $content, array('id' => $this->getJsonId()))->setStyle('display', 'none');
     }
     return $html;
 }