Ejemplo n.º 1
0
 public function testClassMerge()
 {
     $decorator = new HtmlTag('div');
     $decorator->setOption('class', 'class');
     $toMerge = new HtmlTag(array('class' => 'second'));
     $decorator->merge($toMerge);
     $expected = '<div class="class second">foo</div>';
     $actual = $decorator->render('foo');
     $this->assertSame($expected, $actual);
 }
Ejemplo n.º 2
0
 /**
  * TableSection constructor.
  *
  * @param $tag
  * @param $rows
  * @param bool $header
  */
 public function __construct($tag, $rows, $header = false)
 {
     parent::__construct($tag);
     $this->header = $header;
     foreach ($rows as $row) {
         $this->rows[] = new TableRow($row, $header);
     }
 }
Ejemplo n.º 3
0
 public static function buildSelect($id = null, $name = null, array $values = null, $selected = null)
 {
     $options = null;
     foreach ($values as $value => $text) {
         if ($value == $current) {
             $options .= HtmlTag::option($text)->_value($value)->_selected("selected");
         } else {
             $options .= HtmlTag::option($text)->_value($value);
         }
     }
     $tag = HtmlTag::select($options)->setId($id)->setName($name);
 }
Ejemplo n.º 4
0
 /**
  * @depends	testInitialState
  * @return	null
  */
 public function testCreateStyleTagWithContentAndTypeAndSep()
 {
     $list = array('p {color: red}', 'h1 {color:blue}');
     $type = 'text/html';
     $sep = ':';
     $tag = $this->factory->createStyleTag($list, $type, $sep);
     $this->assertInstanceOf('Appfuel\\View\\Html\\Tag\\StyleTag', $tag);
     $this->assertFalse($tag->isEmpty());
     $this->assertTrue($tag->isAttribute('type'));
     $this->assertEquals($type, $tag->getAttribute('type'));
     $this->assertEquals($sep, $tag->getContentSeparator());
     $this->assertEquals($list, $tag->getContent());
 }
Ejemplo n.º 5
0
/**
 * 
 * @param UserStateInterviewSlots[] $slotStatus
 * @param RegisterController $controller Description
 */
function renderInterviewSlotStatus($slotStatus, $controller)
{
    $formatter = O::app()->getLocale()->getDateFormatter();
    $ul = HtmlTag::tag('ul');
    foreach ($slotStatus as $status) {
        if ($status->time) {
            $utime = strtotime($status->time);
            $time = O::t('oprecx', '{date} at {time}', array('{date}' => $formatter->formatDateTime($utime, 'full', null), '{time}' => $formatter->formatDateTime($utime, null, 'medium')));
        } else {
            $time = O::t('oprecx', 'You have not choosen a slot');
        }
        $ul->appendLi('<strong>' . CHtml::link($status->slot_name, $controller->getURL('interview', array('edit' => 1, 'slotid' => $status->slot_id))) . '</strong>: ' . $time);
    }
    $ul->render(true);
}
Ejemplo n.º 6
0
 public function setAttribute($attribute, $value = null)
 {
     if ($this->getTagName() === 'textarea' && $attribute === 'value') {
         return $this->addText($value);
     }
     $keys = array('select' => 'selected', 'checkbox' => 'checked', 'radio' => 'checked');
     if (isset($keys[$this->getOriginalTagName()]) && $attribute === 'value') {
         foreach ($this->children() as $child) {
             if ($child->getAttribute('value') == $value) {
                 $verb = $keys[$this->getOriginalTagName()];
                 $child->setAttribute($verb, $verb);
                 return;
             }
         }
     }
     return parent::setAttribute($attribute, $value);
 }
Ejemplo n.º 7
0
 /**
  * Render a description
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $description = $element->getDescription();
     $description = trim($description);
     if (!empty($description) && null !== ($translator = $element->getTranslator())) {
         $description = $translator->translate($description);
     }
     if (empty($description)) {
         return $content;
     }
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $class = $this->getClass();
     $escape = $this->getEscape();
     $options = $this->getOptions();
     if ($escape) {
         $description = $view->escape($description);
     }
     if (!empty($tag)) {
         $options['tag'] = $tag;
         $decorator = new HtmlTag($options);
         $description = $decorator->render($description);
     }
     switch ($placement) {
         case self::PREPEND:
             return $description . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $description;
     }
 }
Ejemplo n.º 8
0
 /**
  * Render a label
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $label = $this->getLabel();
     $separator = $this->getSeparator();
     $placement = $this->getPlacement();
     $tag = $this->getTag();
     $id = $this->getId();
     $class = $this->getClass();
     $options = $this->getOptions();
     if (empty($label) && empty($tag)) {
         return $content;
     }
     if (!empty($label)) {
         $options['class'] = $class;
         $label = $view->broker('formLabel')->direct($element->getFullyQualifiedName(), trim($label), $options);
     } else {
         $label = '&#160;';
     }
     if (null !== $tag) {
         $decorator = new HtmlTag();
         $decorator->setOptions(array('tag' => $tag, 'id' => $id . '-label'));
         $label = $decorator->render($label);
     }
     switch ($placement) {
         case self::APPEND:
             return $content . $separator . $label;
         case self::PREPEND:
             return $label . $separator . $content;
     }
 }
Ejemplo n.º 9
0
 /**
  * TableCell constructor.
  *
  * @param $content
  */
 public function __construct($content)
 {
     parent::__construct($this->tag);
     $this->content = $content;
 }
Ejemplo n.º 10
0
 public function testIdCanBeSet()
 {
     $tag = new HtmlTag('somename');
     $tag->setId('someid');
     self::assertRegExp('/<somename id="someid" \\/>/i', $tag->__toString());
 }
Ejemplo n.º 11
0
 public function __construct(HtmlTag $element)
 {
     $this->element = $element;
     $this->type = $element->getTagName();
     $this->originType = $element->getOriginType();
 }
Ejemplo n.º 12
0
 public function adminGetContainers()
 {
     $oTemplate = $this->oPage->getTemplate();
     foreach ($oTemplate->identifiersMatching('container', Template::$ANY_VALUE) as $oIdentifier) {
         $oInheritedFrom = null;
         $sContainerName = $oIdentifier->getValue();
         if (BooleanParser::booleanForString($oIdentifier->getParameter('inherit'))) {
             $oInheritedFrom = $this->oPage;
             $iInheritedObjectCount = 0;
             while ($iInheritedObjectCount === 0 && ($oInheritedFrom = $oInheritedFrom->getParent()) !== null) {
                 $iInheritedObjectCount = $oInheritedFrom->countObjectsForContainer($sContainerName);
             }
         }
         $sInheritedFrom = $oInheritedFrom ? $oInheritedFrom->getName() : '';
         $aTagParams = array('class' => 'template-container template-container-' . $sContainerName, 'data-container-name' => $sContainerName, 'data-container-string' => TranslationPeer::getString('container_name.' . $sContainerName, null, $sContainerName), 'data-inherited-from' => $sInheritedFrom);
         $oContainerTag = TagWriter::quickTag('ol', $aTagParams);
         $mInnerTemplate = new Template(TemplateIdentifier::constructIdentifier('content'), null, true);
         //Replace container info
         //…name
         $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-description'), TranslationPeer::getString('wns.page.template_container', null, null, array('container' => TranslationPeer::getString('template_container.' . $sContainerName, null, $sContainerName)), true)));
         //…additional info
         $mInnerTemplate->replaceIdentifierMultiple('content', TagWriter::quickTag('div', array('class' => 'template-container-info')));
         //…tag
         $mInnerTemplate->replaceIdentifierMultiple('content', $oContainerTag);
         //Replace actual container
         $oTemplate->replaceIdentifier($oIdentifier, $mInnerTemplate);
     }
     $bUseParsedCss = Settings::getSetting('admin', 'use_parsed_css_in_config', true);
     $oStyle = null;
     if ($bUseParsedCss) {
         $sTemplateName = $this->oPage->getTemplateNameUsed() . Template::$SUFFIX;
         $sCacheKey = 'parsed-css-' . $sTemplateName;
         $oCssCache = new Cache($sCacheKey, DIRNAME_PRELOAD);
         $sCssContents = "";
         if (!$oCssCache->entryExists() || $oCssCache->isOutdated(ResourceFinder::create(array(DIRNAME_TEMPLATES, $sTemplateName)))) {
             $oIncluder = new ResourceIncluder();
             foreach ($oTemplate->identifiersMatching('addResourceInclude', Template::$ANY_VALUE) as $oIdentifier) {
                 $oIncluder->addResourceFromTemplateIdentifier($oIdentifier);
             }
             foreach ($oIncluder->getAllIncludedResources() as $sIdentifier => $aResource) {
                 if ($aResource['resource_type'] === ResourceIncluder::RESOURCE_TYPE_CSS && !isset($aResource['ie_condition']) && !isset($aResource['frontend_specific'])) {
                     if (isset($aResource['media'])) {
                         $sCssContents .= "@media {$aResource['media']} {";
                     }
                     if (isset($aResource['file_resource'])) {
                         $sCssContents .= file_get_contents($aResource['file_resource']->getFullPath());
                     } else {
                         // Absolute link, requires fopen wrappers
                         $sCssContents .= file_get_contents($aResource['location']);
                     }
                     if (isset($aResource['media'])) {
                         $sCssContents .= "}";
                     }
                 }
             }
             $oParser = new Sabberworm\CSS\Parser($sCssContents, Sabberworm\CSS\Settings::create()->withDefaultCharset(Settings::getSetting("encoding", "browser", "utf-8")));
             $oCss = $oParser->parse();
             $this->cleanupCSS($oCss);
             $sCssContents = Template::htmlEncode($oCss->render(Sabberworm\CSS\OutputFormat::createCompact()));
             $oCssCache->setContents($sCssContents);
         } else {
             $sCssContents = $oCssCache->getContentsAsString();
         }
         $oStyle = new HtmlTag('style');
         $oStyle->addParameters(array('scoped' => 'scoped'));
         $oStyle->appendChild($sCssContents);
     }
     $sTemplate = $oTemplate->render();
     $sTemplate = substr($sTemplate, strpos($sTemplate, '<body') + 5);
     $sTemplate = substr($sTemplate, strpos($sTemplate, '>') + 1);
     $sTemplate = substr($sTemplate, 0, strpos($sTemplate, '</body'));
     $oParser = new TagParser("<body>{$sTemplate}</body>");
     $oTag = $oParser->getTag();
     $this->cleanupContainerStructure($oTag);
     if ($bUseParsedCss) {
         $oTag->appendChild($oStyle);
     }
     $sResult = $oTag->__toString();
     $sResult = substr($sResult, strpos($sResult, '<body>') + 6);
     $sResult = substr($sResult, 0, strrpos($sResult, '</body>'));
     return array('html' => $sResult, 'css_parsed' => $bUseParsedCss);
 }
Ejemplo n.º 13
0
 public static function createElement($tag = '')
 {
     self::$_instance = new HtmlTag($tag);
     return self::$_instance;
 }
Ejemplo n.º 14
0
 public function afterExecuteRoute($dispatcher)
 {
     return;
     //$this->response->setContent($this->htmlDoc);
     //$this->htmlDoc->getBody()->setContent($this->response->getContent());
     //$this->response->setContent($this->htmlDoc);
     //return $this->response->send();
     //$item = new Doc();
     $item = new HtmlModel(array('tag' => new Doc()));
     //var_dump ($doctag->getChild('html')->setAttribute('lang', 'gb'));
     echo '<pre><code>' . htmlentities($item) . '</code></pre>';
     return;
     $test = HtmlTag::factory(array('tagname' => 'doc', 'children' => array('doctype' => array('tagname' => 'doctype'))));
     echo '<pre><code>';
     var_dump($test);
     echo '</code></pre>';
     return;
     // Set up the assets manager to not output directly
     $this->assets->useImplicitOutput(false);
     // Compile everything into the assets manager
     foreach ($this->htmldoc['css'] as $css) {
         if (Text::startsWith($css, 'http')) {
             $this->assets->addCss($css, false);
         } elseif (Text::startsWith($css, 'files/')) {
             $this->assets->addCss($css);
         } else {
             $this->assets->addInlineCss($css);
         }
     }
     foreach ($this->htmldoc['js'] as $js) {
         if (Text::startsWith($js, 'http')) {
             $this->assets->addJs($js, false);
         } elseif (Text::startsWith($js, 'files/')) {
             $this->assets->addJs($js);
         } else {
             $this->assets->addInlineJs($js);
         }
     }
     $this->assets->collection('jsfooter');
     foreach ($this->htmldoc['jsfooter'] as $js) {
         if (Text::startsWith($js, 'http')) {
             $this->assets->collection('jsfooter')->addJs($js, false);
         } elseif (Text::startsWith($js, 'files/')) {
             $this->assets->collection('jsfooter')->addJs($js);
         } else {
             $this->assets->addInlineJs($js);
         }
     }
     $this->htmldoc['meta-src'] = '';
     foreach ($this->htmldoc['meta'] as $meta) {
         $this->htmldoc['meta-src'] .= $this->tag->tagHtml('meta', $meta, true, true, true);
     }
     // Create the css view variable
     $this->htmldoc['css-src'] = $this->assets->outputCss();
     $this->htmldoc['css-inline-src'] = $this->assets->outputInlineCss();
     // Create the javascript view variables
     // Inline scripts are separated
     $this->htmldoc['js-src'] = $this->assets->outputJs();
     $this->htmldoc['js-inline-src'] = $this->assets->outputInlineJs();
     // Create the footer javascript view variable
     $this->htmldoc['jsfooter-src'] = $this->assets->outputJs('jsfooter');
     // Create the import view variable
     $this->htmldoc['import-src'] = '';
     foreach ($this->htmldoc['import'] as $import) {
         $this->htmldoc['import-src'] .= $this->tag->tagHtml('link', array('rel' => 'import', 'href' => $this->url->get($import)), true, true, true);
     }
     // Create the menu items
     $this->htmldoc['menu-items'] = $this->_parse_menu_items($this->htmldoc['menu']);
     // Add the variables to the view
     $this->view->setVar('htmldoc', $this->htmldoc);
     $this->view->setVar('menu', $this->view->getPartial('shared/menu'));
 }
Ejemplo n.º 15
0
    <h2><?php 
echo O::t('oprecx', 'Welcome to Oprecx!');
?>
</h2>
    <?php 
//echo O::t('oprecx', '<p>Oprecx is web based open recruitment system')
?>
    <p>Oprecx adalah sistem rekruitmen terbuka berbasis web.</p>
    <hr />

    <h2><?php 
echo O::t('oprecx', 'Active Open Recruitment');
?>
</h2>
    
    <?php 
/* @var $rec Recruitment */
//JqmTag::listview()->render(TRUE);
//*
if ($recs) {
    $ul = JqmTag::listview()->inset()->theme('d')->icon('false')->data('filter', true)->data('filter-placeholder', O::t('oprecx', 'Search recruitment'));
    foreach ($recs as $rec) {
        $ul->appendLvItem(HtmlTag::link($rec->full_name, array('registration/default/index', 'rec_name' => $rec->name)));
    }
    $ul->render(true);
}
// */
?>

</div>
Ejemplo n.º 16
0
Archivo: Image.php Proyecto: rexmac/zf2
 /**
  * Render a form image
  *
  * @param  string $content
  * @return string
  */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $tag = $this->getTag();
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     $name = $element->getFullyQualifiedName();
     $attribs = $this->getAttribs();
     $attribs['id'] = $element->getId();
     $image = $view->formImage($name, $element->getImageValue(), $attribs);
     if (null !== $tag) {
         $decorator = new HtmlTag();
         $decorator->setOptions(array('tag' => $tag));
         $image = $decorator->render($image);
     }
     switch ($placement) {
         case self::PREPEND:
             return $image . $separator . $content;
         case self::APPEND:
         default:
             return $content . $separator . $image;
     }
 }
	protected function showEmail( $step ) {
		$header = new HtmlTag( 'h2' );
		$step_message = 'translate-fs-email-title';
		$header->style( 'opacity', 0.4 )->content( wfMsg( $step_message ) );

		if ( $step && ( $step !== 'translate-fs-target-title' && $step !== 'translate-fs-permissions-title' ) ) {
			$this->out->addHtml( $header );
			return $step;
		}

		if ( $this->user->isEmailConfirmed() ) {
			$header->content( $header->content . wfMsg( 'translate-fs-pagetitle-done' ) );
			$this->out->addHtml( $header );
			return $step; // Start translating step
		}

		$this->out->addHtml( $header->style( 'opacity', false ) );
		$this->out->addWikiMsg( 'translate-fs-email-text' );

		return $step_message;
	}