<?php
/*----------------------------------------------------------------------------*/
	
	namespace Apps\Wiki\Actors;
	
	class Location extends \Libs\Actor {
		public function execute(\Libs\DOM\Element $element) {
			parent::execute($element);
			
			ini_set('html_errors', true);
			
			$session = \Libs\Session::current();
			$settings = $session->app()->settings();
			$parameters = $session->parameters();
			
			$url = $parameters->{'document-url'}->get();
			$documents = (
				$url != ''
					? $documents = explode('/', $url)
					: array()
			);
			$path = '';
			
			foreach ($documents as $document) {
				$path = ltrim($path . '/' . $document, '/');
				$item = $element->ownerDocument->createElement('item');
				$item->setAttribute('path', $path);
				$item->setAttribute('name', str_replace('-', ' ', $document));
				$element->appendChild($item);
			}
		}
	}
	
/*----------------------------------------------------------------------------*/
?>
<?php
/*----------------------------------------------------------------------------*/
	
	namespace Apps\Wiki\Actors;
	
	class Location extends \Libs\Actor {
		public function execute(\Libs\DOM\Element $element) {
			parent::execute($element);
			
			ini_set('html_errors', true);
			
			$session = \Libs\Session::current();
			$settings = $session->app()->settings();
			$constants = $session->constants();
			$parameters = $session->parameters();
			$document = $element->ownerDocument;
			
			$url = $parameters->{'document-url'}->get();
			$files = (
				$url != ''
					? explode('/', $url)
					: array()
			);
			$path = '';
			
			foreach ($files as $file) {
				$path = $path . '/' . $file;
				$name = ucfirst(str_replace('-', ' ', $file));
				
				try {
					$xml = new \Libs\DOM\Document();
					$xml->loadHTMLFile(sprintf(
						'%s/docs%s.html',
						$constants->{'app-dir'},
						$path
					));
					$value = $xml->{'string(//h1[1])'};
					
					if ($value) $name = $value;
				}
				
				catch (\Exception $e) {
					// De-serialised name is fine.
				}
				
				$item = $document->createElement('item');
				$item->setAttribute('path', ltrim($path, '/'));
				$item->setAttribute('name', $name);
				$element->appendChild($item);
			}
		}
	}
	
/*----------------------------------------------------------------------------*/
?>
Load breadcrumb titles from documents if possible.
Load breadcrumb titles from documents if possible.
