dbFields = array(
'amountOfItems'=>5
);
}
// Method called on the settings of the plugin on the admin area
public function form()
{
global $Language;
$html = '
';
$html .= '';
$html .= '';
$html .= ''.$Language->get('Amount of items to show on the feed').'';
$html .= '
';
return $html;
}
private function createXML()
{
global $Site;
global $dbPages;
global $Url;
// Amount of pages to show
$amountOfItems = $this->getValue('amountOfItems');
// Page number the first one
$pageNumber = 1;
// Only published pages
$onlyPublished = true;
// Get the list of pages
$pages = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished, true);
$xml = '';
$xml .= '';
$xml .= '';
$xml .= ''.$Site->title().'';
$xml .= ''.$Site->url().'';
$xml .= ''.$Site->description().'';
// Get keys of pages
foreach($pages as $pageKey) {
// Create the page object from the page key
$page = buildPage($pageKey);
$xml .= '';
$xml .= ''.$page->title().'';
$xml .= ''.$page->permalink().'';
$xml .= ''.Sanitize::html($page->contentBreak()).'';
$xml .= ''.$page->dateRaw('r').'';
$xml .= ''.$page->uuid().'';
$xml .= '';
}
$xml .= '';
// New DOM document
$doc = new DOMDocument();
$doc->formatOutput = true;
$doc->loadXML($xml);
$doc->save($this->workspace().'rss.xml');
}
public function install($position=0)
{
parent::install($position);
$this->createXML();
}
public function post()
{
// Call the method
parent::post();
// After POST request
$this->createXML();
}
public function afterPageCreate()
{
$this->createXML();
}
public function afterPageModify()
{
$this->createXML();
}
public function afterPageDelete()
{
$this->createXML();
}
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();
// Load XML
libxml_disable_entity_loader(false);
$doc->load($this->workspace().'rss.xml');
libxml_disable_entity_loader(true);
// Print the XML
echo $doc->saveXML();
// Stop Bludit execution
exit(0);
}
}
}