diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index 1681d480..58599541 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -1,142 +1,143 @@ -dbFields = array( - 'numberOfItems'=>5 - ); - } + public function init() + { + // Fields and default values for the database of this plugin + $this->dbFields = array( + 'numberOfItems'=>5 + ); + } - // Method called on the settings of the plugin on the admin area - public function form() - { - global $L; + // Method called on the settings of the plugin on the admin area + public function form() + { + global $L; - $html = ''; + $html = ''; - $html .= '
'; - $html .= ''; - $html .= ''.Theme::rssUrl().''; - $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= ''.Theme::rssUrl().''; + $html .= '
'; - $html .= '
'; - $html .= ''; - $html .= ''; - $html .= ''.$L->get('Amount of items to show on the feed').''; - $html .= '
'; + $html .= '
'; + $html .= ''; + $html .= ''; + $html .= ''.$L->get('Amount of items to show on the feed').''; + $html .= '
'; - return $html; - } + return $html; + } - private function createXML() - { - global $site; - global $pages; - global $url; + private function createXML() + { + global $site; + global $pages; + global $url; - // Amount of pages to show - $numberOfItems = $this->getValue('numberOfItems'); + // Amount of pages to show + $numberOfItems = $this->getValue('numberOfItems'); - // Get the list of public pages (sticky and static included) - $list = $pages->getList( - $pageNumber=1, - $numberOfItems, - $published=true, - $static=true, - $sticky=true, - $draft=false, - $scheduled=false - ); + // Get the list of public pages (sticky and static included) + $list = $pages->getList( + $pageNumber=1, + $numberOfItems, + $published=true, + $static=true, + $sticky=true, + $draft=false, + $scheduled=false + ); - $xml = ''; - $xml .= ''; - $xml .= ''; - $xml .= ''.$site->title().''; - $xml .= ''.$site->url().''; - $xml .= ''.$site->description().''; - $xml .= ''.date(DATE_RSS).''; + $xml = ''; + $xml .= ''; + $xml .= ''; + $xml .= ''; + $xml .= ''.$site->title().''; + $xml .= ''.preg_replace_callback("/[^\x20-\x7f]/", function($match) { return urlencode($match[0]); },$site->url()).''; + $xml .= ''.$site->description().''; + $xml .= ''.date(DATE_RSS).''; - // Get keys of pages - foreach ($list as $pageKey) { - try { - // Create the page object from the page key - $page = new Page($pageKey); - $xml .= ''; - $xml .= ''.$page->title().''; - $xml .= ''.$page->permalink().''; - $xml .= ''.Sanitize::html($page->contentBreak()).''; - $xml .= ''.date('r',strtotime($page->getValue('dateRaw'))).''; - $xml .= ''.$page->uuid().''; - $xml .= ''; - } catch (Exception $e) { - // Continue - } - } + // Get keys of pages + foreach ($list as $pageKey) { + try { + // Create the page object from the page key + $page = new Page($pageKey); + $xml .= ''; + $xml .= ''.$page->title().''; + $xml .= "".preg_replace_callback('/[^\x20-\x7f]/',function($match){return urlencode($match[0]);},$page->permalink()).""; + $xml .= ''.Sanitize::html($page->contentBreak()).''; + $xml .= ''.date('r',strtotime($page->getValue('dateRaw'))).''; + $xml .= ''.$page->uuid().''; + $xml .= ''; + } catch (Exception $e) { + // Continue + } + } - $xml .= ''; + $xml .= ''; - // New DOM document - $doc = new DOMDocument(); - $doc->formatOutput = true; - $doc->loadXML($xml); - return $doc->save($this->workspace().'rss.xml'); - } + // New DOM document + $doc = new DOMDocument(); + $doc->formatOutput = true; + $doc->loadXML($xml); + return $doc->save($this->workspace().'rss.xml'); + } - public function install($position=0) - { - parent::install($position); - return $this->createXML(); - } + public function install($position=0) + { + parent::install($position); + return $this->createXML(); + } - public function post() - { - parent::post(); - return $this->createXML(); - } + public function post() + { + parent::post(); + return $this->createXML(); + } - public function afterPageCreate() - { - $this->createXML(); - } + public function afterPageCreate() + { + $this->createXML(); + } - public function afterPageModify() - { - $this->createXML(); - } + public function afterPageModify() + { + $this->createXML(); + } - public function afterPageDelete() - { - $this->createXML(); - } + public function afterPageDelete() + { + $this->createXML(); + } - public function siteHead() - { - return ''.PHP_EOL; - } + public function siteHead() + { + return ''.PHP_EOL; + } - public function beforeAll() - { - $webhook = 'rss.xml'; - if ($this->webhook($webhook)) { - // Send XML header - header('Content-type: text/xml'); - $doc = new DOMDocument(); + public function beforeAll() + { + $webhook = 'rss.xml'; + if ($this->webhook($webhook)) { + // Send XML header + header('Content-type: text/xml'); + $doc = new DOMDocument(); - // Load XML - libxml_disable_entity_loader(false); - $doc->load($this->workspace().'rss.xml'); - libxml_disable_entity_loader(true); + // Load XML + libxml_disable_entity_loader(false); + $doc->load($this->workspace().'rss.xml'); + libxml_disable_entity_loader(true); - // Print the XML - echo $doc->saveXML(); + // Print the XML + echo $doc->saveXML(); - // Stop Bludit execution - exit(0); - } - } + // Stop Bludit execution + exit(0); + } + } }