Ejemplo n.º 1
0
 public function getTemplate()
 {
     $xsl = '<xsl:choose>';
     if (!empty($this->notIfCondition)) {
         $xsl .= '<xsl:when test="' . \htmlspecialchars($this->notIfCondition) . '"><xsl:value-of select="."/></xsl:when><xsl:otherwise><xsl:choose>';
     }
     foreach ($this->collection as $code => $template) {
         $xsl .= '<xsl:when test=".=' . \htmlspecialchars(XPathHelper::export($code)) . '">' . $template . '</xsl:when>';
     }
     $xsl .= '<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>';
     $xsl .= '</xsl:choose>';
     if (!empty($this->notIfCondition)) {
         $xsl .= '</xsl:otherwise></xsl:choose>';
     }
     return $xsl;
 }
Ejemplo n.º 2
0
 /**
  * Generate the dynamic template that renders all emoticons
  *
  * @return string
  */
 public function getTemplate()
 {
     // Build the <xsl:choose> node
     $xsl = '<xsl:choose>';
     // First, test whether the emoticon should be rendered as text if applicable
     if (!empty($this->notIfCondition)) {
         $xsl .= '<xsl:when test="' . htmlspecialchars($this->notIfCondition) . '">' . '<xsl:value-of select="."/>' . '</xsl:when>' . '<xsl:otherwise>' . '<xsl:choose>';
     }
     // Iterate over codes, create an <xsl:when> for each emote
     foreach ($this->collection as $code => $template) {
         $xsl .= '<xsl:when test=".=' . htmlspecialchars(XPathHelper::export($code)) . '">' . $template . '</xsl:when>';
     }
     // Finish it with an <xsl:otherwise> that displays the unknown codes as text
     $xsl .= '<xsl:otherwise><xsl:value-of select="."/></xsl:otherwise>';
     // Close the emote switch
     $xsl .= '</xsl:choose>';
     // Close the "notIf" condition if applicable
     if (!empty($this->notIfCondition)) {
         $xsl .= '</xsl:otherwise></xsl:choose>';
     }
     return $xsl;
 }
Ejemplo n.º 3
0
 /**
  * @testdox export('"\'') returns concat('"',"'")
  */
 public function testExportBothQuotes2()
 {
     $this->assertSame("concat('\"',\"'\")", XPathHelper::export('"\''));
 }