Beispiel #1
0
 public function __construct($name = null)
 {
     $this->_xmlloader = new \XMLLoader();
     $this->_xmlloader->setRootName('theme');
     $filename = ROOT_PDIR . 'themes/' . $name . '/theme.xml';
     if (!$this->_xmlloader->loadFromFile($filename)) {
         throw new \Exception('Parsing of XML Metafile [' . $filename . '] failed, not valid XML.');
     }
 }
	public function execute(){

		// If it exists and is good, nothing else needs to be done, (other than flush the session data)
		// This is hit if the user has to manually copy in the configuration.xml data.
		if(file_exists(ROOT_PDIR . '/config/configuration.xml')){
			unset($_SESSION['configs']);
			$this->setAsPassed();
			reload();
		}

		// Load in the configuration example, merge in the SESSION data, and apply them or display the code.
		$xml = new \XMLLoader();
		$xml->setRootName('configuration');
		$xml->loadFromFile(ROOT_PDIR . 'config/configuration.example.xml');

		$elements = $xml->getElements('return|define');
		foreach($elements as $el){
			$name        = $el->getAttribute('name');
			$children    = $el->childNodes;

			foreach($children as $c){
				if($c->nodeName == 'value'){
					// This one requires a random string.
					if($name == 'SECRET_ENCRYPTION_PASSPHRASE' && isset($_SESSION['configs'][$name]) && $_SESSION['configs'][$name] == 'RANDOM'){
						$value = \Core\random_hex(96);
						$c->nodeValue = $value;
					}
					elseif($name == 'SERVER_ID' && isset($_SESSION['configs'][$name]) && $_SESSION['configs'][$name] == 'RANDOM'){
						// The server ID is a 32-digit random string.
						$value = \Core\random_hex(32);
						$c->nodeValue = $value;
					}
					// An override is provided, use that and overwrite the xml.
					elseif(isset($_SESSION['configs'][$name])){
						$value = $_SESSION['configs'][$name];
						$c->nodeValue = $value;
					}
				}
			}
		}

		// Try to save this back down.
		$fdata = $xml->asPrettyXML();

		if(is_writable(ROOT_PDIR . '/config')){
			// Just automatically copy it over, (with the necessary tranformations).
			file_put_contents(ROOT_PDIR . 'config/configuration.xml', $fdata);
			unset($_SESSION['configs']);
			$this->setAsPassed();
			reload();
			// :)
		}
		else{
			// Display the instructions to the user.
			$this->getTemplate()->assign('contents', $fdata);
		}
	}
	public function __construct($filename = null) {
		$this->_file = \Core\Filestore\Factory::File($filename);

		$this->_xmlloader = new XMLLoader();
		$this->_xmlloader->setRootName('component');

		if (!$this->_xmlloader->loadFromFile($filename)) {
			throw new Exception('Parsing of XML Metafile [' . $filename . '] failed, not valid XML.');
		}
	}
Beispiel #4
0
	/**
	 * Get the associated XMLLoader object for this data
	 *
	 * @return \XMLLoader
	 */
	public function getLoader(){
		$xml = new \XMLLoader();
		$xml->loadFromFile($this->_file);
		return $xml;
	}
Beispiel #5
0
			$bundlefiles[] = $file;
		}
		closedir($dh);
	}
}

// They should be in alphabetical order...
sort($bundlefiles);

// Transpose them to the keyname => human readable name.
foreach($bundlefiles as $b){
	// Open it up
	$xml = new XMLLoader();
	$xml->setRootName('bundler');
	$xml->loadFromFile($dir . '/' . $b);

	$name  = $xml->getRootDOM()->getAttribute('name');
	$sname = preg_replace('/[^a-z0-9-\.\+]*/i', '', str_replace(' ', '-', $name));
	$bundles[] = [
		'file'  => $b,
		'name'  => $name,
		'sname' => $sname,
		'xml'   => $xml,
	];
}


if(!sizeof($bundles)){
	echo "No bundles found, exporting will bundle the entire site." . NL;
	$bundles[] = [
	public function execute(){

		// If there's already a configuration file present... just skip to the next.
		if(file_exists(ROOT_PDIR . '/config/configuration.xml')){
			$this->setAsPassed();
			reload();
		}

		// This will contain the temporary configuration values for the installer.
		if(!isset($_SESSION['configs'])) $_SESSION['configs'] = [];

		$xml = new \XMLLoader();
		$xml->setRootName('configuration');
		$xml->loadFromFile(ROOT_PDIR . 'config/configuration.example.xml');
		$formelements = [];

		// Since we're pulling from the ant version, set some nice defaults for the user.
		$valuedefaults = [
			'@{db.server}@' => 'localhost',
			'@{db.port}@' => '3306',
			'@{db.type}@' => 'mysqli',
			'@{db.name}@' => '',
			'@{db.user}@' => '',
			'@{db.pass}@' => '',
			'@{devmode}@' => 'false',
			'/tmp/coreplus-web/' => '/tmp/' . $_SERVER['HTTP_HOST'] . '-web/',
			'/tmp/coreplus-cli/' => '/tmp/' . $_SERVER['HTTP_HOST'] . '-cli/',
			'RANDOM' => \Core\random_hex(96),
		];

		$elements = $xml->getElements('return|define');
		foreach($elements as $el){
			$node        = $el->nodeName;
			$name        = $el->getAttribute('name');
			$type        = $el->getAttribute('type');
			$formtype    = $el->getAttribute('formtype');
			$advanced    = $el->getAttribute('advanced');
			$children    = $el->childNodes;
			$value       = null;
			$valuenode   = null;
			$description = null;
			$options     = [];

			// Defaults
			if($advanced === null || $advanced === '') $advanced = "1";

			foreach($children as $c){
				switch($c->nodeName){
					case 'value':
						$value = trim($c->nodeValue);
						$valuenode = $c;
						break;
					case 'description':
						$description = trim($c->nodeValue);
						break;
					case 'option':
						$options[] = trim($c->nodeValue);
						break;
					case '#text':
						break;
					case '#comment':
						break;
					default:
						trigger_error('Unknown sub-node for ' . $node . ' ' . $name . ': ' . $c->nodeName);
				}
			}

			// Since we're pulling from the ant version, set some nice defaults for the user.
			if(isset($valuedefaults[$value])){
				$value = $valuedefaults[$value];
			}

			// Save the value?
			if($_SERVER['REQUEST_METHOD'] == 'POST'){
				if($type == 'boolean' && $formtype == 'checkbox'){
					$value = isset($_POST[$name]) ? 'true' : 'false';
				}
				else{
					$value = isset($_POST[$name]) ? $_POST[$name] : '';
				}

				$_SESSION['configs'][$name] = $value;
			}
			elseif(isset($_SESSION['configs'][$name])){
				$value = $_SESSION['configs'][$name];
			}

			//$value = $el->getElement('value')->nodeValue;

			// Throw this element onto the array for the template to render out.
			$formelements[] = [
				'name'        => $name,
				// Make the title more appealing than machine names...
				'title'       => ucwords(strtolower(str_replace('_', ' ', $name))),
				// Remap "formtype" to "type", since this will be used in a form afterall!
				'type'        => $formtype,
				'value'       => $value,
				'description' => $description,
				'options'     => $options,
				'advanced'    => $advanced,
			];
		}


		// If it's a POST... try the settings and if valid, proceed.
		$message = null;
		$instructions = null;

		if($_SERVER['REQUEST_METHOD'] == 'POST'){
			if($message === null){
				$connectionresults = $this->testDatabaseConnection();
				if($connectionresults['status'] != 'passed'){
					//var_dump($connectionresults); die();
					$message = $connectionresults['message'];
					$instructions = $connectionresults['instructions'];
				}
			}

			if($message === null){
				// Test the assets too!
				$results = $this->testDirectoryWritable('assets/');
				if($results['status'] != 'passed'){
					//var_dump($connectionresults); die();
					$message = $results['message'];
					$instructions = $results['instructions'];
				}
			}

			if($message === null){
				// Test the assets too!
				$results = $this->testDirectoryWritable('public/');
				if($results['status'] != 'passed'){
					//var_dump($connectionresults); die();
					$message = $results['message'];
					$instructions = $results['instructions'];
				}
			}


			if($message === null){
				// Still null after all the tests have ran?
				// w00t!
				$this->setAsPassed();
				reload();
			}
		}

		$this->getTemplate()->assign('message', $message);
		$this->getTemplate()->assign('instructions', $instructions);
		$this->getTemplate()->assign('formelements', $formelements);
		//var_dump($formelements);// die();
	}
Beispiel #7
0
	unset($file, $version, $title, $c, $dh);

	// Load in all themes currently on the system
	$dir = ROOT_PDIR . 'themes';
	$dh = opendir($dir);
	while(($file = readdir($dh)) !== false){
		if($file{0} == '.') continue;
		if(!is_dir($dir . '/' . $file)) continue;
		if(!is_readable($dir . '/' . $file . '/' . 'theme.xml')) continue;

		$t = ThemeHandler::GetTheme($file);

		// What's this file's version?
		$xml = new XMLLoader();
		$xml->setRootName('theme');
		if(!$xml->loadFromFile($dir .  '/' . $file . '/theme.xml')){
			CLI::PrintLine('Skipping theme ' . $file . ', unable to load XML file');
			continue;
		}

		// Get the current version, this will be used to autocomplete for the next version.
		//$version = $xml->getRootDOM()->getAttribute("version");
		$version = $t->getVersion();

		// If display versions is requested, tack on the version number too!
		if($opts['listversions']){
			$title = 'Theme/' . $t->getName() . ' ' . $version;
		}
		else{
			$title = '    Theme ' . $t->getName();
		}