public function setItem($name, $value, $raw = false) { if ($raw) { $this->items[$name] = $value; } else { $this->items[$name] = utf8_encode(htmlnumericentities($value)); } return $this; }
} else { $returnType = "nodes"; } $arr = $node->{$func}($returnType, distanceTo($distance, $node), 5); for ($i = 0; $i < count($arr); $i++) { // Now let's create the display $art = $arr[$i]->getMainArt(); $imgUrl = jzCreateLink($art, "image"); $urlArr = array(); $urlArr['action'] = "playlist"; $urlArr['jz_path'] = $arr[$i]->getPath("String"); if ($distance == "track") { $urlArr['type'] = "track"; } $title_add = ""; if ($showPlays) { $title_add = ' (' . $arr[$i]->getPlayCount() . ')'; } if ($showDownload) { $title_add = ' (' . $arr[$i]->getDownloadCount() . ')'; } // Now that we have the data let's echo it echo '<item rdf:about="' . $this_site . str_replace("rss.php", "index.php", str_replace("&", "&", urlize($urlArr))) . '">' . "\n"; echo ' <title>' . htmlnumericentities($arr[$i]->getName() . $title_add) . '</title>' . "\n"; echo ' <link>' . $this_site . str_replace("rss.php", "index.php", str_replace("&", "&", urlize($urlArr))) . '</link>' . "\n"; echo ' <description><![CDATA[' . nl2br($arr[$i]->getDescription()) . ']]></description>' . "\n"; echo '</item>' . "\n"; } } // Now let's close out... echo '</rdf:RDF>';
function createFeed() { $feed = "<?xml version=\"1.0\" encoding=\"" . $this->encoding . "\"?>\n"; $feed .= $this->_createGeneratorComment(); $feed .= $this->_createStylesheetReferences(); $feed .= "<opml xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n"; $feed .= " <head>\n"; $feed .= " <title>" . htmlspecialchars($this->title) . "</title>\n"; if ($this->pubDate != "") { $date = new FeedDate($this->pubDate); $feed .= " <dateCreated>" . $date->rfc822() . "</dateCreated>\n"; } if ($this->lastBuildDate != "") { $date = new FeedDate($this->lastBuildDate); $feed .= " <dateModified>" . $date->rfc822() . "</dateModified>\n"; } if ($this->editor != "") { $feed .= " <ownerName>" . $this->editor . "</ownerName>\n"; } if ($this->editorEmail != "") { $feed .= " <ownerEmail>" . $this->editorEmail . "</ownerEmail>\n"; } $feed .= " </head>\n"; $feed .= " <body>\n"; for ($i = 0; $i < count($this->items); $i++) { $feed .= " <outline type=\"rss\" "; $title = utf8_encode(htmlnumericentities(strip_tags(strtr($this->items[$i]->title, "\n\r", " ")))); $feed .= " title=\"" . $title . "\""; $feed .= " text=\"" . $title . "\""; //$feed.= " description=\"".htmlspecialchars($this->items[$i]->description)."\""; $feed .= " url=\"" . htmlspecialchars($this->items[$i]->link) . "\""; $feed .= "/>\n"; } $feed .= " </body>\n"; $feed .= "</opml>\n"; return $feed; }
function test_numericentities() { $raw = 'AB-' . chr(163) . '-cd'; $cooked = 'AB-£-cd'; $this->assertTrue(htmlnumericentities($raw) == $cooked); }
/** * Description: Converts value into xml CDATA * Who/When: Denis, Zenkovich 8 June 2006, dzen@scand.com **/ function data2xml($value, $key = "CustomData") { $value = str_replace("[", "[", $value); $value = str_replace("]", "]", $value); $value = htmlnumericentities($value); $value = str_replace(">", ">", $value); $value = str_replace("<", "<", $value); $value = str_replace("&", "&", $value); return '<' . $key . '><![CDATA[' . $value . ']]></' . $key . '>'; }