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; }
/** * 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; }
/** * @testdox export('"\'') returns concat('"',"'") */ public function testExportBothQuotes2() { $this->assertSame("concat('\"',\"'\")", XPathHelper::export('"\'')); }