diff --git a/bl-kernel/abstract/plugin.class.php b/bl-kernel/abstract/plugin.class.php index 2c203aa5..a546b9b7 100644 --- a/bl-kernel/abstract/plugin.class.php +++ b/bl-kernel/abstract/plugin.class.php @@ -197,6 +197,11 @@ class Plugin { return $this->directoryName; } + public function workspace() + { + return PATH_PLUGINS_DATABASES.$this->directoryName.DS; + } + // Return TRUE if the installation success, otherwise FALSE. public function install($position=0) { diff --git a/bl-kernel/admin/controllers/developers.php b/bl-kernel/admin/controllers/developers.php new file mode 100644 index 00000000..f00846a2 --- /dev/null +++ b/bl-kernel/admin/controllers/developers.php @@ -0,0 +1,49 @@ +'.$title.''; + echo ' + + + + + + + + + '; + + foreach($array as $key=>$value) { + if($value===false) { $value = 'false'; } + elseif($value===true) { $value = 'true'; } + echo ''; + echo ''; + echo ''; + echo ''; + } + + echo ' + +
'.$key.''.Sanitize::html($value).'
+ '; +} + +// ============================================================================ +// Main before POST +// ============================================================================ + +// ============================================================================ +// POST Method +// ============================================================================ + +// ============================================================================ +// Main after POST +// ============================================================================ diff --git a/bl-kernel/admin/views/developers.php b/bl-kernel/admin/views/developers.php new file mode 100644 index 00000000..45a72355 --- /dev/null +++ b/bl-kernel/admin/views/developers.php @@ -0,0 +1,10 @@ +$L->g('Developers'), 'icon'=>'support')); + +// Constanst defined by Bludit +$constants = get_defined_constants(true); +printTable('CONSTANTS', $constants['user']); + +// Site object +printTable('$Site object database',$Site->db); diff --git a/bl-kernel/boot/init.php b/bl-kernel/boot/init.php index 65533e42..9877eb62 100644 --- a/bl-kernel/boot/init.php +++ b/bl-kernel/boot/init.php @@ -56,9 +56,6 @@ define('DB_CATEGORIES', PATH_DATABASES.'categories.php'); define('DB_TAGS', PATH_DATABASES.'tags.php'); define('DB_SYSLOG', PATH_DATABASES.'syslog.php'); -// ADMIN URI FILTER -define('ADMIN_URI_FILTER', '/admin/'); - // Log separator define('LOG_SEP', ' | '); @@ -137,6 +134,9 @@ define('EXTREME_FRIENDLY_URL', FALSE); // Permissions for new directories define('DIR_PERMISSIONS', 0755); +// Admin URI filter +define('ADMIN_URI_FILTER', '/admin/'); + // Set internal character encoding mb_internal_encoding(CHARSET); @@ -250,11 +250,20 @@ $Language = new dbLanguage( $Site->locale() ); $Login = new Login( $dbUsers ); $Url->checkFilters( $Site->uriFilters() ); -// --- Objects shortcuts --- -$L = $Language; - // --- CONSTANTS with dependency --- +// Tag URI filter +define('TAG_URI_FILTER', $Url->filters('tag')); + +// Category URI filter +define('CATEGORY_URI_FILTER', $Url->filters('category')); + +// Page URI filter +define('PAGE_URI_FILTER', $Url->filters('page')); + +// Content order by: date / position +define('ORDER_BY', $Site->orderBy()); + // --- PHP paths with dependency --- // This paths are absolutes for the OS define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS); @@ -267,7 +276,7 @@ define('THEME_DIR_LANG', THEME_DIR.'languages'.DS); // --- Absolute paths with domain --- // This paths are absolutes for the user / web browsing. define('DOMAIN', $Site->domain()); -define('DOMAIN_BASE', $Site->url()); +define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT); define('DOMAIN_THEME', DOMAIN.HTML_PATH_THEME); define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS); define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS); @@ -275,17 +284,19 @@ define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG); define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS); define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES); define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS); -define('DOMAIN_TAGS', trim(DOMAIN_BASE, '/').'/'.$Url->filters('tag',$trim=true).'/'); -define('DOMAIN_CATEGORY', trim(DOMAIN_BASE, '/').'/'.$Url->filters('category',$trim=true).'/'); -define('DOMAIN_PAGE', trim(DOMAIN_BASE, '/').'/'.$Url->filters('page',$trim=true).'/'); -define('ORDER_BY', $Site->orderBy()); +define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE.TAG_URI_FILTER, false, true)); +define('DOMAIN_CATEGORY', Text::addSlashes(DOMAIN_BASE.CATEGORY_URI_FILTER, false, true)); +define('DOMAIN_PAGE', Text::addSlashes(DOMAIN_BASE.PAGE_URI_FILTER, false, true)); $ADMIN_CONTROLLER = ''; $ADMIN_VIEW = ''; $ID_EXECUTION = uniqid(); // string 13 characters long $WHERE_AM_I = $Url->whereAmI(); +// --- Objects shortcuts --- +$L = $Language; + // DEBUG: Print constants // $arr = array_filter(get_defined_constants(), 'is_string'); // echo json_encode($arr); diff --git a/bl-kernel/page.class.php b/bl-kernel/page.class.php index 2120cee6..d1b2168e 100644 --- a/bl-kernel/page.class.php +++ b/bl-kernel/page.class.php @@ -78,6 +78,15 @@ class Page { return false; } + public function getValue($field) + { + if(isset($this->vars[$field])) { + return $this->vars[$field]; + } + + return false; + } + // Set a field with a value public function setField($field, $value, $overwrite=true) { @@ -95,7 +104,7 @@ class Page { public function content($fullContent=true, $noSanitize=true) { // This content is not sanitized. - $content = $this->getField('content'); + $content = $this->getValue('content'); if(!$fullContent) { return $this->contentBreak(); @@ -110,7 +119,7 @@ class Page { public function contentBreak() { - return $this->getField('contentBreak'); + return $this->getValue('contentBreak'); } // Returns the raw content @@ -119,7 +128,7 @@ class Page { public function contentRaw($noSanitize=true) { // This content is not sanitized. - $content = $this->getField('contentRaw'); + $content = $this->getValue('contentRaw'); if($noSanitize) { return $content; @@ -131,14 +140,14 @@ class Page { // Returns the date according to locale settings and format settings public function date() { - return $this->getField('date'); + return $this->getValue('date'); } // Returns the date according to locale settings and format as database stored // (string) $format, you can specify the date format public function dateRaw($format=false) { - $date = $this->getField('dateRaw'); + $date = $this->getValue('dateRaw'); if($format) { return Date::format($date, DB_DATE_FORMAT, $format); @@ -151,28 +160,27 @@ class Page { // (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN public function permalink($absolute=true) { - global $Url; + // Get the key of the page + $key = $this->getValue('key'); - $key = $this->getField('key'); if($absolute) { return DOMAIN_PAGE.$key; } - $filter = $Url->filters('page', true); - return trim(HTML_PATH_ROOT,'/').'/'.$filter.'/'.$key; + return HTML_PATH_ROOT.PAGE_URI_FILTER.$key; } // Returns the category key public function categoryKey() { - return $this->getField('category'); + return $this->getValue('category'); } // Returns the field from the array // categoryMap = array( 'name'=>'', 'list'=>array() ) public function categoryMap($field) { - $map = $this->getField('categoryMap'); + $map = $this->getValue('categoryMap'); if($field=='key') { return $this->categoryKey(); @@ -192,7 +200,7 @@ class Page { public function user($field=false) { // Get the user object. - $User = $this->getField('user'); + $User = $this->getValue('user'); if($field) { return $User->getField($field); @@ -204,13 +212,13 @@ class Page { // Returns the username who created the post/page public function username() { - return $this->getField('username'); + return $this->getValue('username'); } // Returns the description field public function description() { - return $this->getField('description'); + return $this->getValue('description'); } @@ -222,7 +230,7 @@ class Page { // $complete = true : full version public function relativeTime($complete = false) { $current = new DateTime; - $past = new DateTime($this->getField('date')); + $past = new DateTime($this->getValue('date')); $elapsed = $current->diff($past); $elapsed->w = floor($elapsed->d / 7); @@ -258,7 +266,7 @@ class Page { // (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma public function tags($returnsArray=false) { - $tags = $this->getField('tags'); + $tags = $this->getValue('tags'); if($returnsArray) { if($tags==false) { @@ -298,7 +306,7 @@ class Page { // (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name public function coverImage($absolute=true) { - $fileName = $this->getField('coverImage'); + $fileName = $this->getValue('coverImage'); if(empty($fileName)) { return false; } @@ -313,60 +321,60 @@ class Page { // Returns TRUE if the content has the text splited public function readMore() { - return $this->getField('readMore'); + return $this->getValue('readMore'); } public function uuid() { - return $this->getField('uuid'); + return $this->getValue('uuid'); } // Returns the field key public function key() { - return $this->getField('key'); + return $this->getValue('key'); } // Returns TRUE if the post/page is published, FALSE otherwise. public function published() { - return ($this->getField('status')==='published'); + return ($this->getValue('status')==='published'); } // Returns TRUE if the post/page is scheduled, FALSE otherwise. public function scheduled() { - return ($this->getField('status')==='scheduled'); + return ($this->getValue('status')==='scheduled'); } // Returns TRUE if the post/page is draft, FALSE otherwise. public function draft() { - return ($this->getField('status')=='draft'); + return ($this->getValue('status')=='draft'); } // Returns the title field public function title() { - return $this->getField('title'); + return $this->getValue('title'); } // Returns TRUE if the page has enabled the comments, FALSE otherwise public function allowComments() { - return $this->getField('allowComments'); + return $this->getValue('allowComments'); } // Returns the page position public function position() { - return $this->getField('position'); + return $this->getValue('position'); } // Returns the page slug public function slug() { - $explode = explode('/', $this->getField('key')); + $explode = explode('/', $this->getValue('key')); // Check if the page have a parent. if(!empty($explode[1])) { @@ -379,7 +387,7 @@ class Page { // Returns the parent key, if the page doesn't have a parent returns FALSE public function parentKey() { - $explode = explode('/', $this->getField('key')); + $explode = explode('/', $this->getValue('key')); if(isset($explode[1])) { return $explode[0]; } @@ -403,8 +411,8 @@ class Page { public function children() { $tmp = array(); - //$paths = glob(PATH_PAGES.$this->getField('key').DS.'*', GLOB_ONLYDIR); - $paths = Filesystem::listDirectories(PATH_PAGES.$this->getField('key').DS); + //$paths = glob(PATH_PAGES.$this->getValue('key').DS.'*', GLOB_ONLYDIR); + $paths = Filesystem::listDirectories(PATH_PAGES.$this->getValue('key').DS); foreach($paths as $path) { array_push($tmp, basename($path)); } diff --git a/bl-plugins/categories/plugin.php b/bl-plugins/categories/plugin.php index 9711dffe..a089f0f9 100644 --- a/bl-plugins/categories/plugin.php +++ b/bl-plugins/categories/plugin.php @@ -28,7 +28,6 @@ class pluginCategories extends Plugin { { global $Language; global $dbCategories; - global $Url; // HTML for sidebar $html = '
'; diff --git a/bl-plugins/googletools/languages/de_CH.json b/bl-plugins/google/languages/de_CH.json similarity index 100% rename from bl-plugins/googletools/languages/de_CH.json rename to bl-plugins/google/languages/de_CH.json diff --git a/bl-plugins/googletools/languages/de_DE.json b/bl-plugins/google/languages/de_DE.json similarity index 100% rename from bl-plugins/googletools/languages/de_DE.json rename to bl-plugins/google/languages/de_DE.json diff --git a/bl-plugins/googletools/languages/en_US.json b/bl-plugins/google/languages/en_US.json similarity index 96% rename from bl-plugins/googletools/languages/en_US.json rename to bl-plugins/google/languages/en_US.json index 2d3ef48b..bbe892ed 100644 --- a/bl-plugins/googletools/languages/en_US.json +++ b/bl-plugins/google/languages/en_US.json @@ -1,7 +1,7 @@ { "plugin-data": { - "name": "Google Tools", + "name": "Google", "description": "This plugin generate the meta tag to validate your site with Google Webmasters Tools and the JavaScript code to track your site with Google Analytics." }, diff --git a/bl-plugins/googletools/languages/es_AR.json b/bl-plugins/google/languages/es_AR.json similarity index 100% rename from bl-plugins/googletools/languages/es_AR.json rename to bl-plugins/google/languages/es_AR.json diff --git a/bl-plugins/googletools/languages/ja_JP.json b/bl-plugins/google/languages/ja_JP.json similarity index 100% rename from bl-plugins/googletools/languages/ja_JP.json rename to bl-plugins/google/languages/ja_JP.json diff --git a/bl-plugins/googletools/languages/nl_NL.json b/bl-plugins/google/languages/nl_NL.json similarity index 100% rename from bl-plugins/googletools/languages/nl_NL.json rename to bl-plugins/google/languages/nl_NL.json diff --git a/bl-plugins/googletools/languages/pl_PL.json b/bl-plugins/google/languages/pl_PL.json similarity index 100% rename from bl-plugins/googletools/languages/pl_PL.json rename to bl-plugins/google/languages/pl_PL.json diff --git a/bl-plugins/googletools/languages/ru_RU.json b/bl-plugins/google/languages/ru_RU.json similarity index 100% rename from bl-plugins/googletools/languages/ru_RU.json rename to bl-plugins/google/languages/ru_RU.json diff --git a/bl-plugins/googletools/languages/tr_TR.json b/bl-plugins/google/languages/tr_TR.json similarity index 100% rename from bl-plugins/googletools/languages/tr_TR.json rename to bl-plugins/google/languages/tr_TR.json diff --git a/bl-plugins/googletools/languages/uk_UA.json b/bl-plugins/google/languages/uk_UA.json similarity index 100% rename from bl-plugins/googletools/languages/uk_UA.json rename to bl-plugins/google/languages/uk_UA.json diff --git a/bl-plugins/googletools/metadata.json b/bl-plugins/google/metadata.json similarity index 59% rename from bl-plugins/googletools/metadata.json rename to bl-plugins/google/metadata.json index 8801aa07..a5c64fc0 100644 --- a/bl-plugins/googletools/metadata.json +++ b/bl-plugins/google/metadata.json @@ -2,9 +2,9 @@ "author": "Bludit", "email": "", "website": "https://plugins.bludit.com", - "version": "1.5.2", - "releaseDate": "2016-05-28", + "version": "2.0", + "releaseDate": "2017-05-26", "license": "MIT", - "compatible": "1.5.2", + "compatible": "2.0", "notes": "" -} +} \ No newline at end of file diff --git a/bl-plugins/googletools/plugin.php b/bl-plugins/google/plugin.php similarity index 55% rename from bl-plugins/googletools/plugin.php rename to bl-plugins/google/plugin.php index 06077176..9dc4f3ca 100644 --- a/bl-plugins/googletools/plugin.php +++ b/bl-plugins/google/plugin.php @@ -1,11 +1,11 @@ dbFields = array( - 'tracking-id'=>'', + 'google-analytics-tracking-id'=>'', 'google-site-verification'=>'', 'google-tag-manager'=>'' ); @@ -23,7 +23,7 @@ class pluginGoogleTools extends Plugin { $html .= '
'; $html .= ''; - $html .= ''; + $html .= ''; $html .= '
'.$Language->get('complete-this-field-with-the-tracking-id').'
'; $html .= '
'; @@ -39,21 +39,24 @@ class pluginGoogleTools extends Plugin { public function siteHead() { global $Url; + global $WHERE_AM_I; $html = ''; - if((!Text::isEmpty($this->getDbField('google-site-verification'))) && ($Url->whereAmI()=='home')) { - $html .= PHP_EOL.''.PHP_EOL; - $html .= ''.PHP_EOL; + // Google HTML tag + if( $this->getValue('google-site-verification') && ($WHERE_AM_I=='home') ) { + $html .= PHP_EOL.''.PHP_EOL; + $html .= ''.PHP_EOL; } - if(!(Text::isEmpty($this->getDbField('google-tag-manager')))) { + // Google Tag Manager + if( $this->getValue('google-tag-manager') ) { $html .= PHP_EOL."".PHP_EOL; $html .= "".PHP_EOL; + $html .= "})(window,document,'script','dataLayer','".$this->getValue('google-tag-manager')."');".PHP_EOL; $html .= "".PHP_EOL; } @@ -62,34 +65,36 @@ class pluginGoogleTools extends Plugin { public function siteBodyBegin() { - if((Text::isEmpty($this->getDbField('google-tag-manager')))) { - return false; - } + $html = ''; - $html = ''.PHP_EOL; - $html .= ''.PHP_EOL; - $html .= ''.PHP_EOL; + // Google Tag Manager + if( $this->getValue('google-tag-manager') ) { + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + $html .= ''.PHP_EOL; + } return $html; } public function siteBodyEnd() { - $html = PHP_EOL.''.PHP_EOL; - $html .= "".PHP_EOL; + // Google Analytics + if( $this->getValue('google-analytics-tracking-id') ) { + $html .= PHP_EOL.''.PHP_EOL; + $html .= "".PHP_EOL; } return $html; } -} +} \ No newline at end of file diff --git a/bl-plugins/pages/plugin.php b/bl-plugins/pages/plugin.php index e2038874..2b6285b1 100644 --- a/bl-plugins/pages/plugin.php +++ b/bl-plugins/pages/plugin.php @@ -71,8 +71,9 @@ class pluginPages extends Plugin { $html .= ''; } - // Show page list - foreach( $pages as $pageKey=>$fields ) { + // Get keys of pages + $keys = array_keys($pages); + foreach($keys as $pageKey) { // Create the page object from the page key $page = buildPage($pageKey); $html .= '
  • '; diff --git a/bl-plugins/rss/plugin.php b/bl-plugins/rss/plugin.php index a892082c..c1622b77 100644 --- a/bl-plugins/rss/plugin.php +++ b/bl-plugins/rss/plugin.php @@ -2,13 +2,45 @@ class pluginRSS extends Plugin { + public function init() + { + // Fields and default values for the database of this plugin + $this->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 .= '
    '; + + return $html; + } + private function createXML() { global $Site; global $dbPages; - global $dbPosts; 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 .= ''; @@ -16,13 +48,17 @@ class pluginRSS extends Plugin { $xml .= ''.$Site->url().''; $xml .= ''.$Site->description().''; - $posts = buildPostsForPage(0, 10, true); - foreach($posts as $Post) - { + // Get keys of pages + $keys = array_keys($pages); + foreach($keys as $pageKey) { + // Create the page object from the page key + $page = buildPage($pageKey); $xml .= ''; - $xml .= ''.$Post->title().''; - $xml .= ''.$Post->permalink(true).''; - $xml .= ''.$Post->description().''; + $xml .= ''.$page->title().''; + $xml .= ''.$page->permalink().''; + $xml .= ''.$page->contentBreak().''; + $xml .= ''.$page->dateRaw('r').''; + $xml .= ''.$page->uuid().''; $xml .= ''; } @@ -30,24 +66,14 @@ class pluginRSS extends Plugin { // New DOM document $doc = new DOMDocument(); - - // Friendly XML code $doc->formatOutput = true; - $doc->loadXML($xml); - - $doc->save(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'rss.xml'); + $doc->save($this->workspace().'rss.xml'); } - public function install($position = 0) + public function install($position=0) { parent::install($position); - - $this->createXML(); - } - - public function afterPostCreate() - { $this->createXML(); } @@ -56,21 +82,11 @@ class pluginRSS extends Plugin { $this->createXML(); } - public function afterPostModify() - { - $this->createXML(); - } - public function afterPageModify() { $this->createXML(); } - public function afterPostDelete() - { - $this->createXML(); - } - public function afterPageDelete() { $this->createXML(); @@ -78,32 +94,28 @@ class pluginRSS extends Plugin { public function siteHead() { - $html = ''.PHP_EOL; - return $html; + return ''.PHP_EOL; } public function beforeRulesLoad() { global $Url; - if( $Url->uri() === HTML_PATH_ROOT.'rss.xml' ) - { + if($Url->uri()===HTML_PATH_ROOT.'rss.xml') { // Send XML header header('Content-type: text/xml'); - - // New DOM document $doc = new DOMDocument(); // Load XML libxml_disable_entity_loader(false); - $doc->load(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'rss.xml'); + $doc->load($this->workspace().'rss.xml'); libxml_disable_entity_loader(true); // Print the XML echo $doc->saveXML(); // Stop Bludit running - exit; + exit(0); } } diff --git a/bl-plugins/sitemap/plugin.php b/bl-plugins/sitemap/plugin.php index 3af46de2..ba68bc1d 100644 --- a/bl-plugins/sitemap/plugin.php +++ b/bl-plugins/sitemap/plugin.php @@ -6,96 +6,39 @@ class pluginSitemap extends Plugin { { global $Site; global $dbPages; - global $dbPosts; global $Url; - $doc = new DOMDocument('1.0', 'UTF-8'); + $xml = ''; + $xml .= ''; - // Friendly XML code + $xml .= ''; + $xml .= ''.$Site->url().''; + $xml .= ''; + + // Get keys of pages + $keys = array_keys($dbPages->db); + foreach($keys as $pageKey) { + // Create the page object from the page key + $page = buildPage($pageKey); + $xml .= ''; + $xml .= ''.$page->permalink().''; + $xml .= ''.$page->dateRaw(SITEMAP_DATE_FORMAT).''; + $xml .= 'daily'; + $xml .= ''; + } + + $xml .= ''; + + // New DOM document + $doc = new DOMDocument(); $doc->formatOutput = true; - - // Create urlset element - $urlset = $doc->createElement('urlset'); - $attribute = $doc->createAttribute('xmlns'); - $attribute->value = 'http://www.sitemaps.org/schemas/sitemap/0.9'; - $urlset->appendChild($attribute); - - // --- Base URL --- - - // Create url, loc and lastmod elements - $url = $doc->createElement('url'); - $loc = $doc->createElement('loc', $Site->url()); - $lastmod = $doc->createElement('lastmod', Date::current(SITEMAP_DATE_FORMAT)); - - // Append loc and lastmod -> url - $url->appendChild($loc); - $url->appendChild($lastmod); - - // Append url -> urlset - $urlset->appendChild($url); - - // --- Pages and Posts --- - $all = array(); - $url = trim($Site->url(),'/'); - - // --- Pages --- - $filter = trim($Url->filters('page'),'/'); - $pages = $dbPages->getDB(); - unset($pages['error']); - foreach($pages as $key=>$db) - { - if($db['status']=='published') - { - $permalink = empty($filter) ? $url.'/'.$key : $url.'/'.$filter.'/'.$key; - $date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT); - array_push($all, array('permalink'=>$permalink, 'date'=>$date)); - } - } - - // --- Posts --- - $filter = rtrim($Url->filters('post'),'/'); - $posts = $dbPosts->getDB(); - foreach($posts as $key=>$db) - { - if($db['status']=='published') - { - $permalink = empty($filter) ? $url.'/'.$key : $url.'/'.$filter.'/'.$key; - $date = Date::format($db['date'], DB_DATE_FORMAT, SITEMAP_DATE_FORMAT); - array_push($all, array('permalink'=>$permalink, 'date'=>$date)); - } - } - - // Generate the XML for posts and pages - foreach($all as $db) - { - // Create url, loc and lastmod elements - $url = $doc->createElement('url'); - $loc = $doc->createElement('loc', $db['permalink']); - $lastmod = $doc->createElement('lastmod', $db['date']); - - // Append loc and lastmod -> url - $url->appendChild($loc); - $url->appendChild($lastmod); - - // Append url -> urlset - $urlset->appendChild($url); - } - - // Append urlset -> XML - $doc->appendChild($urlset); - - $doc->save(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'sitemap.xml'); + $doc->loadXML($xml); + $doc->save($this->workspace().'sitemap.xml'); } - public function install($position = 0) + public function install($position=0) { parent::install($position); - - $this->createXML(); - } - - public function afterPostCreate() - { $this->createXML(); } @@ -104,21 +47,11 @@ class pluginSitemap extends Plugin { $this->createXML(); } - public function afterPostModify() - { - $this->createXML(); - } - public function afterPageModify() { $this->createXML(); } - public function afterPostDelete() - { - $this->createXML(); - } - public function afterPageDelete() { $this->createXML(); @@ -128,25 +61,25 @@ class pluginSitemap extends Plugin { { global $Url; - if( $Url->uri() === HTML_PATH_ROOT.'sitemap.xml' ) - { + if($Url->uri()===HTML_PATH_ROOT.'sitemap.xml') { // Send XML header header('Content-type: text/xml'); - - // New DOM document $doc = new DOMDocument(); - // Load XML + // Workaround for a bug https://bugs.php.net/bug.php?id=62577 libxml_disable_entity_loader(false); - $doc->load(PATH_PLUGINS_DATABASES.$this->directoryName.DS.'sitemap.xml'); + + // Load XML + $doc->load($this->workspace().'sitemap.xml'); + libxml_disable_entity_loader(true); // Print the XML echo $doc->saveXML(); - // Stop Bludit running - exit; + // Terminate the run successfully + exit(0); } } -} +} \ No newline at end of file