Ejemplo n.º 1
0
 public function doWidget()
 {
     $oListTag = new TagWriter('div');
     $oListTag->addToParameter('class', 'ui-tree');
     $oListTag->setParameter('data-widget-session', $this->sPersistentSessionKey);
     $oListTag->setParameter('data-widget-type', $this->getModuleName());
     return $oListTag->parse();
 }
Ejemplo n.º 2
0
 public function doWidget()
 {
     $oElement = $this->getElementType();
     if ($oElement === null) {
         return null;
     }
     if (!$oElement instanceof TagWriter) {
         $oElement = new TagWriter($oElement);
     }
     $oElement->setParameter('data-widget-type', $this->getModuleName());
     $oElement->setParameter('data-widget-session', $this->sPersistentSessionKey);
     if ($this->sInputName !== null) {
         $oElement->setParameter('name', $this->sInputName);
     }
     return $oElement->parse();
 }
Ejemplo n.º 3
0
 public static function quickTag($sTagName = 'div', $aParameters = array(), $sContent = '')
 {
     $oTagWriter = new TagWriter($sTagName, $aParameters, $sContent);
     return $oTagWriter->parse();
 }
Ejemplo n.º 4
0
 /**
  * Does the actual parsing of the tag to produce valid XHTML output. The default implementation uses a TagWriter to produce the tag contents, passing it the name, parameters and parsed children (as string).
  *
  * If a parse callback is set, it relies on its implementation to return valid output given the parsed children.
  * Most callbacks will want to use TagWriter as well but transform the output a bit before doing so.
  */
 public function __toString()
 {
     $sParsedChildren = "";
     foreach ($this->aChildren as $mChild) {
         if ($mChild instanceof HtmlTag) {
             $sParsedChildren .= $mChild->__toString(false);
         } else {
             $sParsedChildren .= Template::htmlEncode($mChild);
         }
     }
     $sResult = "";
     if ($this->mParseCallback === null) {
         $oTagWriter = new TagWriter($this->sName, $this->aParameters, $sParsedChildren);
         $sResult = $oTagWriter->parse(true)->render();
     } else {
         $sResult = call_user_func($this->mParseCallback, $this, $sParsedChildren);
     }
     return $sResult;
 }
 public function testTemplateObjectReplace()
 {
     $oTestTemplate = new Template('{{test}}', null, true);
     $oTagWriter = new TagWriter('a');
     $oTestTemplate->replaceIdentifier('test', $oTagWriter->parse());
     $this->assertSame("<a></a>", $oTestTemplate->render());
 }
Ejemplo n.º 6
0
 public function textTagParseCallback($oHtmlTag, $sParsedChildren)
 {
     if ($oHtmlTag->getName() === 'text') {
         return $sParsedChildren;
     }
     if ($oHtmlTag->getName() === 'img') {
         if (preg_match("%display_document/(\\d+)%", $oHtmlTag->getParameter('src'), $aMatches)) {
             $aParameters = $oHtmlTag->getParameters();
             $this->addTrackReference($aMatches[1], "Document");
             return TemplateIdentifier::constructIdentifier('image', $aMatches[1], $aParameters);
         }
     }
     if ($oHtmlTag->getName() === 'a') {
         if ($sParsedChildren === '') {
             return '';
         }
         $bHasMatched = preg_match("%/" . preg_quote(Manager::getPrefixForManager('FileManager'), "%") . "/([^/]+)/(\\d+)((\\D.+)?)\$%", $oHtmlTag->getParameter('href'), $aMatches) === 1;
         if ($bHasMatched) {
             $sFileMethod = $aMatches[1];
             $iId = $aMatches[2];
             $sAdditional = $aMatches[3];
             $sIdentifier = 'file_link';
             $sModel = 'Document';
             if ($sFileMethod === 'external_link_proxy') {
                 $sIdentifier = 'external_link';
                 $sModel = 'Link';
             } else {
                 if ($sFileMethod === 'internal_link_proxy') {
                     $sIdentifier = 'internal_link';
                     $sModel = 'Page';
                 }
             }
             $this->addTrackReference($iId, $sModel);
             return TemplateIdentifier::constructIdentifier($sIdentifier, "{$iId}{$sAdditional}", array_merge($oHtmlTag->getParameters(), array('link_text' => $sParsedChildren)));
         } else {
             if (strpos($oHtmlTag->getParameter('href'), "mailto:") === 0) {
                 return TemplateIdentifier::constructIdentifier("mailto_link", substr($oHtmlTag->getParameter('href'), strlen("mailto:")), array("link_text" => $sParsedChildren));
             }
         }
     }
     $oTagWriter = new TagWriter($oHtmlTag->getName(), $oHtmlTag->getParameters(), $sParsedChildren);
     $oTagTemplate = $oTagWriter->parse(true);
     $oTagTemplate->bKillIdentifiersBeforeRender = false;
     return $oTagTemplate->render();
 }
Ejemplo n.º 7
0
 public function getMessage($sName)
 {
     if (!isset($this->aMessages[$sName])) {
         return null;
     }
     $aMessageAttribs = $this->aMessages[$sName];
     $aParameters = array();
     if (isset($aMessageAttribs[self::STRING_PARAMETERS_KEY])) {
         $aParameters = $aMessageAttribs[self::STRING_PARAMETERS_KEY];
     }
     $sStringKey = "flash.{$sName}";
     if (isset($aMessageAttribs[self::STRING_KEY_KEY])) {
         $sStringKey = $aMessageAttribs[self::STRING_KEY_KEY];
     }
     $sClassName = 'error_display';
     if (isset($aMessageAttribs[self::CLASS_NAME_KEY])) {
         $sClassName = $aMessageAttribs[self::CLASS_NAME_KEY];
     }
     $sTagName = 'span';
     if (isset($aMessageAttribs[self::TAG_NAME_KEY])) {
         $sTagName = $aMessageAttribs[self::TAG_NAME_KEY];
     }
     $oTag = new TagWriter($sTagName, array('class' => $sClassName), TranslationPeer::getString($sStringKey, null, null, $aParameters));
     return $oTag->parse();
 }