From d9bfd73fdf560794676e7823e66c20c8dad08dd9 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Fri, 4 Nov 2011 15:20:13 -0500 Subject: [PATCH 01/66] testing stuff --- src/pulltester.php | 468 ++++++++++++++++++++++++++++++++++++++------- 1 file changed, 399 insertions(+), 69 deletions(-) diff --git a/src/pulltester.php b/src/pulltester.php index 11d1fcc..e456930 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -10,7 +10,6 @@ define('_JEXEC', 1); - /** * Turn on strict error reporting during development */ @@ -26,6 +25,8 @@ define('JPATH_SITE', JPATH_BASE); define('PATH_CHECKOUTS', dirname(dirname(__FILE__)).'/checkouts'); +define('PATH_OUTPUT', '/home/elkuku/eclipsespace/indigogit3/pulltester-gh-pages'); + jimport('joomla.application.cli'); jimport('joomla.database'); jimport('joomla.database.table'); @@ -44,6 +45,14 @@ class PullTester extends JCli protected $report = null; + protected $reportHtml = ''; + + protected $verbose = false; + + protected $phpUnitDebug = ''; + + protected $startTime = 0; + /** * Execute the application. * @@ -53,20 +62,82 @@ class PullTester extends JCli */ public function execute() { + $this->startTime = microtime(true); + + $this->verbose = $this->input->get('v', 0); + + $selectedPull = $this->input->get('pull', 0, 'INT'); + + $this->output('----------------------'); + $this->output('-- Ian\'s PullTester --'); + $this->output('----------------------'); + JTable::addIncludePath(JPATH_BASE.'/tables'); + $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); + + $this->output('Fetching pull requests...', false); + $pulls = $this->github->pulls->getAll($this->config->get('github_project'), $this->config->get('github_repo'), 'open', 0, 100); + $this->output('OK'); + + $this->output('Creating the base repo...', false); $this->createRepo(); + $this->output('OK'); + + foreach ($pulls AS $pull) + { + if($selectedPull && $selectedPull != $pull->number) + { + $this->output('Skipping pull '.$pull->number); + continue; + } + + $this->output('Processing pull '.$pull->number.'...'); - foreach ($pulls AS $pull) { $this->report = ''; + $this->reportHtml = ''; $this->processPull($pull); + + $this->output('OK'); + + $t = microtime(true); + + $this->output(($t - $this->startTime).' secs'); + $this->output('------------------------'); } + $this->totalTime = microtime(true) - $this->startTime; + + $this->output('Finished in '.$this->totalTime.' secs =;)'); + + $this->generateStatsTable(); + $this->close(); } + protected function getIndexData() + { + $db = JFactory::getDbo(); + + $query = $db->getQuery(true); + + $query->from('pulls AS p'); + $query->select('p.pull_id, p.mergeable'); + $query->select('cs.warnings AS CS_warnings, cs.errors AS CS_errors'); + $query->select('pu.failures AS Unit_failures, pu.errors AS Unit_errors'); + + $query->leftJoin('phpCsResults AS cs on p.id=cs.pulls_id'); + $query->leftJoin('phpunitResults AS pu on p.id=pu.pulls_id'); + + $db->setQuery($query); + + $data = $db->loadObjectList(); + + return $data; + } + protected function processPull($pull) { $results = new stdClass; @@ -91,9 +162,8 @@ protected function processPull($pull) // Step 1: See if the pull request will merge // right now we do this strictly based on what github tells us - $mergeable = $pullRequest->mergeable; - if ($mergeable) + if ($pullRequest->mergeable) { // Step 2: We try and git the repo and perform the build $this->build($pullRequest); @@ -101,19 +171,24 @@ protected function processPull($pull) } else { + $this->report .= 'This pull request could not be tested since the changes could not be cleanly merged.'; + $this->reportHtml .= '

This pull request could not be tested since the changes could not be cleanly merged.

'."\n"; + // if it was mergeable before and it isn't mergeable anymore, report that if ($this->table->mergeable) { - $changed = true; + $this->report .= '...but it was mergeable before and it isn\'t mergeable anymore...'; + $this->reportHtml .= '

...but it was mergeable before and it isn\'t mergeable anymore...

'."\n"; - $this->report .= 'This pull request could not be tested since the changes could not be cleanly merged.'; } + + $changed = true; } } if ($changed) { - if ($mergeable) + if ($pullRequest->mergeable) { $this->processResults($pullRequest); } @@ -132,7 +207,7 @@ public function loadPull($pull) $this->table->pull_id = $pull->number; $this->table->head = $pull->head->sha; $this->table->base = $pull->base->sha; - $this->table->mergeable = true; + $this->table->mergeable = $pull->mergeable; $this->table->store(); return false; } @@ -142,8 +217,22 @@ public function loadPull($pull) protected function createRepo() { - if (!file_exists(PATH_CHECKOUTS . '/pulls')) + if (!file_exists(PATH_CHECKOUTS)) + { + mkdir(PATH_CHECKOUTS); + } + + if (file_exists(PATH_CHECKOUTS . '/pulls')) { + //-- Update existing repository + // chdir(PATH_CHECKOUTS.'/pulls'); + // exec('git checkout staging'); + // exec('git fetch origin'); + // exec('git merge origin/staging'); + } + else + { + //-- Clone repository chdir(PATH_CHECKOUTS); exec('git clone git@github.com:joomla/joomla-platform.git pulls'); } @@ -165,19 +254,55 @@ protected function build($pull) exec('git remote add ' . $pull->user->login . ' ' . $pull->head->repo->git_url); } - exec('git checkout staging'); - exec('git checkout -b pull' . $pull->number); + exec('git checkout staging 2>/dev/null'); + + //-- Just in case, if, for any oscure reason, the branch we are trying to create already exists... + //-- git wont switch to it and will remain on the 'staging' branch so... + //-- let's first try to delete it =;) + exec('git branch -D pull'.$pull->number.' 2>/dev/null'); + + exec('git checkout -b pull'.$pull->number); + + $this->output('Fetch repo: '.$pull->user->login); + exec('git fetch ' . $pull->user->login); exec('git merge ' . $pull->user->login . '/' . $pull->head->ref); - exec('ant clean'); - exec('ant phpunit'); - exec('ant phpunit'); + // exec('ant clean'); + exec('rm build/logs/junit.xml 2>/dev/null'); + + $this->output('Running PHPUnit...', false); + + ob_start(); + // exec('ant phpunit'); + // exec('ant phpunit'); - exec('ant phpcs'); + echo shell_exec('phpunit 2>&1'); - exec('git checkout staging'); + $this->phpUnitDebug = ob_get_clean(); + + $this->output('OK'); + + $this->output('Running the CodeSniffer...', false); + // exec('ant phpcs'); + exec('mkdir build/logs 2>/dev/null'); + exec('touch build/logs/checkstyle.xml'); + + echo shell_exec('phpcs' + // .' -p' + .' --report=checkstyle' + .' --report-file='.PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' + .' --standard=' + .'/home/elkuku/libs/joomla/' + // .$basedir + .'build/phpcs/Joomla' + .' libraries/joomla' + .' 2>&1'); + + $this->output('OK'); + + exec('git checkout staging 2>/dev/null'); exec('git branch -D pull' . $pull->number); } @@ -198,107 +323,304 @@ protected function publishResults($pullRequest) if ($pullRequest->base->ref != 'staging') { $this->report .= "\n\n" . '**WARNING! Pull request is not against staging!**'; + $this->reportHtml .= '

Pull request is not against staging!

'."\n"; } //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); //curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request)); file_put_contents(PATH_CHECKOUTS . '/pull' . $pullRequest->number . '.txt', $this->report); - echo $this->report; + + $html = ''; + $html .= $this->getHead($pullRequest->number.' Test results'); + + $html .= ''."\n"; + + $html .= '⇐ Index'."\n"; + + $html .= '

Results for ' + .'pull request #'.$pullRequest->number.'

'."\n"; + + $html .= $this->reportHtml; + + $html .= ''; + $html .= ''; + + file_put_contents(PATH_OUTPUT . '/' . $pullRequest->number . '.html', $html); + + //echo $this->report; } - protected function parsePhpUnit() + protected function generateStatsTable() { - if (file_exists(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml')) - { - $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); + $data = $this->getIndexData(); + $html = $this->getHead('Test results overview'); + $html .= ''; - $reader = new XMLReader(); - $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); - while ($reader->read() && $reader->name !== 'testsuite'); + $html .= '

Test results overview

'; + + $html .= ''; + + if(isset($data[0])) + { + $html .= ''; + + foreach ($data[0] as $key => $v) + { + $html .= ''; + } + $html .= ''; + } - $phpUnitTable->tests = $reader->getAttribute('tests'); - $phpUnitTable->assertions = $reader->getAttribute('assertions'); - $phpUnitTable->failures = $reader->getAttribute('failures'); - $phpUnitTable->errors = $reader->getAttribute('errors'); - $phpUnitTable->time = $reader->getAttribute('time'); - $phpUnitTable->pulls_id = $this->table->id; - $phpUnitTable->store(); + foreach ($data as $entry) + { + $html .= ''; - $errors = array(); - $failures = array(); + $mergeable = true; - while ($reader->read()) + foreach ($entry as $key => $value) { - if ($reader->name == 'error') + $replace = '%s'; + + if( ! $mergeable) { - $errors[] = preg_replace('#\/[A-Za-z\/]*pulls##', '', $reader->readString()); + $replace = '-'; } - - if ($reader->name == 'failure') + elseif('' == $value) { - $failures[] = preg_replace('#\/[A-Za-z\/]*pulls##', '', $reader->readString()); + $replace = '-?-'; } + else + { + switch ($key) + { + case 'pull_id': + $replace = 'Pull %1$s'; + break; + + case 'CS_warnings': + $replace =(0 == $value) ? '√' : '%d'; + break; + + case 'CS_errors': + case 'Unit_failures': + case 'Unit_errors': + $replace =(0 == $value) ? '√' : '%d'; + break; + + case 'mergeable': + $mergeable =($value) ? true : false; + $value =($value) ? '√' : '** NO **'; + break; + }//switch + } + + $html .= ''; + }//foreach + + $html .= ''."\n"; + }//foreach + + $html .= '
'.$key.'
'.sprintf($replace, $value).'
'; + + $html .= ''; + + $html .= ''; + + file_put_contents(PATH_OUTPUT.'/index.html', $html); + } + + protected function parsePhpUnit() + { + $this->reportHtml .= '

Unit Tests

'."\n"; + + if ( ! file_exists(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml')) + { + $this->report .= 'Test log missing. Tests failed to execute.' . "\n"; + $this->reportHtml .= '

Test log missing. Tests failed to execute.

'."\n"; + $d = $this->phpUnitDebug; + $d = str_replace(PATH_CHECKOUTS . '/pulls/', '', $d); + $this->reportHtml .= '
'.$d.'
'; + + return; + } + + $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); + + $reader = new XMLReader(); + $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); + while ($reader->read() && $reader->name !== 'testsuite'); + + $phpUnitTable->tests = $reader->getAttribute('tests'); + $phpUnitTable->assertions = $reader->getAttribute('assertions'); + $phpUnitTable->failures = $reader->getAttribute('failures'); + $phpUnitTable->errors = $reader->getAttribute('errors'); + $phpUnitTable->time = $reader->getAttribute('time'); + $phpUnitTable->pulls_id = $this->table->id; + $phpUnitTable->store(); + + $errors = array(); + $failures = array(); + + while ($reader->read()) + { + if ($reader->name == 'error') + { + $errors[] = preg_replace('#\/[A-Za-z\/]*pulls#', '', $reader->readString()); } - $reader->close(); + if ($reader->name == 'failure') + { + $failures[] = preg_replace('#\/[A-Za-z\/]*pulls#', '', $reader->readString()); + } + } + + $reader->close(); + + $s = sprintf('Unit testing complete. There were %1d failures and %2d errors from %3d tests and %4d assertions.' + , $phpUnitTable->failures, $phpUnitTable->errors, $phpUnitTable->tests, $phpUnitTable->assertions); + + $this->report .= $s; + + $c =($phpUnitTable->failures || $phpUnitTable->errors) ? 'img-warn' : 'img-success'; + $this->reportHtml .= '

'.$s.'

'."\n"; + + if($errors) + { + $this->reportHtml .= '

Errors

'; + + $this->reportHtml .= '
    '; + + foreach($errors as $error) + { + if( ! $error)//regex produces emty errors :( + continue; + + $this->reportHtml .= '
  1. '.htmlentities($error).'
  2. '; + } - $this->report .= 'Unit testing complete. There were ' . $phpUnitTable->failures . ' failures and ' . $phpUnitTable->errors . - ' errors from ' . $phpUnitTable->tests . ' tests and ' . $phpUnitTable->assertions . ' assertions.' . "\n"; + $this->reportHtml .= '
'; } - else + + if($failures) { - $this->report .= 'Test log missing. Tests failed to execute.' . "\n"; + $this->reportHtml .= '

Failures

'; + + $this->reportHtml .= '
    '; + + foreach($failures as $fail) + { + if( ! $fail)//regex produces emty errors :( + continue; + + $this->reportHtml .= '
  1. '.htmlentities($fail).'
  2. '; + } + + $this->reportHtml .= '
'; } } protected function parsePhpCs() { - if (file_exists(PATH_CHECKOUTS . '/pulls/build/logs/checkstyle.xml')) + $this->reportHtml .= '

Checkstyle

'."\n"; + + if ( ! file_exists(PATH_CHECKOUTS . '/pulls/build/logs/checkstyle.xml')) { - $numWarnings = 0; - $numErrors = 0; + $this->report .= 'Checkstyle analysis not found.' . "\n"; + $this->reportHtml .= '

open(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml'); - while ($reader->read()) + $reader = new XMLReader(); + $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml'); + + $details = ''; + + $detailsHtml = ''; + + $maxErrors = 10; + + while ($reader->read()) + { + if ($reader->name == 'file') { - if ($reader->name == 'error') + $fName = $reader->getAttribute('name'); + + //-- @todo: strip the *right* path... + $fName = str_replace(PATH_CHECKOUTS . '/pulls/', '', $fName); + } + + if ($reader->name == 'error') + { + if ($reader->getAttribute('severity') == 'warning') { - if ($reader->getAttribute('severity') == 'warning') - { - $numWarnings++; - } + $numWarnings++; + } + + if ($reader->getAttribute('severity') == 'error') + { + $numErrors++; + + $detailsHtml .= '
  • '.$fName.':'.$reader->getAttribute('line').'
    '; + $detailsHtml .= ''.$reader->getAttribute('message').'
  • '."\n"; - if ($reader->getAttribute('severity') == 'error') + if($numErrors <= $maxErrors) { - $numErrors++; + $details .= $fName.':'.$reader->getAttribute('line')."\n"; + $details .= $reader->getAttribute('message')."\n"; } } } + } - $phpCsTable->errors = $numErrors; - $phpCsTable->warnings = $numWarnings; + $phpCsTable->errors = $numErrors; + $phpCsTable->warnings = $numWarnings; - $phpCsTable->pulls_id = $this->table->id; - $phpCsTable->store(); - $reader->close(); + $phpCsTable->pulls_id = $this->table->id; + $phpCsTable->store(); + $reader->close(); - $this->report .= 'Checkstyle analysis reported ' . $numWarnings . ' warnings and ' . $numErrors . ' errors.' . "\n"; - } - else + $s = 'Checkstyle analysis reported ' . $numWarnings . ' warnings and ' . $numErrors . ' errors.' . "\n"; + $this->report .= $s; + + $c =($numErrors) ? 'img-warn' : 'img-success'; + $this->reportHtml .= '

    '.$s.'

    '."\n"; + + if($numErrors) { - $this->report .= 'Checkstyle analysis not found.' . "\n"; + $this->report .= '**Checkstyle error details**'."\n".$details."\n"; + $this->reportHtml .= '

    Checkstyle error details

    '."\n".''."\n"; } + if($numErrors > $maxErrors) + { + $this->report .= '('.($numErrors - $maxErrors).' more errors)'."\n"; + } } + protected function getHead($title) + { + $htmlHead = ''; + $htmlHead .= ''; + $htmlHead .= ''.$title.''; + $htmlHead .= ''; + $htmlHead .= ''."\n"; + + return $htmlHead; + } /** * Method to load a PHP configuration class file based on convention and return the instantiated data object. You @@ -320,6 +642,14 @@ protected function fetchConfigurationData($config = 'test') return $config; } + + protected function output($text = '', $nl = true) + { + if( ! $this->verbose) + return; + + $this->out($text, $nl); + } } // Execute the application. From 14e31bc462febc13f1e6401a9f428ca637929b13 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Sat, 5 Nov 2011 02:43:50 -0500 Subject: [PATCH 02/66] Add functions to update and truncate the tables --- src/tables/checkstyle.php | 16 +++++++++- src/tables/phpunit.php | 16 +++++++++- src/tables/pulls.php | 63 ++++++++++++++++++++++++++++++++++++++- 3 files changed, 92 insertions(+), 3 deletions(-) diff --git a/src/tables/checkstyle.php b/src/tables/checkstyle.php index d9def9b..ead90cf 100644 --- a/src/tables/checkstyle.php +++ b/src/tables/checkstyle.php @@ -16,5 +16,19 @@ class TableCheckstyle extends JTable public function __construct(&$db) { parent::__construct('phpCsResults', 'id', $db); - } + } + + /** + * Truncate the table. + * + * @return void + */ + public function truncate() + { + $this->_db->setQuery('TRUNCATE TABLE '.$this->_tbl); + + $this->_db->query(); + + return; + } } diff --git a/src/tables/phpunit.php b/src/tables/phpunit.php index c9a01a2..4f634e7 100644 --- a/src/tables/phpunit.php +++ b/src/tables/phpunit.php @@ -16,5 +16,19 @@ class TablePhpunit extends JTable public function __construct(&$db) { parent::__construct('phpunitResults', 'id', $db); - } + } + + /** + * Truncate the table. + * + * @return void + */ + public function truncate() + { + $this->_db->setQuery('TRUNCATE TABLE '.$this->_tbl); + + $this->_db->query(); + + return; + } } diff --git a/src/tables/pulls.php b/src/tables/pulls.php index 431658b..fbe9d41 100644 --- a/src/tables/pulls.php +++ b/src/tables/pulls.php @@ -46,5 +46,66 @@ public function loadByNumber($number) return false; } return $this->load($id); - } + } + + public function update($pulls) + { + //-- @todo this seems ugly :P + + $activePulls = array(); + + foreach ($pulls as $pull) + { + $activePulls[] = $pull->number; + } + + $query = $this->_db->getQuery(true); + + $query->from($this->_tbl); + $query->select('pull_id'); + + $this->_db->setQuery($query); + + $entries = $this->_db->loadResultArray(); + + $query->clear(); + + $query->delete($this->_tbl); + + foreach ($entries as $entry) + { + if(in_array($entry, $activePulls)) + { + continue; + } + + //-- Delete the pull + $query->clear('where'); + + $query->where('pull_id='.$entry); + + $this->_db->setQuery($query); + $this->_db->query(); + + //-- Let's also delete the html file -- @todo: move + if(file_exists(PATH_OUTPUT.'/'.$entry.'.html')) + { + unlink(PATH_OUTPUT.'/'.$entry.'.html'); + } + } + } + + /** + * Truncate the table. + * + * @return void + */ + public function truncate() + { + $this->_db->setQuery('TRUNCATE TABLE '.$this->_tbl); + + $this->_db->query(); + + return; + } } From dce5593b7825d0596a2e40cd492fdc77a1a0a318 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Sun, 6 Nov 2011 02:39:52 -0500 Subject: [PATCH 03/66] Add reset and update functionality --- src/pulltester.php | 469 ++++++++++++++++++++++++-------------- src/tables/checkstyle.php | 29 +++ src/tables/phpunit.php | 29 +++ 3 files changed, 354 insertions(+), 173 deletions(-) diff --git a/src/pulltester.php b/src/pulltester.php index e456930..415a6c4 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -64,78 +64,73 @@ public function execute() { $this->startTime = microtime(true); + $reset = $this->input->get('reset'); + $this->verbose = $this->input->get('v', 0); + if($reset) + { + $this->output('Resetting...', false); + $this->reset('hard' == $reset); + $this->output('OK'); + $this->output('Finished =;)'); + } + $selectedPull = $this->input->get('pull', 0, 'INT'); $this->output('----------------------'); $this->output('-- Ian\'s PullTester --'); $this->output('----------------------'); - JTable::addIncludePath(JPATH_BASE.'/tables'); - - $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); + $this->output('Creating the base repo...', false); + $this->createRepo(); + $this->output('OK'); $this->output('Fetching pull requests...', false); - + $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); $pulls = $this->github->pulls->getAll($this->config->get('github_project'), $this->config->get('github_repo'), 'open', 0, 100); - $this->output('OK'); + JTable::addIncludePath(JPATH_BASE.'/tables'); + JTable::getInstance('Pulls', 'Table')->update($pulls); - $this->output('Creating the base repo...', false); - $this->createRepo(); $this->output('OK'); + $cnt = 1; + foreach ($pulls AS $pull) { if($selectedPull && $selectedPull != $pull->number) { $this->output('Skipping pull '.$pull->number); + $cnt ++; + continue; } - $this->output('Processing pull '.$pull->number.'...'); + $this->output('Processing pull '.$pull->number.'...', false); + $this->output(sprintf('(%d/%d)...', $cnt, count($pulls)), false); $this->report = ''; $this->reportHtml = ''; $this->processPull($pull); - $this->output('OK'); - $t = microtime(true); - $this->output(($t - $this->startTime).' secs'); + $this->output('Finished in '.($t - $this->startTime).' secs'); $this->output('------------------------'); + + $cnt ++; } $this->totalTime = microtime(true) - $this->startTime; - $this->output('Finished in '.$this->totalTime.' secs =;)'); - + $this->output('Generating stats...', false); $this->generateStatsTable(); + $this->output('OK'); - $this->close(); - } - - protected function getIndexData() - { - $db = JFactory::getDbo(); - - $query = $db->getQuery(true); - - $query->from('pulls AS p'); - $query->select('p.pull_id, p.mergeable'); - $query->select('cs.warnings AS CS_warnings, cs.errors AS CS_errors'); - $query->select('pu.failures AS Unit_failures, pu.errors AS Unit_errors'); - - $query->leftJoin('phpCsResults AS cs on p.id=cs.pulls_id'); - $query->leftJoin('phpunitResults AS pu on p.id=pu.pulls_id'); - - $db->setQuery($query); + $this->output('Total time: '.$this->totalTime.' secs =;)'); - $data = $db->loadObjectList(); - - return $data; + $this->close(); } protected function processPull($pull) @@ -158,7 +153,18 @@ protected function processPull($pull) $changed = false; // if we haven't processed this pull request before or if new commits have been made against our repo or the head repo - if (!$pullData || $this->table->head != $pullRequest->head->sha || $this->table->base != $pullRequest->base->sha) { + if (!$pullData + || $this->table->head != $pullRequest->head->sha + || $this->table->base != $pullRequest->base->sha) + { + // Update the table + $this->table->head = $pullRequest->head->sha; + $this->table->base = $pullRequest->base->sha; + $this->table->mergeable = $pullRequest->mergeable; + + $this->table->store(); + + $changed = true; // Step 1: See if the pull request will merge // right now we do this strictly based on what github tells us @@ -167,7 +173,6 @@ protected function processPull($pull) { // Step 2: We try and git the repo and perform the build $this->build($pullRequest); - $changed = true; } else { @@ -179,10 +184,7 @@ protected function processPull($pull) { $this->report .= '...but it was mergeable before and it isn\'t mergeable anymore...'; $this->reportHtml .= '

    ...but it was mergeable before and it isn\'t mergeable anymore...

    '."\n"; - } - - $changed = true; } } @@ -222,13 +224,21 @@ protected function createRepo() mkdir(PATH_CHECKOUTS); } + if( ! file_exists(PATH_OUTPUT.'/test/')) + { + mkdir(PATH_OUTPUT.'/test/'); + } + if (file_exists(PATH_CHECKOUTS . '/pulls')) { - //-- Update existing repository - // chdir(PATH_CHECKOUTS.'/pulls'); - // exec('git checkout staging'); - // exec('git fetch origin'); - // exec('git merge origin/staging'); + if ($this->input->get('update')) + { + //-- Update existing repository + chdir(PATH_CHECKOUTS.'/pulls'); + exec('git checkout staging'); + exec('git fetch origin'); + exec('git merge origin/staging'); + } } else { @@ -306,150 +316,59 @@ protected function build($pull) exec('git branch -D pull' . $pull->number); } - protected function publishResults($pullRequest) + protected function parsePhpUnit() { + $this->reportHtml .= '

    Unit Tests

    '."\n"; - $project = $this->config->get('github_project'); - $repo = $this->config->get('github_repo'); - //$url = 'https://api.github.com/repos/'.$project.'/'.$repo.'/issues/'.$pullRequest->number.'/comments'; - //$ch = curl_init(); - //curl_setopt($ch, CURLOPT_URL, $url); - //curl_setopt($ch, CURLOPT_POST, true); - //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); - //curl_setopt($ch, CURLOPT_USERPWD, $this->config->get('github_user').':'.$this->config->get('github_password')); - - //$request = new stdClass; - //$request->body = ''; - - if ($pullRequest->base->ref != 'staging') { - $this->report .= "\n\n" . '**WARNING! Pull request is not against staging!**'; - $this->reportHtml .= '

    Pull request is not against staging!

    '."\n"; - } - - //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); - //curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request)); - file_put_contents(PATH_CHECKOUTS . '/pull' . $pullRequest->number . '.txt', $this->report); - - $html = ''; - $html .= $this->getHead($pullRequest->number.' Test results'); - - $html .= ''."\n"; - - $html .= '⇐ Index'."\n"; - - $html .= '

    Results for ' - .'pull request #'.$pullRequest->number.'

    '."\n"; - - $html .= $this->reportHtml; - - $html .= ''; - $html .= ''; + if ( ! file_exists(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml')) + { + $this->report .= 'Test log missing. Tests failed to execute.' . "\n"; + $this->reportHtml .= '

    Test log missing. Tests failed to execute.

    '."\n"; - file_put_contents(PATH_OUTPUT . '/' . $pullRequest->number . '.html', $html); + $d = $this->phpUnitDebug; + $d = str_replace(PATH_CHECKOUTS . '/pulls/', '', $d); + $d = str_replace('/opt/lampp', '...', $d); - //echo $this->report; - } + $this->reportHtml .= '
    '.$d.'
    '; - protected function generateStatsTable() - { - $data = $this->getIndexData(); + return; + } - $html = $this->getHead('Test results overview'); + copy(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml', PATH_OUTPUT.'/test/'.$this->table->pull_id.'junit.xml'); - $html .= ''; + $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); - $html .= '

    Test results overview

    '; + //....heho infinite loop in JError... + // $xml = JFactory::getXML(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); + // do it by hand.. + // Disable libxml errors and allow to fetch error information as needed + libxml_use_internal_errors(true); - $html .= ''; + $xml = simplexml_load_file(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); - if(isset($data[0])) + if (empty($xml)) { - $html .= ''; - - foreach ($data[0] as $key => $v) - { - $html .= ''; - } - $html .= ''; - } - - foreach ($data as $entry) - { - $html .= ''; + // There was an error + $d = $this->phpUnitDebug; + $d = str_replace(PATH_CHECKOUTS . '/pulls/', '', $d); + $d = str_replace('/opt/lampp', '...', $d); - $mergeable = true; + $this->reportHtml .= '
    '.$d;
     
    -			foreach ($entry as $key => $value)
    +			foreach (libxml_get_errors() as $error)
     			{
    -				$replace = '%s';
    -
    -				if( ! $mergeable)
    -				{
    -					$replace = '-';
    -				}
    -				elseif('' == $value)
    -				{
    -					$replace = '-?-';
    -				}
    -				else
    -				{
    -					switch ($key)
    -					{
    -						case 'pull_id':
    -							$replace = 'Pull %1$s';
    -							break;
    -
    -						case 'CS_warnings':
    -							$replace =(0 == $value) ? '√' : '%d';
    -							break;
    -
    -						case 'CS_errors':
    -						case 'Unit_failures':
    -						case 'Unit_errors':
    -							$replace =(0 == $value) ? '√' : '%d';
    -							break;
    -
    -						case 'mergeable':
    -							$mergeable =($value) ? true : false;
    -							$value =($value) ? '√' : '** NO **';
    -							break;
    -					}//switch
    -				}
    -
    -				$html .= '
    '; - }//foreach - - $html .= ''."\n"; - }//foreach - - $html .= '
    '.$key.'
    '.sprintf($replace, $value).'
    '; - - $html .= ''; - - $html .= ''; - - file_put_contents(PATH_OUTPUT.'/index.html', $html); - } + $this->reportHtml .= $error->message."\n"; + } - protected function parsePhpUnit() - { - $this->reportHtml .= '

    Unit Tests

    '."\n"; - - if ( ! file_exists(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml')) - { - $this->report .= 'Test log missing. Tests failed to execute.' . "\n"; - $this->reportHtml .= '

    Test log missing. Tests failed to execute.

    '."\n"; - $d = $this->phpUnitDebug; - $d = str_replace(PATH_CHECKOUTS . '/pulls/', '', $d); - $this->reportHtml .= '
    '.$d.'
    '; + $this->reportHtml .= ''; return; } - - $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); + else + { + //-- @TODO use simple_xml to parse xml files.. + // var_dump($xml); + } $reader = new XMLReader(); $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); @@ -536,6 +455,8 @@ protected function parsePhpCs() return; } + copy(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml', PATH_OUTPUT.'/test/'.$this->table->pull_id.'checkstyle.xml'); + $numWarnings = 0; $numErrors = 0; @@ -611,12 +532,212 @@ protected function parsePhpCs() } } + protected function publishResults($pullRequest) + { + + $project = $this->config->get('github_project'); + $repo = $this->config->get('github_repo'); + //$url = 'https://api.github.com/repos/'.$project.'/'.$repo.'/issues/'.$pullRequest->number.'/comments'; + //$ch = curl_init(); + //curl_setopt($ch, CURLOPT_URL, $url); + //curl_setopt($ch, CURLOPT_POST, true); + //curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); + //curl_setopt($ch, CURLOPT_USERPWD, $this->config->get('github_user').':'.$this->config->get('github_password')); + + //$request = new stdClass; + //$request->body = ''; + + if ($pullRequest->base->ref != 'staging') { + $this->report .= "\n\n" . '**WARNING! Pull request is not against staging!**'; + $this->reportHtml .= '

    Pull request is not against staging!

    '."\n"; + } + + //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); + //curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request)); + file_put_contents(PATH_CHECKOUTS . '/pull' . $pullRequest->number . '.txt', $this->report); + + $html = ''; + $html .= $this->getHead($pullRequest->number.' Test results'); + + $html .= ''."\n"; + + $html .= '⇐ Index'."\n"; + + $html .= '

    Results for ' + .'pull request #'.$pullRequest->number.'

    '."\n"; + + $html .= $this->reportHtml; + + $html .= ''; + $html .= ''."\n\n"; + + file_put_contents(PATH_OUTPUT . '/' . $pullRequest->number . '.html', $html); + + //echo $this->report; + } + + protected function reset($hard = false) + { + jimport('joomla.filesystem.file'); + + $this->output(($hard ? 'hard...' : 'soft...'), false); + $this->output('truncating tables...', false); + + JTable::addIncludePath(JPATH_BASE.'/tables'); + + JTable::getInstance('Checkstyle', 'Table')->truncate(); + JTable::getInstance('Phpunit', 'Table')->truncate(); + JTable::getInstance('Pulls', 'Table')->truncate(); + + $this->output('deleting files...', false); + JFile::delete(JFolder::files(PATH_CHECKOUTS, '.', false, true)); + JFile::delete(JFolder::files(PATH_OUTPUT, '.', false, true, array('index.html'))); + + if($hard) + { + $this->out('HARD - not implemented yet - will reset the repo...', false); + } + } + + protected function getIndexData() + { + $db = JFactory::getDbo(); + + $query = $db->getQuery(true); + + $query->from('pulls AS p'); + $query->leftJoin('phpCsResults AS cs on p.id=cs.pulls_id'); + $query->leftJoin('phpunitResults AS pu on p.id=pu.pulls_id'); + + $query->select('p.pull_id, p.mergeable'); + $query->select('cs.warnings AS CS_warnings, cs.errors AS CS_errors'); + $query->select('pu.failures AS Unit_failures, pu.errors AS Unit_errors'); + + $query->order('p.pull_id DESC'); + + $db->setQuery($query); + + $data = $db->loadObjectList(); + + return $data; + } + + protected function generateStatsTable() + { + $statusColors = array(0 => 'ccff99', 1 => 'ffc',2 => 'ff7f7f',3 => 'ff0033'); + + $data = $this->getIndexData(); + + $html = $this->getHead('Test results overview'); + + $html .= ''."\n"; + + $html .= '

    Test results overview

    '."\n"; + + $html .= ''."\n"; + + if(isset($data[0])) + { + $html .= ''; + + foreach ($data[0] as $key => $v) + { + $html .= ''; + } + + $html .= ''; + $html .= ''."\n"; + } + + foreach ($data as $entry) + { + $html .= ''; + + $mergeable = true; + $overall = 0; + + foreach ($entry as $key => $value) + { + $replace = '%s'; + + if( ! $mergeable) + { + $replace = '-'; + $overall = 3; + } + elseif('' == $value) + { + $replace = '-?-'; + $overall = 2; + } + else + { + switch ($key) + { + case 'pull_id': + $replace = 'Pull %1$s'; + break; + + case 'CS_warnings': + $replace =(0 == $value) ? '√' : '%d'; + // $overall = 1; + break; + + case 'CS_errors': + case 'Unit_failures': + case 'Unit_errors': + $replace =(0 == $value) ? '√' : '%d'; + $overall =(0 == $value) ? $overall : 1; + break; + + case 'mergeable': + $replace =($value) ? '√' : '** NO **'; + $mergeable =($value) ? true : false; + break; + }//switch + } + + $html .= ''; + }//foreach + + $html .= ''; + + $html .= ''."\n"; + }//foreach + + $html .= '
    '.$key.'Status
    '.sprintf($replace, $value).' 
    '."\n"; + + $total = $this->totalTime; + + if(file_exists(PATH_OUTPUT.'/index.html')) + { + $test = file_get_contents(PATH_OUTPUT.'/index.html'); + + preg_match('#([0-9.]+)#', $test, $matches); + + if($matches) + { + $total += $matches[1]; + } + } + + $html .= ''."\n"; + + $html .= ''."\n\n"; + + file_put_contents(PATH_OUTPUT.'/index.html', $html); + } + protected function getHead($title) { $htmlHead = ''; - $htmlHead .= ''; - $htmlHead .= ''.$title.''; - $htmlHead .= ''; + $htmlHead .= ''."\n"; + $htmlHead .= ''."\n"; + $htmlHead .= ''.$title.''."\n"; + $htmlHead .= ''."\n"; $htmlHead .= ''."\n"; return $htmlHead; @@ -654,3 +775,5 @@ protected function output($text = '', $nl = true) // Execute the application. JCli::getInstance('PullTester')->execute(); + +exit(0); \ No newline at end of file diff --git a/src/tables/checkstyle.php b/src/tables/checkstyle.php index ead90cf..4c67785 100644 --- a/src/tables/checkstyle.php +++ b/src/tables/checkstyle.php @@ -18,6 +18,35 @@ public function __construct(&$db) parent::__construct('phpCsResults', 'id', $db); } + /** + * Store only new records. Find previous. + * + * @param boolean $updateNulls True to update fields even if they are null. + * + * @return boolean True on success. + * + * @see JTable::store() + */ + public function store($updateNulls = false) + { + $query = $this->_db->getQuery(true); + + $query->from($this->_tbl); + $query->select('id'); + $query->where('pulls_id='.$this->pulls_id); + + $this->_db->setQuery($query); + + $id = $this->_db->loadResult(); + + if($id) + { + $this->id = $id; + } + + return parent::store($updateNulls); + } + /** * Truncate the table. * diff --git a/src/tables/phpunit.php b/src/tables/phpunit.php index 4f634e7..31e30bf 100644 --- a/src/tables/phpunit.php +++ b/src/tables/phpunit.php @@ -18,6 +18,35 @@ public function __construct(&$db) parent::__construct('phpunitResults', 'id', $db); } + /** + * Store only new records. Find previous. + * + * @param boolean $updateNulls True to update fields even if they are null. + * + * @return boolean True on success. + * + * @see JTable::store() + */ + public function store($updateNulls = false) + { + $query = $this->_db->getQuery(true); + + $query->from($this->_tbl); + $query->select('id'); + $query->where('pulls_id='.$this->pulls_id); + + $this->_db->setQuery($query); + + $id = $this->_db->loadResult(); + + if($id) + { + $this->id = $id; + } + + return parent::store($updateNulls); + } + /** * Truncate the table. * From 870cfc6adfd608b591cd43d7aec8d980bdd3dc51 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Mon, 7 Nov 2011 18:42:54 -0500 Subject: [PATCH 04/66] Add some more fishy error checks, option to reset 'hard' --- src/pulltester.php | 123 +++++++++++++++++++++++++++++++++------------ 1 file changed, 90 insertions(+), 33 deletions(-) diff --git a/src/pulltester.php b/src/pulltester.php index 415a6c4..f7a0e3a 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -1,6 +1,14 @@ #!/usr/bin/php Process only a specific pull + * -v Be verbose. + * * @package Joomla.Documentation * @subpackage Application * @@ -31,6 +39,7 @@ jimport('joomla.database'); jimport('joomla.database.table'); jimport('joomla.client.github'); +jimport('joomla.client.github2'); JError::$legacy = false; @@ -62,27 +71,28 @@ class PullTester extends JCli */ public function execute() { + JTable::addIncludePath(JPATH_BASE.'/tables'); + $this->startTime = microtime(true); $reset = $this->input->get('reset'); $this->verbose = $this->input->get('v', 0); + $selectedPull = $this->input->get('pull', 0, 'INT'); + + $this->output('----------------------'); + $this->output('-- Ian\'s PullTester --'); + $this->output('----------------------'); + if($reset) { $this->output('Resetting...', false); $this->reset('hard' == $reset); $this->output('OK'); - $this->output('Finished =;)'); } - $selectedPull = $this->input->get('pull', 0, 'INT'); - - $this->output('----------------------'); - $this->output('-- Ian\'s PullTester --'); - $this->output('----------------------'); - - $this->output('Creating the base repo...', false); + $this->output('Creating/Updating the base repo...', false); $this->createRepo(); $this->output('OK'); @@ -90,8 +100,9 @@ public function execute() $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); $pulls = $this->github->pulls->getAll($this->config->get('github_project'), $this->config->get('github_repo'), 'open', 0, 100); - JTable::addIncludePath(JPATH_BASE.'/tables'); - JTable::getInstance('Pulls', 'Table')->update($pulls); + $this->github2 = new JGithub2(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); + + $this->updateTables($pulls); $this->output('OK'); @@ -148,6 +159,15 @@ protected function processPull($pull) return; } +// try { +// $pullRequest2 = $this->github2->pulls->get($this->config->get('github_project'), $this->config->get('github_repo'), $number); +// } catch (Exception $e) { +// echo 'Error Getting Pull Request - JSON Error: '.$e->getMessage."\n"; +// return; +// } +// var_dump($pullRequest2); +// return; + $pullData = $this->loadPull($pullRequest); $changed = false; @@ -277,16 +297,19 @@ protected function build($pull) exec('git fetch ' . $pull->user->login); + $this->output('Merge repo: '.$pull->user->login . '/' . $pull->head->ref); exec('git merge ' . $pull->user->login . '/' . $pull->head->ref); // exec('ant clean'); + exec('mkdir build/logs 2>/dev/null'); exec('rm build/logs/junit.xml 2>/dev/null'); + exec('touch build/logs/checkstyle.xml'); $this->output('Running PHPUnit...', false); ob_start(); - // exec('ant phpunit'); - // exec('ant phpunit'); + // exec('ant phpunit'); + // exec('ant phpunit'); echo shell_exec('phpunit 2>&1'); @@ -295,9 +318,7 @@ protected function build($pull) $this->output('OK'); $this->output('Running the CodeSniffer...', false); - // exec('ant phpcs'); - exec('mkdir build/logs 2>/dev/null'); - exec('touch build/logs/checkstyle.xml'); + // exec('ant phpcs'); echo shell_exec('phpcs' // .' -p' @@ -312,7 +333,10 @@ protected function build($pull) $this->output('OK'); - exec('git checkout staging 2>/dev/null'); + //-- Fishy things happen all along the way... + //-- Let's use the -f (force) option.. + exec('git checkout -f staging'); + exec('git branch -D pull' . $pull->number); } @@ -455,7 +479,8 @@ protected function parsePhpCs() return; } - copy(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml', PATH_OUTPUT.'/test/'.$this->table->pull_id.'checkstyle.xml'); + copy(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' + , PATH_OUTPUT.'/test/'.$this->table->pull_id.'checkstyle.xml'); $numWarnings = 0; $numErrors = 0; @@ -580,22 +605,35 @@ protected function reset($hard = false) { jimport('joomla.filesystem.file'); - $this->output(($hard ? 'hard...' : 'soft...'), false); $this->output('truncating tables...', false); - JTable::addIncludePath(JPATH_BASE.'/tables'); - JTable::getInstance('Checkstyle', 'Table')->truncate(); JTable::getInstance('Phpunit', 'Table')->truncate(); JTable::getInstance('Pulls', 'Table')->truncate(); $this->output('deleting files...', false); - JFile::delete(JFolder::files(PATH_CHECKOUTS, '.', false, true)); - JFile::delete(JFolder::files(PATH_OUTPUT, '.', false, true, array('index.html'))); + //-- Remove the checkout files if($hard) { - $this->out('HARD - not implemented yet - will reset the repo...', false); + $this->output('ALL FILES...', false); + + if(JFolder::exists(PATH_CHECKOUTS)) + { + JFolder::delete(PATH_CHECKOUTS); + } + } + else + { + JFile::delete(JFolder::files(PATH_CHECKOUTS, '.', false, true)); + } + + //-- Delete all HTML files but the index.html + JFile::delete(JFolder::files(PATH_OUTPUT, '.', false, true, array('index.html'))); + + if(JFolder::exists(PATH_OUTPUT.'/test')) + { + JFile::delete(JFolder::files(PATH_OUTPUT.'/test', '.', false, true)); } } @@ -622,6 +660,12 @@ protected function getIndexData() return $data; } + protected function updateTables($pulls) + { + JTable::getInstance('Pulls', 'Table')->update($pulls); + ; + } + protected function generateStatsTable() { $statusColors = array(0 => 'ccff99', 1 => 'ffc',2 => 'ff7f7f',3 => 'ff0033'); @@ -634,6 +678,8 @@ protected function generateStatsTable() $html .= '

    Test results overview

    '."\n"; + $html .= sprintf('We have %s open pull requests...', ''.count($data).''); + $html .= ''."\n"; if(isset($data[0])) @@ -667,7 +713,7 @@ protected function generateStatsTable() } elseif('' == $value) { - $replace = '-?-'; + $replace = '? ? ?'; $overall = 2; } else @@ -679,19 +725,19 @@ protected function generateStatsTable() break; case 'CS_warnings': - $replace =(0 == $value) ? '√' : '%d'; + $replace =(0 == $value) ? '√' : '%d'; // $overall = 1; break; case 'CS_errors': case 'Unit_failures': case 'Unit_errors': - $replace =(0 == $value) ? '√' : '%d'; + $replace =(0 == $value) ? '√' : '%d'; $overall =(0 == $value) ? $overall : 1; break; case 'mergeable': - $replace =($value) ? '√' : '** NO **'; + $replace =($value) ? '√' : '** NO **'; $mergeable =($value) ? true : false; break; }//switch @@ -755,8 +801,9 @@ protected function getHead($title) protected function fetchConfigurationData($config = 'test') { $configFile = $this->input->get('config', 'config.php'); - require_once($configFile); - if (!class_exists('JConfig')) { + require_once $configFile; + if (!class_exists('JConfig')) + { return false; } $config = new JConfig; @@ -771,9 +818,19 @@ protected function output($text = '', $nl = true) $this->out($text, $nl); } -} +}//class + +try +{ + // Execute the application. + JCli::getInstance('PullTester')->execute(); -// Execute the application. -JCli::getInstance('PullTester')->execute(); + exit(0); +} +catch (Exception $e) +{ + // An exception has been caught, just echo the message. + fwrite(STDOUT, $e->getMessage() . "\n"); -exit(0); \ No newline at end of file + exit($e->getCode()); +}//try From 650f2e524ad830f922119867471889e5882e3594 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Wed, 9 Nov 2011 16:19:56 -0500 Subject: [PATCH 05/66] Strip out parsing and formatting, Add a helper class --- src/formats/html.php | 272 ++++++++++++++++++++++ src/formats/markdown.php | 43 ++++ src/helper.php | 15 ++ src/parsers/phpcs.php | 72 ++++++ src/parsers/phpunit.php | 91 ++++++++ src/pulltester.php | 481 ++++++--------------------------------- 6 files changed, 565 insertions(+), 409 deletions(-) create mode 100644 src/formats/html.php create mode 100644 src/formats/markdown.php create mode 100644 src/helper.php create mode 100644 src/parsers/phpcs.php create mode 100644 src/parsers/phpunit.php diff --git a/src/formats/html.php b/src/formats/html.php new file mode 100644 index 0000000..b404357 --- /dev/null +++ b/src/formats/html.php @@ -0,0 +1,272 @@ +'; + $html[] = ''; + $html[] = ''; + $html[] = ''.$pullRequest->number.' Test results'.''; + $html[] = ''; + $html[] = ''; + $html[] = ''; + + $html[] = ''; + + $html[] = '⇐ Index ⇐'; + + $html[] = '

    Results for ' + .'pull request #'.$pullRequest->number.'

    '; + + if('staging' != $pullRequest->base->ref) + { + $html[] = '

    Pull request is not against staging!

    '; + } + elseif($testResults->error) + { + //-- Usually this means 'not meargeable' + $html[] = '

    '.$testResults->error.'

    '; + } + else + { + //-- PhpUnit results + $html[] = '

    Unit Tests

    '; + + if($testResults->phpunit->error) + { + $html[] = '

    '.$testResults->phpunit->error.'

    '; + + foreach ($testResults->phpunit->debugMessages as $message) + { + $html[] = '
    '.$message.'
    '; + } + } + + if(false){} + else + { + $c =($testResults->phpunit->failures || $testResults->phpunit->errors) ? 'img-warn' : 'img-success'; + + $s = sprintf('Unit testing complete. There were %1d failures and %2d errors.' + , count($testResults->phpunit->failures), count($testResults->phpunit->errors)); + + $html[] = '

    '.$s.'

    '; + + if($testResults->phpunit->errors) + { + $html[] = '

    Errors

    '; + + $html[] = '
      '; + + foreach($testResults->phpunit->errors as $error) + { + if( ! $error)//regex produces empty errors :( + continue; + + $html[] = '
    1. '.htmlentities($error).'
    2. '; + } + + $html[] = '
    '; + } + + if($testResults->phpunit->failures) + { + $html[] = '

    Failures

    '; + + $html[] = '
      '; + + foreach($testResults->phpunit->failures as $fail) + { + if( ! $fail)//regex produces empty errors :( + continue; + + $html[] = '
    1. '.htmlentities($fail).'
    2. '; + } + + $html[] = '
    '; + } + } + + //-- PhpCS results + $html[] = '

    Checkstyle

    '; + + if($testResults->phpcs->error) + { + $html[] = '

    '.$testResults->phpcs->error.'

    '; + + foreach ($testResults->phpcs->debugMessages as $message) + { + $html[] = '
    '.$message.'
    '; + } + } + else + { + $s = sprintf('Checkstyle analysis reported %1d warnings and %2d errors.' + , count($testResults->phpcs->warnings), count($testResults->phpcs->errors)); + + $c =($testResults->phpcs->errors) ? 'img-warn' : 'img-success'; + + $html[] = '

    '.$s.'

    '; + + //--- @todo display warnings... + + if($testResults->phpcs->errors) + { + $html[] = '

    Checkstyle error details

    '; + + $html[] = '
      '; + + foreach ($testResults->phpcs->errors as $error) { + $html[] = '
    • '.$error->file.':'.$error->line.'
      '; + $html[] = ''.$error->message.'
    • '; + ; + } + + $html[] = '
    '; + } + } + } + + $html[] = '⇐ Index ⇐'; + + $html[] = ''; + $html[] = ''; + $html[] = ''; + + $html[] = ''; + + return implode("\n", $html); + } + + public static function formatIndex($indexData, $totalTime) + { + $html = array(); + $statusColors = array(0 => 'ccff99', 1 => 'ffc',2 => 'ff7f7f',3 => 'ff0033'); + + $html[] = ''; + $html[] = ''; + $html[] = ''; + $html[] = 'Test results overview'; + $html[] = ''; + $html[] = ''; + $html[] = ''; + + $html[] = ''; + $html[] = '

    Test results overview

    '; + $html[] = sprintf('We have %s open pull requests...', ''.count($indexData).''); + + $html[] = '
    '; + + if(isset($indexData[0])) + { + $html[] = ''; + + foreach ($indexData[0] as $key => $v) + { + $html[] = ''; + } + + $html[] = ''; + $html[] = ''; + } + + foreach ($indexData as $entry) + { + $html[] = ''; + + $mergeable = true; + $overall = 0; + + foreach ($entry as $key => $value) + { + $replace = '%s'; + + if( ! $mergeable) + { + $replace = '-'; + $overall = 3; + } + elseif('' == $value) + { + $replace = '? ? ?'; + $overall = 2; + } + else + { + switch ($key) + { + case 'pull_id': + $replace = 'Pull %1$s'; + break; + + case 'CS_warnings': + $replace =(0 == $value) ? '√' : '%d'; + // $overall = 1; + break; + + case 'CS_errors': + case 'Unit_failures': + case 'Unit_errors': + $replace =(0 == $value) ? '√' : '%d'; + $overall =(0 == $value) ? $overall : 1; + break; + + case 'mergeable': + $replace =($value) ? '√' : '** NO **'; + $mergeable =($value) ? true : false; + break; + }//switch + } + + $html[] = ''; + }//foreach + + $html[] = ''; + + $html[] = ''; + }//foreach + + $html[] = '
    '.$key.'Status
    '.sprintf($replace, $value).' 
    '; + + if(file_exists(PATH_OUTPUT.'/index.html')) + { + $test = file_get_contents(PATH_OUTPUT.'/index.html'); + + preg_match('#([0-9.]+)#', $test, $matches); + + if($matches) + { + $totalTime += $matches[1]; + } + } + + $html[] = ''; + + $html[] = ''; + $html[] = ''; + + $html[] = ''; + + return implode("\n", $html); + } + + protected static function getHead($title) + { + $html = array(); + + $html[] = ''; + $html[] = ''; + $html[] = ''; + $html[] = ''.$title.''; + $html[] = ''; + $html[] = ''; + $html[] = ''; + + return implode("\n", $html); + } +} diff --git a/src/formats/markdown.php b/src/formats/markdown.php new file mode 100644 index 0000000..1e44aa7 --- /dev/null +++ b/src/formats/markdown.php @@ -0,0 +1,43 @@ +base->ref) + { + $markdown[] = '**WARNING! Pull request is not against staging!**'; + } + elseif($testResults->error) + { + //-- Usually this means 'not meargeable' + $markdown[] = $testResults->error; + } + else + { + //-- PhpUnit results + if($testResults->phpunit->error) + { + $markdown[] = $testResults->phpunit->error; + } + else + { + $markdown[] = sprintf('Unit testing complete. There were %1d failures and %2d errors.' + , count($testResults->phpunit->failures), count($testResults->phpunit->errors)); + } + + //-- PhpCS results + $markdown[] = sprintf('Checkstyle analysis reported %1d warnings and %2d errors.' + , count($testResults->phpcs->warnings), count($testResults->phpcs->errors)); + + //-- Details link.. + $markdown[] = ''; + $markdown[] = 'See the [Details Page]('.sprintf(self::$detailsUrl, $pullRequest->number).') for more information.'; + } + + return implode("\n", $markdown); + } +} \ No newline at end of file diff --git a/src/helper.php b/src/helper.php new file mode 100644 index 0000000..0bb827a --- /dev/null +++ b/src/helper.php @@ -0,0 +1,15 @@ +error = 'Checkstyle analysis not found.'; + + return; + } + + copy(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' + , PATH_OUTPUT.'/test/'.$pullTable->pull_id.'checkstyle.xml'); + + $numWarnings = 0; + $numErrors = 0; + + $warnings = array(); + $errors = array(); + + $reader = new XMLReader(); + $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml'); + + while ($reader->read()) + { + if ($reader->name == 'file') + { + $fName = $reader->getAttribute('name'); + + //-- @todo: strip the *right* path... + $fName = str_replace(PATH_CHECKOUTS . '/pulls/', '', $fName); + } + + if ($reader->name == 'error') + { + if ($reader->getAttribute('severity') == 'warning') + { + $e = new stdClass; + $e->file = $fName; + $e->line = (int)$reader->getAttribute('line'); + $e->message = $reader->getAttribute('message'); + + $result->warnings[] = $e; + } + + if ($reader->getAttribute('severity') == 'error') + { + $e = new stdClass; + $e->file = $fName; + $e->line = (int)$reader->getAttribute('line'); + $e->message = $reader->getAttribute('message'); + + $result->errors[] = $e; + } + } + } + + $reader->close(); + + $phpCsTable = JTable::getInstance('Checkstyle', 'Table'); + $phpCsTable->errors = count($result->errors); + $phpCsTable->warnings = count($result->warnings); + $phpCsTable->pulls_id = $pullTable->id; + + $phpCsTable->store(); + + return $result; + } +} diff --git a/src/parsers/phpunit.php b/src/parsers/phpunit.php new file mode 100644 index 0000000..5086a45 --- /dev/null +++ b/src/parsers/phpunit.php @@ -0,0 +1,91 @@ +error = 'Unit Tests log missing. Tests failed to execute.'; + $result->debugMessages[] = PullTesterHelper::stripLocalPaths($phpUnitDebug); + + return $result; + } + + copy(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml', PATH_OUTPUT.'/test/'.$pullTable->pull_id.'junit.xml'); + + $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); + + //....heho infinite loop in JError... + // $xml = JFactory::getXML(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); + // do it by hand.. + // Disable libxml errors and allow to fetch error information as needed + libxml_use_internal_errors(true); + + $xml = simplexml_load_file(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); + + if (empty($xml)) + { + // There was an error + $result->error = 'Unit Tests log corrupt.'; + + $result->debugMessages[] = PullTesterHelper::stripLocalPaths($phpUnitDebug); + + foreach (libxml_get_errors() as $error) + { + $result->debugMessages[] = PullTesterHelper::stripLocalPaths($error->message); + } + + return; + } + else + { + //-- @TODO use simple_xml to parse xml files.. + // var_dump($xml); + } + + $reader = new XMLReader(); + $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); + while ($reader->read() && $reader->name !== 'testsuite'); + + $phpUnitTable->tests = $reader->getAttribute('tests'); + $phpUnitTable->assertions = $reader->getAttribute('assertions'); + $phpUnitTable->failures = $reader->getAttribute('failures'); + $phpUnitTable->errors = $reader->getAttribute('errors'); + $phpUnitTable->time = $reader->getAttribute('time'); + $phpUnitTable->pulls_id = $pullTable->id; + $phpUnitTable->store(); + + while ($reader->read()) + { + if ($reader->name == 'error') + { + $s = $reader->readString(); + + if($s) + { + $s = preg_replace('#\/[A-Za-z\/]*pulls#', '', PullTesterHelper::stripLocalPaths($s)); + $result->errors[] = $s; + } + + // $errors[] = preg_replace('#\/[A-Za-z\/]*pulls#', '', $this->stripPaths($reader->readString())); + } + + if ($reader->name == 'failure') + { + $s = $reader->readString(); + + if($s) + { + $s = preg_replace('#\/[A-Za-z\/]*pulls#', '', PullTesterHelper::stripLocalPaths($s)); + $result->failures[] = $s; + } + } + } + + $reader->close(); + + return $result; + } +} diff --git a/src/pulltester.php b/src/pulltester.php index f7a0e3a..0d47550 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -1,13 +1,14 @@ #!/usr/bin/php Process only a specific pull - * -v Be verbose. + * --update Update the base repo. + * --reset [hard] Cleans tables and tatabase tables. "hard" also deletes the base repo. + * --pull Process only a specific pull. + * + * -v Be verbose. * * @package Joomla.Documentation * @subpackage Application @@ -41,6 +42,12 @@ jimport('joomla.client.github'); jimport('joomla.client.github2'); +require 'helper.php'; +require_once 'parsers/phpunit.php'; +require_once 'parsers/phpcs.php'; +require_once 'formats/markdown.php'; +require_once 'formats/html.php'; + JError::$legacy = false; /** @@ -52,16 +59,19 @@ class PullTester extends JCli protected $table = null; - protected $report = null; - - protected $reportHtml = ''; - protected $verbose = false; protected $phpUnitDebug = ''; + /** + * @var testResult + */ + protected $testResults = null; + protected $startTime = 0; + protected $options = null; + /** * Execute the application. * @@ -73,6 +83,11 @@ public function execute() { JTable::addIncludePath(JPATH_BASE.'/tables'); + $this->options = new stdClass; + + $this->testResults = new stdClass; + $this->testResults->error = ''; + $this->startTime = microtime(true); $reset = $this->input->get('reset'); @@ -99,18 +114,16 @@ public function execute() $this->output('Fetching pull requests...', false); $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); $pulls = $this->github->pulls->getAll($this->config->get('github_project'), $this->config->get('github_repo'), 'open', 0, 100); - - $this->github2 = new JGithub2(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); - - $this->updateTables($pulls); - $this->output('OK'); + JTable::getInstance('Pulls', 'Table')->update($pulls); + $cnt = 1; - foreach ($pulls AS $pull) + foreach ($pulls as $pull) { - if($selectedPull && $selectedPull != $pull->number) + if($selectedPull + && $selectedPull != $pull->number) { $this->output('Skipping pull '.$pull->number); $cnt ++; @@ -121,9 +134,8 @@ public function execute() $this->output('Processing pull '.$pull->number.'...', false); $this->output(sprintf('(%d/%d)...', $cnt, count($pulls)), false); - $this->report = ''; - $this->reportHtml = ''; - $this->processPull($pull); + $forceUpdate =($selectedPull) ? true : false; + $this->processPull($pull, $forceUpdate); $t = microtime(true); @@ -136,7 +148,8 @@ public function execute() $this->totalTime = microtime(true) - $this->startTime; $this->output('Generating stats...', false); - $this->generateStatsTable(); + $content = PullTesterFormatHtml::formatIndex($this->getIndexData(), $this->totalTime); + file_put_contents(PATH_OUTPUT.'/index.html', $content); $this->output('OK'); $this->output('Total time: '.$this->totalTime.' secs =;)'); @@ -144,12 +157,10 @@ public function execute() $this->close(); } - protected function processPull($pull) + protected function processPull($pull, $forceUpdate = false) { $results = new stdClass; - $db = JFactory::getDbo(); - $number = $pull->number; try { @@ -159,24 +170,19 @@ protected function processPull($pull) return; } -// try { -// $pullRequest2 = $this->github2->pulls->get($this->config->get('github_project'), $this->config->get('github_repo'), $number); -// } catch (Exception $e) { -// echo 'Error Getting Pull Request - JSON Error: '.$e->getMessage."\n"; -// return; -// } -// var_dump($pullRequest2); -// return; - $pullData = $this->loadPull($pullRequest); $changed = false; // if we haven't processed this pull request before or if new commits have been made against our repo or the head repo - if (!$pullData + if ($forceUpdate + || ! $pullData || $this->table->head != $pullRequest->head->sha || $this->table->base != $pullRequest->base->sha) { + if($forceUpdate) + $this->output('update forced...', false); + // Update the table $this->table->head = $pullRequest->head->sha; $this->table->base = $pullRequest->base->sha; @@ -196,14 +202,12 @@ protected function processPull($pull) } else { - $this->report .= 'This pull request could not be tested since the changes could not be cleanly merged.'; - $this->reportHtml .= '

    This pull request could not be tested since the changes could not be cleanly merged.

    '."\n"; + $this->testResults->error = 'This pull request could not be tested since the changes could not be cleanly merged.'; // if it was mergeable before and it isn't mergeable anymore, report that if ($this->table->mergeable) { - $this->report .= '...but it was mergeable before and it isn\'t mergeable anymore...'; - $this->reportHtml .= '

    ...but it was mergeable before and it isn\'t mergeable anymore...

    '."\n"; + $this->testResults->error .= '...but it was mergeable before and it isn\'t mergeable anymore...'; } } } @@ -244,11 +248,19 @@ protected function createRepo() mkdir(PATH_CHECKOUTS); } + if( ! file_exists(PATH_OUTPUT)) + throw new Exception('Invalid output directory: '.PATH_OUTPUT); + if( ! file_exists(PATH_OUTPUT.'/test/')) { mkdir(PATH_OUTPUT.'/test/'); } + if( ! file_exists(PATH_OUTPUT.'/pulls/')) + { + mkdir(PATH_OUTPUT.'/pulls/'); + } + if (file_exists(PATH_CHECKOUTS . '/pulls')) { if ($this->input->get('update')) @@ -270,8 +282,8 @@ protected function createRepo() protected function processResults($results) { - $this->parsePhpUnit(); - $this->parsePhpCs(); + $this->testResults->phpunit = PullTesterParserPhpUnit::parse($this->phpUnitDebug, $this->table); + $this->testResults->phpcs = PullTesterParserPhpCS::parse($this->table); } protected function build($pull) @@ -321,7 +333,6 @@ protected function build($pull) // exec('ant phpcs'); echo shell_exec('phpcs' - // .' -p' .' --report=checkstyle' .' --report-file='.PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' .' --standard=' @@ -340,223 +351,6 @@ protected function build($pull) exec('git branch -D pull' . $pull->number); } - protected function parsePhpUnit() - { - $this->reportHtml .= '

    Unit Tests

    '."\n"; - - if ( ! file_exists(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml')) - { - $this->report .= 'Test log missing. Tests failed to execute.' . "\n"; - $this->reportHtml .= '

    Test log missing. Tests failed to execute.

    '."\n"; - - $d = $this->phpUnitDebug; - $d = str_replace(PATH_CHECKOUTS . '/pulls/', '', $d); - $d = str_replace('/opt/lampp', '...', $d); - - $this->reportHtml .= '
    '.$d.'
    '; - - return; - } - - copy(PATH_CHECKOUTS . '/pulls/build/logs/junit.xml', PATH_OUTPUT.'/test/'.$this->table->pull_id.'junit.xml'); - - $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); - - //....heho infinite loop in JError... - // $xml = JFactory::getXML(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); - // do it by hand.. - // Disable libxml errors and allow to fetch error information as needed - libxml_use_internal_errors(true); - - $xml = simplexml_load_file(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); - - if (empty($xml)) - { - // There was an error - $d = $this->phpUnitDebug; - $d = str_replace(PATH_CHECKOUTS . '/pulls/', '', $d); - $d = str_replace('/opt/lampp', '...', $d); - - $this->reportHtml .= '
    '.$d;
    -
    -			foreach (libxml_get_errors() as $error)
    -			{
    -				$this->reportHtml .= $error->message."\n";
    -			}
    -
    -			$this->reportHtml .= '
    '; - - return; - } - else - { - //-- @TODO use simple_xml to parse xml files.. - // var_dump($xml); - } - - $reader = new XMLReader(); - $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); - while ($reader->read() && $reader->name !== 'testsuite'); - - $phpUnitTable->tests = $reader->getAttribute('tests'); - $phpUnitTable->assertions = $reader->getAttribute('assertions'); - $phpUnitTable->failures = $reader->getAttribute('failures'); - $phpUnitTable->errors = $reader->getAttribute('errors'); - $phpUnitTable->time = $reader->getAttribute('time'); - $phpUnitTable->pulls_id = $this->table->id; - $phpUnitTable->store(); - - $errors = array(); - $failures = array(); - - while ($reader->read()) - { - if ($reader->name == 'error') - { - $errors[] = preg_replace('#\/[A-Za-z\/]*pulls#', '', $reader->readString()); - } - - if ($reader->name == 'failure') - { - $failures[] = preg_replace('#\/[A-Za-z\/]*pulls#', '', $reader->readString()); - } - } - - $reader->close(); - - $s = sprintf('Unit testing complete. There were %1d failures and %2d errors from %3d tests and %4d assertions.' - , $phpUnitTable->failures, $phpUnitTable->errors, $phpUnitTable->tests, $phpUnitTable->assertions); - - $this->report .= $s; - - $c =($phpUnitTable->failures || $phpUnitTable->errors) ? 'img-warn' : 'img-success'; - $this->reportHtml .= '

    '.$s.'

    '."\n"; - - if($errors) - { - $this->reportHtml .= '

    Errors

    '; - - $this->reportHtml .= '
      '; - - foreach($errors as $error) - { - if( ! $error)//regex produces emty errors :( - continue; - - $this->reportHtml .= '
    1. '.htmlentities($error).'
    2. '; - } - - $this->reportHtml .= '
    '; - } - - if($failures) - { - $this->reportHtml .= '

    Failures

    '; - - $this->reportHtml .= '
      '; - - foreach($failures as $fail) - { - if( ! $fail)//regex produces emty errors :( - continue; - - $this->reportHtml .= '
    1. '.htmlentities($fail).'
    2. '; - } - - $this->reportHtml .= '
    '; - } - } - - protected function parsePhpCs() - { - $this->reportHtml .= '

    Checkstyle

    '."\n"; - - if ( ! file_exists(PATH_CHECKOUTS . '/pulls/build/logs/checkstyle.xml')) - { - $this->report .= 'Checkstyle analysis not found.' . "\n"; - $this->reportHtml .= '

    table->pull_id.'checkstyle.xml'); - - $numWarnings = 0; - $numErrors = 0; - - $warnings = array(); - $errors = array(); - - $phpCsTable = JTable::getInstance('Checkstyle', 'Table'); - - $reader = new XMLReader(); - $reader->open(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml'); - - $details = ''; - - $detailsHtml = ''; - - $maxErrors = 10; - - while ($reader->read()) - { - if ($reader->name == 'file') - { - $fName = $reader->getAttribute('name'); - - //-- @todo: strip the *right* path... - $fName = str_replace(PATH_CHECKOUTS . '/pulls/', '', $fName); - } - - if ($reader->name == 'error') - { - if ($reader->getAttribute('severity') == 'warning') - { - $numWarnings++; - } - - if ($reader->getAttribute('severity') == 'error') - { - $numErrors++; - - $detailsHtml .= '
  • '.$fName.':'.$reader->getAttribute('line').'
    '; - $detailsHtml .= ''.$reader->getAttribute('message').'
  • '."\n"; - - if($numErrors <= $maxErrors) - { - $details .= $fName.':'.$reader->getAttribute('line')."\n"; - $details .= $reader->getAttribute('message')."\n"; - } - } - } - } - - $phpCsTable->errors = $numErrors; - $phpCsTable->warnings = $numWarnings; - - $phpCsTable->pulls_id = $this->table->id; - $phpCsTable->store(); - $reader->close(); - - $s = 'Checkstyle analysis reported ' . $numWarnings . ' warnings and ' . $numErrors . ' errors.' . "\n"; - $this->report .= $s; - - $c =($numErrors) ? 'img-warn' : 'img-success'; - $this->reportHtml .= '

    '.$s.'

    '."\n"; - - if($numErrors) - { - $this->report .= '**Checkstyle error details**'."\n".$details."\n"; - $this->reportHtml .= '

    Checkstyle error details

    '."\n".'
      '.$detailsHtml.'
    '."\n"; - } - - if($numErrors > $maxErrors) - { - $this->report .= '('.($numErrors - $maxErrors).' more errors)'."\n"; - } - } - protected function publishResults($pullRequest) { @@ -572,31 +366,14 @@ protected function publishResults($pullRequest) //$request = new stdClass; //$request->body = ''; - if ($pullRequest->base->ref != 'staging') { - $this->report .= "\n\n" . '**WARNING! Pull request is not against staging!**'; - $this->reportHtml .= '

    Pull request is not against staging!

    '."\n"; - } - //curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); //curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($request)); - file_put_contents(PATH_CHECKOUTS . '/pull' . $pullRequest->number . '.txt', $this->report); - - $html = ''; - $html .= $this->getHead($pullRequest->number.' Test results'); - - $html .= ''."\n"; - - $html .= '⇐ Index'."\n"; - $html .= '

    Results for ' - .'pull request #'.$pullRequest->number.'

    '."\n"; + $report = PullTesterFormatMarkdown::format($pullRequest, $this->testResults); + file_put_contents(PATH_CHECKOUTS . '/pull' . $pullRequest->number . '.test.txt', $report); - $html .= $this->reportHtml; - - $html .= ''; - $html .= ''."\n\n"; - - file_put_contents(PATH_OUTPUT . '/' . $pullRequest->number . '.html', $html); + $report = PullTesterFormatHtml::format($pullRequest, $this->testResults); + file_put_contents(PATH_OUTPUT . '/pulls/' . $pullRequest->number . '.html', $report); //echo $this->report; } @@ -628,8 +405,11 @@ protected function reset($hard = false) JFile::delete(JFolder::files(PATH_CHECKOUTS, '.', false, true)); } - //-- Delete all HTML files but the index.html - JFile::delete(JFolder::files(PATH_OUTPUT, '.', false, true, array('index.html'))); + //-- Delete all HTML files + if(JFolder::exists(PATH_OUTPUT.'/test')) + { + JFile::delete(JFolder::files(PATH_OUTPUT.'/pulls', '.', false, true)); + } if(JFolder::exists(PATH_OUTPUT.'/test')) { @@ -660,135 +440,6 @@ protected function getIndexData() return $data; } - protected function updateTables($pulls) - { - JTable::getInstance('Pulls', 'Table')->update($pulls); - ; - } - - protected function generateStatsTable() - { - $statusColors = array(0 => 'ccff99', 1 => 'ffc',2 => 'ff7f7f',3 => 'ff0033'); - - $data = $this->getIndexData(); - - $html = $this->getHead('Test results overview'); - - $html .= ''."\n"; - - $html .= '

    Test results overview

    '."\n"; - - $html .= sprintf('We have %s open pull requests...', ''.count($data).''); - - $html .= ''."\n"; - - if(isset($data[0])) - { - $html .= ''; - - foreach ($data[0] as $key => $v) - { - $html .= ''; - } - - $html .= ''; - $html .= ''."\n"; - } - - foreach ($data as $entry) - { - $html .= ''; - - $mergeable = true; - $overall = 0; - - foreach ($entry as $key => $value) - { - $replace = '%s'; - - if( ! $mergeable) - { - $replace = '-'; - $overall = 3; - } - elseif('' == $value) - { - $replace = '? ? ?'; - $overall = 2; - } - else - { - switch ($key) - { - case 'pull_id': - $replace = 'Pull %1$s'; - break; - - case 'CS_warnings': - $replace =(0 == $value) ? '√' : '%d'; - // $overall = 1; - break; - - case 'CS_errors': - case 'Unit_failures': - case 'Unit_errors': - $replace =(0 == $value) ? '√' : '%d'; - $overall =(0 == $value) ? $overall : 1; - break; - - case 'mergeable': - $replace =($value) ? '√' : '** NO **'; - $mergeable =($value) ? true : false; - break; - }//switch - } - - $html .= ''; - }//foreach - - $html .= ''; - - $html .= ''."\n"; - }//foreach - - $html .= '
    '.$key.'Status
    '.sprintf($replace, $value).' 
    '."\n"; - - $total = $this->totalTime; - - if(file_exists(PATH_OUTPUT.'/index.html')) - { - $test = file_get_contents(PATH_OUTPUT.'/index.html'); - - preg_match('#([0-9.]+)#', $test, $matches); - - if($matches) - { - $total += $matches[1]; - } - } - - $html .= ''."\n"; - - $html .= ''."\n\n"; - - file_put_contents(PATH_OUTPUT.'/index.html', $html); - } - - protected function getHead($title) - { - $htmlHead = ''; - $htmlHead .= ''."\n"; - $htmlHead .= ''."\n"; - $htmlHead .= ''.$title.''."\n"; - $htmlHead .= ''."\n"; - $htmlHead .= ''."\n"; - - return $htmlHead; - } - /** * Method to load a PHP configuration class file based on convention and return the instantiated data object. You * will extend this method in child classes to provide configuration data from whatever data source is relevant @@ -820,6 +471,18 @@ protected function output($text = '', $nl = true) } }//class +class TestResult +{ + public $warnings = array(); + public $errors = array(); + public $failures = array(); + + public $messages = array(); + + public $error = ''; + public $debugMessages = array(); +} + try { // Execute the application. From 0445d9ff527edaf8e746c11182ced9d6ff1eefb5 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Fri, 11 Nov 2011 14:03:34 -0500 Subject: [PATCH 06/66] Add phpcs debug info --- src/formats/html.php | 44 ++++++++++++++++++++++++++--------------- src/parsers/phpcs.php | 3 ++- src/parsers/phpunit.php | 6 +++--- src/pulltester.php | 15 +++++++------- 4 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/formats/html.php b/src/formats/html.php index b404357..392df57 100644 --- a/src/formats/html.php +++ b/src/formats/html.php @@ -43,8 +43,6 @@ public static function format($pullRequest, $testResults) $html[] = '
    '.$message.'
    '; } } - - if(false){} else { $c =($testResults->phpunit->failures || $testResults->phpunit->errors) ? 'img-warn' : 'img-success'; @@ -96,10 +94,10 @@ public static function format($pullRequest, $testResults) { $html[] = '

    '.$testResults->phpcs->error.'

    '; - foreach ($testResults->phpcs->debugMessages as $message) - { - $html[] = '
    '.$message.'
    '; - } +// foreach ($testResults->phpcs->debugMessages as $message) +// { +// $html[] = '
    '.$message.'
    '; +// } } else { @@ -119,14 +117,20 @@ public static function format($pullRequest, $testResults) $html[] = '
      '; foreach ($testResults->phpcs->errors as $error) { - $html[] = '
    • '.$error->file.':'.$error->line.'
      '; - $html[] = ''.$error->message.'
    • '; + $html[] = '
    • '.$error->file.':'.$error->line.'
      '; + $html[] = ''.$error->message.'
    • '; ; } $html[] = '
    '; } } + + foreach ($testResults->phpcs->debugMessages as $message) + { + $html[] = '
    '.$message.'
    '; + } + } $html[] = '⇐ Index ⇐'; @@ -161,20 +165,26 @@ public static function formatIndex($indexData, $totalTime) if(isset($indexData[0])) { - $html[] = ''; + $row = ''; + + $row .= ''; foreach ($indexData[0] as $key => $v) { - $html[] = ''.$key.''; + $row .= ''.$key.''; } - $html[] = 'Status'; - $html[] = ''; + $row .= 'Status'; + $row .= ''; + + $html[] = $row; } foreach ($indexData as $entry) { - $html[] = ''; + $row = ''; + + $row .= ''; $mergeable = true; $overall = 0; @@ -220,12 +230,14 @@ public static function formatIndex($indexData, $totalTime) }//switch } - $html[] = ''.sprintf($replace, $value).''; + $row .= ''.sprintf($replace, $value).''; }//foreach - $html[] = ' '; + $row .= ' '; + + $row .= ''; - $html[] = ''; + $html[] = $row; }//foreach $html[] = ''; diff --git a/src/parsers/phpcs.php b/src/parsers/phpcs.php index 5099c72..7b6238a 100644 --- a/src/parsers/phpcs.php +++ b/src/parsers/phpcs.php @@ -1,13 +1,14 @@ error = 'Checkstyle analysis not found.'; + $result->debugMessages[] = PullTesterHelper::stripLocalPaths($debug); return; } diff --git a/src/parsers/phpunit.php b/src/parsers/phpunit.php index 5086a45..c350f1e 100644 --- a/src/parsers/phpunit.php +++ b/src/parsers/phpunit.php @@ -1,14 +1,14 @@ error = 'Unit Tests log missing. Tests failed to execute.'; - $result->debugMessages[] = PullTesterHelper::stripLocalPaths($phpUnitDebug); + $result->debugMessages[] = PullTesterHelper::stripLocalPaths($debug); return $result; } @@ -30,7 +30,7 @@ public static function parse($phpUnitDebug, JTable $pullTable) // There was an error $result->error = 'Unit Tests log corrupt.'; - $result->debugMessages[] = PullTesterHelper::stripLocalPaths($phpUnitDebug); + $result->debugMessages[] = PullTesterHelper::stripLocalPaths($debug); foreach (libxml_get_errors() as $error) { diff --git a/src/pulltester.php b/src/pulltester.php index 0d47550..59bbdd8 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -62,6 +62,7 @@ class PullTester extends JCli protected $verbose = false; protected $phpUnitDebug = ''; + protected $phpCsDebug = ''; /** * @var testResult @@ -85,9 +86,6 @@ public function execute() $this->options = new stdClass; - $this->testResults = new stdClass; - $this->testResults->error = ''; - $this->startTime = microtime(true); $reset = $this->input->get('reset'); @@ -131,6 +129,9 @@ public function execute() continue; } + $this->testResults = new stdClass; + $this->testResults->error = ''; + $this->output('Processing pull '.$pull->number.'...', false); $this->output(sprintf('(%d/%d)...', $cnt, count($pulls)), false); @@ -283,7 +284,7 @@ protected function createRepo() protected function processResults($results) { $this->testResults->phpunit = PullTesterParserPhpUnit::parse($this->phpUnitDebug, $this->table); - $this->testResults->phpcs = PullTesterParserPhpCS::parse($this->table); + $this->testResults->phpcs = PullTesterParserPhpCS::parse($this->phpCsDebug, $this->table); } protected function build($pull) @@ -331,7 +332,7 @@ protected function build($pull) $this->output('Running the CodeSniffer...', false); // exec('ant phpcs'); - + ob_start(); echo shell_exec('phpcs' .' --report=checkstyle' .' --report-file='.PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' @@ -341,7 +342,7 @@ protected function build($pull) .'build/phpcs/Joomla' .' libraries/joomla' .' 2>&1'); - + $this->phpCsDebug = ob_get_clean(); $this->output('OK'); //-- Fishy things happen all along the way... @@ -406,7 +407,7 @@ protected function reset($hard = false) } //-- Delete all HTML files - if(JFolder::exists(PATH_OUTPUT.'/test')) + if(JFolder::exists(PATH_OUTPUT.'/pulls')) { JFile::delete(JFolder::files(PATH_OUTPUT.'/pulls', '.', false, true)); } From fcf9b28745e5800e8adae9c4f326f1ff7a16a7e0 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Mon, 28 Nov 2011 05:22:01 -0500 Subject: [PATCH 07/66] Add username, title and avatar to status output --- src/formats/html.php | 4 ++++ src/pulltester.php | 25 +++++++++++++------------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/src/formats/html.php b/src/formats/html.php index 392df57..94be63f 100644 --- a/src/formats/html.php +++ b/src/formats/html.php @@ -20,6 +20,10 @@ public static function format($pullRequest, $testResults) $html[] = '

    Results for ' .'pull request #'.$pullRequest->number.'

    '; + $html[] = '

    '.$pullRequest->user->login.'
    '; + $html[] = '

    '.htmlspecialchars($pullRequest->title).'

    '; + $html[] = '
    '; + if('staging' != $pullRequest->base->ref) { $html[] = '

    Pull request is not against staging!

    '; diff --git a/src/pulltester.php b/src/pulltester.php index 59bbdd8..92c733c 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -227,15 +227,22 @@ protected function processPull($pull, $forceUpdate = false) public function loadPull($pull) { $this->table = JTable::getInstance('Pulls', 'Table'); - if (!$this->table->loadByNumber($pull->number)) + + if( ! $this->table->loadByNumber($pull->number)) { $this->table->reset(); + $this->table->id = 0; $this->table->pull_id = $pull->number; $this->table->head = $pull->head->sha; $this->table->base = $pull->base->sha; $this->table->mergeable = $pull->mergeable; + $this->table->title = $pull->title; + $this->table->user = $pull->user->login; + $this->table->avatar_url = $pull->user->avatar_url; + $this->table->store(); + return false; } @@ -245,22 +252,16 @@ public function loadPull($pull) protected function createRepo() { if (!file_exists(PATH_CHECKOUTS)) - { - mkdir(PATH_CHECKOUTS); - } + mkdir(PATH_CHECKOUTS); if( ! file_exists(PATH_OUTPUT)) throw new Exception('Invalid output directory: '.PATH_OUTPUT); if( ! file_exists(PATH_OUTPUT.'/test/')) - { - mkdir(PATH_OUTPUT.'/test/'); - } + mkdir(PATH_OUTPUT.'/test/'); if( ! file_exists(PATH_OUTPUT.'/pulls/')) - { - mkdir(PATH_OUTPUT.'/pulls/'); - } + mkdir(PATH_OUTPUT.'/pulls/'); if (file_exists(PATH_CHECKOUTS . '/pulls')) { @@ -428,9 +429,9 @@ protected function getIndexData() $query->leftJoin('phpCsResults AS cs on p.id=cs.pulls_id'); $query->leftJoin('phpunitResults AS pu on p.id=pu.pulls_id'); - $query->select('p.pull_id, p.mergeable'); + $query->select('p.pull_id, p.user, p.mergeable'); $query->select('cs.warnings AS CS_warnings, cs.errors AS CS_errors'); - $query->select('pu.failures AS Unit_failures, pu.errors AS Unit_errors'); + $query->select('pu.failures AS UT_failures, pu.errors AS UT_errors'); $query->order('p.pull_id DESC'); From b544cd6369c36e6bbd11868e18dc8750a54a03f8 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:15:02 -0500 Subject: [PATCH 08/66] Add readme - please **readme** =;) --- readme.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 readme.md diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..6c21474 --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +## Ian's PullTester +Disclaimer? This is a **personal** project not supported by or affiliated to the [Joomla! Project](http://joomla.org) or [Open Source Matters](osm.org). + +The purpose of this script is running the Joomla! platform code style and unit tests against the currently open pull requests. + +### Requirements: + +* [PHP CodeSniffer](http://pear.php.net/package/PHP_CodeSniffer) +* [PHPUnit](https://github.com/sebastianbergmann/phpunit) +* The [Joomla! Platform](https://github.com/joomla/joomla-platform) (the more recent the better) + +### Setup +Edit the config.php and set the required paths. + +run + +```pulltester.php + +Optional arguments: +--update Update the repository +--reset [hard] Reset the data. **hard** will nuke everything ! + +-v Verbose +``` + +have Fun ```=;)``` From 403464b60069f2eb47cb5647e41d88ff892d6322 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:15:34 -0500 Subject: [PATCH 09/66] Move output path to config --- src/pulltester.php | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/src/pulltester.php b/src/pulltester.php index 92c733c..ab77c05 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -32,9 +32,8 @@ define('JPATH_BASE', dirname(__FILE__)); define('JPATH_SITE', JPATH_BASE); -define('PATH_CHECKOUTS', dirname(dirname(__FILE__)).'/checkouts'); -define('PATH_OUTPUT', '/home/elkuku/eclipsespace/indigogit3/pulltester-gh-pages'); +define('PATH_CHECKOUTS', dirname(dirname(__FILE__)).'/checkouts'); jimport('joomla.application.cli'); jimport('joomla.database'); @@ -82,6 +81,8 @@ class PullTester extends JCli */ public function execute() { + define('PATH_OUTPUT', $this->config->get('targetPath')); + JTable::addIncludePath(JPATH_BASE.'/tables'); $this->options = new stdClass; @@ -98,6 +99,9 @@ public function execute() $this->output('-- Ian\'s PullTester --'); $this->output('----------------------'); + $this->output('Checkout dir :'.PATH_CHECKOUTS); + $this->output('Target dir :'.PATH_OUTPUT); + if($reset) { $this->output('Resetting...', false); @@ -112,7 +116,7 @@ public function execute() $this->output('Fetching pull requests...', false); $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); $pulls = $this->github->pulls->getAll($this->config->get('github_project'), $this->config->get('github_repo'), 'open', 0, 100); - $this->output('OK'); + $this->output('Processing '.count($pulls).' pulls...'); JTable::getInstance('Pulls', 'Table')->update($pulls); @@ -298,12 +302,12 @@ protected function build($pull) exec('git remote add ' . $pull->user->login . ' ' . $pull->head->repo->git_url); } - exec('git checkout staging 2>/dev/null'); + exec('git checkout staging &>/dev/null'); //-- Just in case, if, for any oscure reason, the branch we are trying to create already exists... //-- git wont switch to it and will remain on the 'staging' branch so... //-- let's first try to delete it =;) - exec('git branch -D pull'.$pull->number.' 2>/dev/null'); + exec('git branch -D pull'.$pull->number.' &>/dev/null'); exec('git checkout -b pull'.$pull->number); @@ -337,10 +341,7 @@ protected function build($pull) echo shell_exec('phpcs' .' --report=checkstyle' .' --report-file='.PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' - .' --standard=' - .'/home/elkuku/libs/joomla/' - // .$basedir - .'build/phpcs/Joomla' + .' --standard=build/phpcs/Joomla'//.$this->config->get('codeStandardsPath') .' libraries/joomla' .' 2>&1'); $this->phpCsDebug = ob_get_clean(); @@ -348,7 +349,7 @@ protected function build($pull) //-- Fishy things happen all along the way... //-- Let's use the -f (force) option.. - exec('git checkout -f staging'); + exec('git checkout -f staging &>/dev/null'); exec('git branch -D pull' . $pull->number); } @@ -398,9 +399,7 @@ protected function reset($hard = false) $this->output('ALL FILES...', false); if(JFolder::exists(PATH_CHECKOUTS)) - { - JFolder::delete(PATH_CHECKOUTS); - } + JFolder::delete(PATH_CHECKOUTS); } else { @@ -409,14 +408,10 @@ protected function reset($hard = false) //-- Delete all HTML files if(JFolder::exists(PATH_OUTPUT.'/pulls')) - { - JFile::delete(JFolder::files(PATH_OUTPUT.'/pulls', '.', false, true)); - } + JFile::delete(JFolder::files(PATH_OUTPUT.'/pulls', '.', false, true)); - if(JFolder::exists(PATH_OUTPUT.'/test')) - { - JFile::delete(JFolder::files(PATH_OUTPUT.'/test', '.', false, true)); - } + if(JFolder::exists(PATH_OUTPUT.'/logs')) + JFile::delete(JFolder::files(PATH_OUTPUT.'/logs', '.', false, true)); } protected function getIndexData() From e6f3a955a7660c6a2459d751d9f32c6da3b30012 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:18:54 -0500 Subject: [PATCH 10/66] Clean local paths in log files --- src/parsers/phpcs.php | 6 ++++-- src/parsers/phpunit.php | 8 ++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/parsers/phpcs.php b/src/parsers/phpcs.php index 7b6238a..88aef31 100644 --- a/src/parsers/phpcs.php +++ b/src/parsers/phpcs.php @@ -13,8 +13,10 @@ public static function parse($debug, JTable $pullTable) return; } - copy(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' - , PATH_OUTPUT.'/test/'.$pullTable->pull_id.'checkstyle.xml'); + $contents = JFile::read(PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml'); + $contents = PullTesterHelper::stripLocalPaths($contents); + + JFile::write(PATH_OUTPUT.'/logs/'.$pullTable->pull_id.'checkstyle.xml', $contents); $numWarnings = 0; $numErrors = 0; diff --git a/src/parsers/phpunit.php b/src/parsers/phpunit.php index c350f1e..22fba50 100644 --- a/src/parsers/phpunit.php +++ b/src/parsers/phpunit.php @@ -13,13 +13,17 @@ public static function parse($debug, JTable $pullTable) return $result; } - copy(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml', PATH_OUTPUT.'/test/'.$pullTable->pull_id.'junit.xml'); + $contents = JFile::read(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); + $contents = PullTesterHelper::stripLocalPaths($contents); + + JFile::write(PATH_OUTPUT.'/logs/'.$pullTable->pull_id.'junit.xml', $contents); $phpUnitTable = JTable::getInstance('Phpunit', 'Table'); - //....heho infinite loop in JError... + //....heho infinite loop in JError... ;-(((( // $xml = JFactory::getXML(PATH_CHECKOUTS.'/pulls/build/logs/junit.xml'); // do it by hand.. + // Disable libxml errors and allow to fetch error information as needed libxml_use_internal_errors(true); From b35396236dc218587597c691bcecd92a285c3354 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:20:33 -0500 Subject: [PATCH 11/66] Add another check for fishy UT logs, and a link to the published xml log files --- src/formats/html.php | 97 ++++++++++++++++++++++++++-------------- src/formats/markdown.php | 6 ++- 2 files changed, 68 insertions(+), 35 deletions(-) diff --git a/src/formats/html.php b/src/formats/html.php index 94be63f..9705468 100644 --- a/src/formats/html.php +++ b/src/formats/html.php @@ -18,7 +18,7 @@ public static function format($pullRequest, $testResults) $html[] = '⇐ Index ⇐'; $html[] = '

    Results for ' - .'pull request #'.$pullRequest->number.'

    '; + .'Pull Request #'.$pullRequest->number.''; $html[] = '

    '.$pullRequest->user->login.'
    '; $html[] = '

    '.htmlspecialchars($pullRequest->title).'

    '; @@ -26,11 +26,11 @@ public static function format($pullRequest, $testResults) if('staging' != $pullRequest->base->ref) { - $html[] = '

    Pull request is not against staging!

    '; + $html[] = '

    Pull request is not against staging !

    '; } elseif($testResults->error) { - //-- Usually this means 'not meargeable' + //-- Usually this means 'not mergeable' $html[] = '

    '.$testResults->error.'

    '; } else @@ -38,7 +38,11 @@ public static function format($pullRequest, $testResults) //-- PhpUnit results $html[] = '

    Unit Tests

    '; - if($testResults->phpunit->error) + if( ! isset($testResults->phpunit)) + { + $markdown[] = 'Something really fishy happened while executing the unit tests - please FIXME !'; + } + elseif($testResults->phpunit->error) { $html[] = '

    '.$testResults->phpunit->error.'

    '; @@ -51,9 +55,11 @@ public static function format($pullRequest, $testResults) { $c =($testResults->phpunit->failures || $testResults->phpunit->errors) ? 'img-warn' : 'img-success'; - $s = sprintf('Unit testing complete. There were %1d failures and %2d errors.' + $s = sprintf('There were %1d failures and %2d errors.' , count($testResults->phpunit->failures), count($testResults->phpunit->errors)); + $s .= ' Unit Test Log'; + $html[] = '

    '.$s.'

    '; if($testResults->phpunit->errors) @@ -97,16 +103,12 @@ public static function format($pullRequest, $testResults) if($testResults->phpcs->error) { $html[] = '

    '.$testResults->phpcs->error.'

    '; - -// foreach ($testResults->phpcs->debugMessages as $message) -// { -// $html[] = '
    '.$message.'
    '; -// } } else { - $s = sprintf('Checkstyle analysis reported %1d warnings and %2d errors.' + $s = sprintf('There were %1d warnings and %2d errors.' , count($testResults->phpcs->warnings), count($testResults->phpcs->errors)); + $s .= ' Checkstyle Log'; $c =($testResults->phpcs->errors) ? 'img-warn' : 'img-success'; @@ -116,14 +118,14 @@ public static function format($pullRequest, $testResults) if($testResults->phpcs->errors) { - $html[] = '

    Checkstyle error details

    '; + $html[] = '

    Errors

    '; $html[] = '
      '; - foreach ($testResults->phpcs->errors as $error) { + foreach ($testResults->phpcs->errors as $error) + { $html[] = '
    • '.$error->file.':'.$error->line.'
      '; $html[] = ''.$error->message.'
    • '; - ; } $html[] = '
    '; @@ -134,12 +136,15 @@ public static function format($pullRequest, $testResults) { $html[] = '
    '.$message.'
    '; } - } $html[] = '⇐ Index ⇐'; - $html[] = ''; + $html[] = ''; $html[] = ''; $html[] = ''; @@ -148,6 +153,14 @@ public static function format($pullRequest, $testResults) return implode("\n", $html); } + /** + * Generate an index.html file. + * + * @param array $indexData + * @param float $totalTime + * + * @return string + */ public static function formatIndex($indexData, $totalTime) { $html = array(); @@ -173,7 +186,7 @@ public static function formatIndex($indexData, $totalTime) $row .= ''; - foreach ($indexData[0] as $key => $v) + foreach(array_keys($indexData[0]) as $key) { $row .= ''.$key.''; } @@ -184,7 +197,7 @@ public static function formatIndex($indexData, $totalTime) $html[] = $row; } - foreach ($indexData as $entry) + foreach($indexData as $entry) { $row = ''; @@ -193,7 +206,7 @@ public static function formatIndex($indexData, $totalTime) $mergeable = true; $overall = 0; - foreach ($entry as $key => $value) + foreach($entry as $key => $value) { $replace = '%s'; @@ -209,10 +222,15 @@ public static function formatIndex($indexData, $totalTime) } else { - switch ($key) + switch($key) { case 'pull_id': - $replace = 'Pull %1$s'; + $replace = 'Pull %1$d'; + break; + + case 'mergeable': + $replace =($value) ? '√' : '** NO **'; + $mergeable =($value) ? true : false; break; case 'CS_warnings': @@ -221,23 +239,31 @@ public static function formatIndex($indexData, $totalTime) break; case 'CS_errors': - case 'Unit_failures': - case 'Unit_errors': + case 'UT_failures': + case 'UT_errors': $replace =(0 == $value) ? '√' : '%d'; $overall =(0 == $value) ? $overall : 1; break; - - case 'mergeable': - $replace =($value) ? '√' : '** NO **'; - $mergeable =($value) ? true : false; - break; }//switch } $row .= ''.sprintf($replace, $value).''; }//foreach - $row .= ' '; + $row .= ''; + + if($mergeable) + { + $row .= 'CS Log'; + $row .= ' • '; + $row .= 'UT Log'; + } + else + { + $row .= ' '; + } + + $row .= ''; $row .= ''; @@ -260,16 +286,18 @@ public static function formatIndex($indexData, $totalTime) $html[] = ''; + .'Generated on '.date('d-M-Y H:i P T e'); + $html[] = '
    BTW: If you want to run this tests on your own machine - The source code is available on GitHub' + .' and is based on Ian McLennan\'s PullTester =;)
    '; + $html[] = ''; $html[] = ''; $html[] = ''; $html[] = ''; return implode("\n", $html); - } + }//function protected static function getHead($title) { @@ -284,5 +312,6 @@ protected static function getHead($title) $html[] = ''; return implode("\n", $html); - } -} + }//function + +}//class diff --git a/src/formats/markdown.php b/src/formats/markdown.php index 1e44aa7..af0720c 100644 --- a/src/formats/markdown.php +++ b/src/formats/markdown.php @@ -1,7 +1,7 @@ phpunit)) + { + $markdown[] = 'Something really fishy happened while executing the unit tests - please FIXME !'; + } if($testResults->phpunit->error) { $markdown[] = $testResults->phpunit->error; From a24ed2a4006868954a5d4b78bd40ed47a9877073 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:20:58 -0500 Subject: [PATCH 12/66] Add config.dist.php --- src/config.dist.php | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/config.dist.php diff --git a/src/config.dist.php b/src/config.dist.php new file mode 100644 index 0000000..73f6401 --- /dev/null +++ b/src/config.dist.php @@ -0,0 +1,45 @@ + Date: Tue, 29 Nov 2011 00:21:45 -0500 Subject: [PATCH 13/66] Add option to "override" the coding standards with a custom standard --- src/pulltester.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/pulltester.php b/src/pulltester.php index ab77c05..c516b47 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -336,12 +336,16 @@ protected function build($pull) $this->output('OK'); $this->output('Running the CodeSniffer...', false); + + $standard = $this->config->get('codeStandardsPath'); + if( ! $standard) $standard = 'build/phpcs/Joomla'; + // exec('ant phpcs'); ob_start(); echo shell_exec('phpcs' .' --report=checkstyle' .' --report-file='.PATH_CHECKOUTS.'/pulls/build/logs/checkstyle.xml' - .' --standard=build/phpcs/Joomla'//.$this->config->get('codeStandardsPath') + .' --standard='.$standard .' libraries/joomla' .' 2>&1'); $this->phpCsDebug = ob_get_clean(); From 8deec069fa2157ee8c22cd21a79e3ce97937e9b4 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:24:22 -0500 Subject: [PATCH 14/66] Update readme - please **readme** =;) --- readme.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/readme.md b/readme.md index 6c21474..cc726a5 100644 --- a/readme.md +++ b/readme.md @@ -10,17 +10,21 @@ The purpose of this script is running the Joomla! platform code style and unit t * The [Joomla! Platform](https://github.com/joomla/joomla-platform) (the more recent the better) ### Setup -Edit the config.php and set the required paths. +Edit the ```config.dist.php```, set the required paths and rename it to ```config.php```. -run +### Execute +```cd``` to the ```src``` path and run -```pulltester.php +``` +pulltester.php +``` + +**Optional arguments:** -Optional arguments: ---update Update the repository ---reset [hard] Reset the data. **hard** will nuke everything ! +* ```--update``` Update the repository +* ```--reset [hard]``` Reset the data. **hard** will nuke everything ! --v Verbose +* ```-v``` Verbose ``` have Fun ```=;)``` From 1c0e9b56cd761d0636eff1ac06d51b0bd27b6452 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:30:47 -0500 Subject: [PATCH 15/66] Remove personal paths --- src/config.dist.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/config.dist.php b/src/config.dist.php index 73f6401..314b7b1 100644 --- a/src/config.dist.php +++ b/src/config.dist.php @@ -8,7 +8,7 @@ class JConfig public $targetPath = ''; /** Path to the Joomla! Platform Coding Standards (override) */ - public $codeStandardsPath = '/home/elkuku/libs/joomla/build/phpcs/Joomla'; + public $codeStandardsPath = ''; public $dbtype = 'mysql'; public $host = '127.0.0.1'; @@ -22,8 +22,8 @@ class JConfig public $ftp_pass = ''; public $ftp_root = ''; public $ftp_enable = 0; - public $tmp_path = '/home/elkuku/eclipsespace/indigogit3/joomla-platform/tmp'; - public $log_path = '/home/elkuku/eclipsespace/indigogit3/joomla-platform/logs'; + public $tmp_path = '/tmp'; + public $log_path = '/logs'; public $mailer = 'mail'; public $mailfrom = 'admin@localhost.home'; public $fromname = ''; From 6036162ae6694d87c08c7c4b7992a8853270024e Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 00:33:24 -0500 Subject: [PATCH 16/66] Update readme - please **readme** =;) --- readme.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index cc726a5..f76ee03 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,10 @@ ## Ian's PullTester -Disclaimer? This is a **personal** project not supported by or affiliated to the [Joomla! Project](http://joomla.org) or [Open Source Matters](osm.org). +Disclaimer? This is a **personal** project **!** It is **not** supported by or affiliated to the [Joomla! Project](http://joomla.org) or [Open Source Matters](osm.org). The purpose of this script is running the Joomla! platform code style and unit tests against the currently open pull requests. +This is based on [Ian McLennan's PullTester](https://github.com/ianmacl/pulltester). I really admire him for his innovative ideas (like this thingy). + ### Requirements: * [PHP CodeSniffer](http://pear.php.net/package/PHP_CodeSniffer) @@ -25,6 +27,6 @@ pulltester.php * ```--reset [hard]``` Reset the data. **hard** will nuke everything ! * ```-v``` Verbose -``` have Fun ```=;)``` + From f5a35626f8446aeffa4fe73f13b2757fe3a4bfce Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 04:25:05 -0500 Subject: [PATCH 17/66] Add a setup method, renamed output() to say() --- src/pulltester.php | 179 ++++++++++++++++++++++++++------------------- 1 file changed, 104 insertions(+), 75 deletions(-) diff --git a/src/pulltester.php b/src/pulltester.php index c516b47..9e9f505 100755 --- a/src/pulltester.php +++ b/src/pulltester.php @@ -8,7 +8,7 @@ * --reset [hard] Cleans tables and tatabase tables. "hard" also deletes the base repo. * --pull Process only a specific pull. * - * -v Be verbose. + * -v Be verbose. * * @package Joomla.Documentation * @subpackage Application @@ -29,6 +29,7 @@ * Bootstrap the Joomla! Platform. */ require_once dirname(dirname(__FILE__)) . '/platform/libraries/import.php'; +// require $_SERVER['JOOMLA_PLATFORM_PATH'].'/libraries/import.php'; define('JPATH_BASE', dirname(__FILE__)); define('JPATH_SITE', JPATH_BASE); @@ -39,7 +40,6 @@ jimport('joomla.database'); jimport('joomla.database.table'); jimport('joomla.client.github'); -jimport('joomla.client.github2'); require 'helper.php'; require_once 'parsers/phpunit.php'; @@ -50,7 +50,7 @@ JError::$legacy = false; /** - * + * Ian's PullTester */ class PullTester extends JCli { @@ -81,87 +81,121 @@ class PullTester extends JCli */ public function execute() { - define('PATH_OUTPUT', $this->config->get('targetPath')); + $this->verbose = $this->input->get('v', 0); - JTable::addIncludePath(JPATH_BASE.'/tables'); + $this->say('----------------------'); + $this->say('-- Ian\'s PullTester --'); + $this->say('----------------------'); - $this->options = new stdClass; + $this->setup(); - $this->startTime = microtime(true); + $this->say('Checkout dir :'.PATH_CHECKOUTS); + $this->say('Target dir :'.PATH_OUTPUT); $reset = $this->input->get('reset'); - $this->verbose = $this->input->get('v', 0); - $selectedPull = $this->input->get('pull', 0, 'INT'); - $this->output('----------------------'); - $this->output('-- Ian\'s PullTester --'); - $this->output('----------------------'); - - $this->output('Checkout dir :'.PATH_CHECKOUTS); - $this->output('Target dir :'.PATH_OUTPUT); - if($reset) { - $this->output('Resetting...', false); + $this->say('Resetting...', false); $this->reset('hard' == $reset); - $this->output('OK'); + $this->say('OK'); } - $this->output('Creating/Updating the base repo...', false); - $this->createRepo(); - $this->output('OK'); + $this->say('Creating/Updating the base repo...', false); + $this->createUpdateRepo(); + $this->say('OK'); - $this->output('Fetching pull requests...', false); - $this->github = new JGithub(array('username' => $this->config->get('github_username'), 'password' => $this->config->get('github_password'))); + $this->say('Fetching pull requests...', false); $pulls = $this->github->pulls->getAll($this->config->get('github_project'), $this->config->get('github_repo'), 'open', 0, 100); - $this->output('Processing '.count($pulls).' pulls...'); + $this->say('Processing '.count($pulls).' pulls...'); JTable::getInstance('Pulls', 'Table')->update($pulls); $cnt = 1; + $lapTime = $this->startTime; - foreach ($pulls as $pull) + foreach($pulls as $pull) { if($selectedPull && $selectedPull != $pull->number) { - $this->output('Skipping pull '.$pull->number); + $this->say('Skipping pull '.$pull->number); $cnt ++; continue; } + $this->say('------------------------'); $this->testResults = new stdClass; $this->testResults->error = ''; - $this->output('Processing pull '.$pull->number.'...', false); - $this->output(sprintf('(%d/%d)...', $cnt, count($pulls)), false); + $this->say('Processing pull '.$pull->number.'...', false); + $this->say(sprintf('(%d/%d)...', $cnt, count($pulls)), false); $forceUpdate =($selectedPull) ? true : false; $this->processPull($pull, $forceUpdate); - $t = microtime(true); + $t = microtime(true) - $lapTime; - $this->output('Finished in '.($t - $this->startTime).' secs'); - $this->output('------------------------'); + $this->say('Finished in '.$t.' secs'); $cnt ++; - } + $lapTime += $t; + }//foreach + + $this->say('------------------------'); - $this->totalTime = microtime(true) - $this->startTime; + $totalTime = microtime(true) - $this->startTime; - $this->output('Generating stats...', false); - $content = PullTesterFormatHtml::formatIndex($this->getIndexData(), $this->totalTime); + $this->say('Generating stats...', false); + $content = PullTesterFormatHtml::formatIndex($this->getIndexData(), $totalTime); file_put_contents(PATH_OUTPUT.'/index.html', $content); - $this->output('OK'); + $this->say('OK'); - $this->output('Total time: '.$this->totalTime.' secs =;)'); + $this->say(sprintf('Total time: %s secs =;)', $totalTime)); $this->close(); } + protected function setup() + { + $this->say('Setup...', false); + + $this->startTime = microtime(true); + $this->options = new stdClass; + + $this->github = new JGithub( + array('username' => $this->config->get('github_username') + , 'password' => $this->config->get('github_password')) + ); + + define('PATH_OUTPUT', $this->config->get('targetPath')); + + JTable::addIncludePath(JPATH_BASE.'/tables'); + + $this->table = JTable::getInstance('Pulls', 'Table'); + + $this->say('Creating base directories...', false); + + if (!file_exists(PATH_CHECKOUTS)) + mkdir(PATH_CHECKOUTS); + + if( ! file_exists(PATH_OUTPUT)) + throw new Exception('Invalid output directory: '.PATH_OUTPUT); + + if( ! file_exists(PATH_OUTPUT.'/test/')) + mkdir(PATH_OUTPUT.'/test/'); + + if( ! file_exists(PATH_OUTPUT.'/pulls/')) + mkdir(PATH_OUTPUT.'/pulls/'); + + $this->say('ok'); + + return $this; + } + protected function processPull($pull, $forceUpdate = false) { $results = new stdClass; @@ -169,7 +203,9 @@ protected function processPull($pull, $forceUpdate = false) $number = $pull->number; try { - $pullRequest = $this->github->pulls->get($this->config->get('github_project'), $this->config->get('github_repo'), $number); + $pullRequest = $this->github->pulls->get( + $this->config->get('github_project'), $this->config->get('github_repo'), $number + ); } catch (Exception $e) { echo 'Error Getting Pull Request - JSON Error: '.$e->getMessage."\n"; return; @@ -179,14 +215,15 @@ protected function processPull($pull, $forceUpdate = false) $changed = false; - // if we haven't processed this pull request before or if new commits have been made against our repo or the head repo + // if we haven't processed this pull request before or if new commits have been made + // against our repo or the head repo if ($forceUpdate || ! $pullData || $this->table->head != $pullRequest->head->sha || $this->table->base != $pullRequest->base->sha) { if($forceUpdate) - $this->output('update forced...', false); + $this->say('update forced...', false); // Update the table $this->table->head = $pullRequest->head->sha; @@ -230,8 +267,6 @@ protected function processPull($pull, $forceUpdate = false) public function loadPull($pull) { - $this->table = JTable::getInstance('Pulls', 'Table'); - if( ! $this->table->loadByNumber($pull->number)) { $this->table->reset(); @@ -253,20 +288,8 @@ public function loadPull($pull) return true; } - protected function createRepo() + protected function createUpdateRepo() { - if (!file_exists(PATH_CHECKOUTS)) - mkdir(PATH_CHECKOUTS); - - if( ! file_exists(PATH_OUTPUT)) - throw new Exception('Invalid output directory: '.PATH_OUTPUT); - - if( ! file_exists(PATH_OUTPUT.'/test/')) - mkdir(PATH_OUTPUT.'/test/'); - - if( ! file_exists(PATH_OUTPUT.'/pulls/')) - mkdir(PATH_OUTPUT.'/pulls/'); - if (file_exists(PATH_CHECKOUTS . '/pulls')) { if ($this->input->get('update')) @@ -311,11 +334,11 @@ protected function build($pull) exec('git checkout -b pull'.$pull->number); - $this->output('Fetch repo: '.$pull->user->login); + $this->say('Fetch repo: '.$pull->user->login); exec('git fetch ' . $pull->user->login); - $this->output('Merge repo: '.$pull->user->login . '/' . $pull->head->ref); + $this->say('Merge repo: '.$pull->user->login . '/' . $pull->head->ref); exec('git merge ' . $pull->user->login . '/' . $pull->head->ref); // exec('ant clean'); @@ -323,7 +346,7 @@ protected function build($pull) exec('rm build/logs/junit.xml 2>/dev/null'); exec('touch build/logs/checkstyle.xml'); - $this->output('Running PHPUnit...', false); + $this->say('Running PHPUnit...', false); ob_start(); // exec('ant phpunit'); @@ -333,9 +356,9 @@ protected function build($pull) $this->phpUnitDebug = ob_get_clean(); - $this->output('OK'); + $this->say('OK'); - $this->output('Running the CodeSniffer...', false); + $this->say('Running CodeSniffer...', false); $standard = $this->config->get('codeStandardsPath'); if( ! $standard) $standard = 'build/phpcs/Joomla'; @@ -349,7 +372,7 @@ protected function build($pull) .' libraries/joomla' .' 2>&1'); $this->phpCsDebug = ob_get_clean(); - $this->output('OK'); + $this->say('OK'); //-- Fishy things happen all along the way... //-- Let's use the -f (force) option.. @@ -389,18 +412,18 @@ protected function reset($hard = false) { jimport('joomla.filesystem.file'); - $this->output('truncating tables...', false); + $this->say('truncating tables...', false); JTable::getInstance('Checkstyle', 'Table')->truncate(); JTable::getInstance('Phpunit', 'Table')->truncate(); JTable::getInstance('Pulls', 'Table')->truncate(); - $this->output('deleting files...', false); + $this->say('deleting files...', false); //-- Remove the checkout files if($hard) { - $this->output('ALL FILES...', false); + $this->say('ALL FILES...', false); if(JFolder::exists(PATH_CHECKOUTS)) JFolder::delete(PATH_CHECKOUTS); @@ -436,9 +459,7 @@ protected function getIndexData() $db->setQuery($query); - $data = $db->loadObjectList(); - - return $data; + return $db->loadObjectList(); } /** @@ -450,28 +471,36 @@ protected function getIndexData() * * @since 11.1 */ - protected function fetchConfigurationData($config = 'test') + protected function fetchConfigurationData() { - $configFile = $this->input->get('config', 'config.php'); - require_once $configFile; - if (!class_exists('JConfig')) + require_once $this->input->get('config', 'config.php'); + + if( ! class_exists('JConfig')) { return false; } - $config = new JConfig; - return $config; + return new JConfig; } - protected function output($text = '', $nl = true) + protected function say($text = '', $nl = true) { if( ! $this->verbose) - return; + { + return; + } $this->out($text, $nl); } }//class +/** + * Test result class. + * + * @package PullTester + * @subpackage Helper classes + * @since 1.0 + */ class TestResult { public $warnings = array(); From 187746c66b4f60d62a00e0aaff72e05624637b97 Mon Sep 17 00:00:00 2001 From: Nikolai Plath Date: Tue, 29 Nov 2011 04:26:35 -0500 Subject: [PATCH 18/66] Objects have no array_keys.. --- src/formats/html.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/formats/html.php b/src/formats/html.php index 9705468..e8e9ee2 100644 --- a/src/formats/html.php +++ b/src/formats/html.php @@ -17,7 +17,7 @@ public static function format($pullRequest, $testResults) $html[] = '⇐ Index ⇐'; - $html[] = '

    Results for ' + $html[] = '

    Details for ' .'Pull Request #'.$pullRequest->number.'

    '; $html[] = '

    '.$pullRequest->user->login.'
    '; @@ -58,7 +58,7 @@ public static function format($pullRequest, $testResults) $s = sprintf('There were %1d failures and %2d errors.' , count($testResults->phpunit->failures), count($testResults->phpunit->errors)); - $s .= ' Unit Test Log'; + $s .= ' Unit Test Log (XML)'; $html[] = '

    '.$s.'

    '; @@ -108,7 +108,7 @@ public static function format($pullRequest, $testResults) { $s = sprintf('There were %1d warnings and %2d errors.' , count($testResults->phpcs->warnings), count($testResults->phpcs->errors)); - $s .= ' Checkstyle Log'; + $s .= ' Checkstyle Log (XML)'; $c =($testResults->phpcs->errors) ? 'img-warn' : 'img-success'; @@ -176,7 +176,7 @@ public static function formatIndex($indexData, $totalTime) $html[] = ''; $html[] = '

    Test results overview

    '; - $html[] = sprintf('We have %s open pull requests...', ''.count($indexData).''); + $html[] = sprintf('There are %s open pull requests...', ''.count($indexData).''); $html[] = ''; @@ -186,7 +186,7 @@ public static function formatIndex($indexData, $totalTime) $row .= ''; - foreach(array_keys($indexData[0]) as $key) + foreach($indexData[0] as $key => $pumuckl)//note to myself: indexData is an object - don't try array_keys.. { $row .= ''; } @@ -274,14 +274,11 @@ public static function formatIndex($indexData, $totalTime) if(file_exists(PATH_OUTPUT.'/index.html')) { + //-- This will calculate the total time I spent on this thingy (approx..) $test = file_get_contents(PATH_OUTPUT.'/index.html'); - preg_match('#([0-9.]+)#', $test, $matches); - - if($matches) - { - $totalTime += $matches[1]; - } + if(preg_match('#([0-9.]+)#', $test, $matches)) + $totalTime += $matches[1]; } $html[] = '
    '.$key.'
    - - - - : - - - - - - - - - - -
    - - - - [{$alt}] - - - - - - - - - -
    - -
    - - - - -
    - - - - - - - - - - -

    - - -

    -
    - - -
    -
    - - - - - - - - diff --git a/platform/docs/xsl/xhtml/annotations.xsl b/platform/docs/xsl/xhtml/annotations.xsl deleted file mode 100644 index 3e137e8..0000000 --- a/platform/docs/xsl/xhtml/annotations.xsl +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Note - - - namesp. cut - - - stripped namespace before processing - - - - - - - - Note - - - namesp. cut - - - processing stripped document - - - - - - - - Unable to strip the namespace from DB5 document, - cannot proceed. - - - - - - - - - ID ' - - ' not found in document. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - diff --git a/platform/docs/xsl/xhtml/ebnf.xsl b/platform/docs/xsl/xhtml/ebnf.xsl deleted file mode 100644 index d228cfb..0000000 --- a/platform/docs/xsl/xhtml/ebnf.xsl +++ /dev/null @@ -1,328 +0,0 @@ - - - - - - - - - - -$Id: ebnf.xsl 8178 2008-12-15 22:26:38Z bobstayton $ - -Walsh -Norman -19992000 -Norman Walsh - - -HTML EBNF Reference - - -
    Introduction - -This is technical reference documentation for the DocBook XSL -Stylesheets; it documents (some of) the parameters, templates, and -other elements of the stylesheets. - -This reference describes the templates and parameters relevant -to formatting EBNF markup. - -This is not intended to be user documentation. -It is provided for developers writing customization layers for the -stylesheets, and for anyone who's interested in how it -works. - -Although I am trying to be thorough, this documentation is known -to be incomplete. Don't forget to read the source, too :-) -
    -
    -
    - - - - - - - - - - - - 1 - - - - - - EBNF - - for - - - - - - - - - - - - -
    - - -
    - - - - - - - - - - EBNF productions - -
    -
    -
    - - - - - - - - - - [ - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - - - - - - - - Error: no ID for productionrecap linkend: - - . - - - - - - Warning: multiple "IDs" for productionrecap linkend: - - . - - - - - - - - - - - - - - - - | -
    -
    -
    - - - - - - - - - - - - - - - production - - - - - - - - - Non-terminals with no content must point to - production elements in the current document. - - - Invalid xpointer for empty nt: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ??? - - - - - - - - - - - - - /*  - -  */ -
    -
    - - - - - - - - - constraintdef - - - - - - - - - - - - - - - - : - - - - - - - : - - - - - - - - - -  ] - -
    -
    -
    - - -
    - - - -
    -
    - - -

    -
    - - - -
    diff --git a/platform/docs/xsl/xhtml/footnote.xsl b/platform/docs/xsl/xhtml/footnote.xsl deleted file mode 100644 index 6d81fa9..0000000 --- a/platform/docs/xsl/xhtml/footnote.xsl +++ /dev/null @@ -1,305 +0,0 @@ - - - - - - - - - - - - - #ftn. - - - - - - - [ - - - - - ] - - - - - [ - - - - - ] - - - - - - - - - - - -ERROR: A footnoteref element has a linkend that points to an element that is not a footnote. -Typically this happens when an id attribute is accidentally applied to the child of a footnote element. -target element: -linkend/id: - - - - - - - - - - - - #ftn. - - - - - [ - - - - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ftn. - - - - - - # - - - - - - - - - - - - - - [ - - - - - ] - - - - - - - - - - - - ftn. - - - - - - # - - - - - - - [ - - - - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - -
    -
    - - -
    -
    -

    The following annotations are from this essay. You are seeing - them here because your browser doesn’t support the user-interface - techniques used to make them appear as ‘popups’ on modern browsers.

    -
    - - -
    -
    -
    - - - - - - - - -
    - - -
    -
    - - -
    - - - -
    -
    - - - - Warning: footnote number may not be generated - correctly; - - unexpected as first child of footnote. - -
    - - -
    -
    -
    -
    - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/formal.xsl b/platform/docs/xsl/xhtml/formal.xsl deleted file mode 100644 index 57c98f3..0000000 --- a/platform/docs/xsl/xhtml/formal.xsl +++ /dev/null @@ -1,411 +0,0 @@ - - - - - - - -1 - - - - - - - - - - -
    - - - - - - - -
    - -
    - - - - - -

    - - -

    -

    - - - - - - - -
    -
    - -
    -
    -
    - - - - - - - - - -float - - - - - - - - - -
    - - - - - - - - - - - - - -
    - -
    -
    - -

    - - - -

    -
    -
    -
    - - - - - -
    -

    - - - - - - - - -

    -

    -
    - - - - - - - - - -float - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - before - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Broken table: tr descendent of CALS Table. - - - - - - - - - - before - - - - - - - - - - - - - - - - - - - - - - - - - Broken table: row descendent of HTML table. - - - - - - - - - - - - - - - - - - - - - - - - before - - - - - - - - - - - - - - - - - - - - - before - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - float: - - ; - - - -
    -
    - -
    diff --git a/platform/docs/xsl/xhtml/glossary.xsl b/platform/docs/xsl/xhtml/glossary.xsl deleted file mode 100644 index d22b6c5..0000000 --- a/platform/docs/xsl/xhtml/glossary.xsl +++ /dev/null @@ -1,564 +0,0 @@ - - - - - - - - - - - - - - - - - - normalize.sort.input - - - - - - normalize.sort.output - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    - - - -
    - - - - -
    -
    - - - - - - - - - - - - - - - - - - normalize.sort.input - - - - - - normalize.sort.output - - - -
    - - - - - -
    - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - normalize.sort.input - - - - - - normalize.sort.output - - - - - -
    - - - -
    - - - - - - - - - - -
    -
    -
    - - -

    - - -

    -
    - - - - - - - - -
    - - - - 0 - 1 - - - - - - - - ( - - ) - - - - - -
    -
    - -
    - - - - 0 - 1 - - - - - - - - ( - - ) - -
    -
    - -
    - - - - 0 - 1 - - - - - -
    -
    -
    - - -
    - - - - , - - - - - , - - - - - , - - - - - - - - - - - -
    -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Warning: glosssee @otherterm reference not found: - - - - - - - - - - - - - - -

    -
    -
    - - -
    - - -

    - - - - - - - - - - - - - -

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Warning: glossseealso @otherterm reference not found: - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - normalize.sort.input - - - - - - normalize.sort.output - - - - - - - - - - - Warning: processing automatic glossary - without a glossary.collection file. - - - - - - Warning: processing automatic glossary but unable to - open glossary.collection file ' - - ' - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - -
    -
    - - - - - - - - - - - - - - - - - normalize.sort.input - - - - - - normalize.sort.output - - - - -
    - - - -
    - - - - ! - - - - - - - - - - - - - - - -
    -
    -
    - - - -
    diff --git a/platform/docs/xsl/xhtml/graphics.xsl b/platform/docs/xsl/xhtml/graphics.xsl deleted file mode 100644 index d1c04fb..0000000 --- a/platform/docs/xsl/xhtml/graphics.xsl +++ /dev/null @@ -1,1436 +0,0 @@ - - - - - - - - - - - - - - - - 1 - - - - - - 1 - - - - - -
    - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 0 - - 1 - 0 - - - - - - 1.0 - 1.0 - - - - 1.0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - px - - - - - - - - - - - px - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - px - - - - - - - - - - - px - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - middle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Warning: imagemaps not supported - on scaled images - - - - 0 - - - - - - - - - - - - - - - - - - - - middle - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - height: - - px - - - - - - - - - - - -
    - - - - - background-color: - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - calspair - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - , - - , - - - - - - - - - - - - Warning: only calspair or - otherunits='imagemap' supported - in imageobjectco - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - middle - - - - - - - - - - - - - - - - - -
    - - - - - - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No insertfile extension available. - - - - - - - Cannot insert - . Check use.extensions and textinsert.extension parameters. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No insertfile extension available. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No insertfile extension available. - - - - - - - Cannot insert - . Check use.extensions and textinsert.extension parameters. - - - - - - - - -
    - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/highlight.xsl b/platform/docs/xsl/xhtml/highlight.xsl deleted file mode 100644 index 222a055..0000000 --- a/platform/docs/xsl/xhtml/highlight.xsl +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/html-rtf.xsl b/platform/docs/xsl/xhtml/html-rtf.xsl deleted file mode 100644 index e079a73..0000000 --- a/platform/docs/xsl/xhtml/html-rtf.xsl +++ /dev/null @@ -1,321 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    - - - - - - - - - - -
    -
    -
    -
    - - - - - - - - - - - - - - -
    - -
    - - - - - - - - - - -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/html.xsl b/platform/docs/xsl/xhtml/html.xsl deleted file mode 100644 index 154a645..0000000 --- a/platform/docs/xsl/xhtml/html.xsl +++ /dev/null @@ -1,598 +0,0 @@ - - - - - - - - - - - - left - right - left - - - - - - right - left - right - - - - - - ltr - rtl - ltr - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - # - - - - - - - - - # - - - - - - - - - - - - - - - - - - - bullet - - - - - - - - - bullet - - - © - - - ® - (SM) -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ID recommended on - - - : - - - - ... - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: no root element for CSS source file' - - '. - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: missing CSS input filename. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/htmltbl.xsl b/platform/docs/xsl/xhtml/htmltbl.xsl deleted file mode 100644 index 47c9a98..0000000 --- a/platform/docs/xsl/xhtml/htmltbl.xsl +++ /dev/null @@ -1,102 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - float: - - left - right - - - - - - - - - - - - - none - none - - ; - - - - diff --git a/platform/docs/xsl/xhtml/index.xsl b/platform/docs/xsl/xhtml/index.xsl deleted file mode 100644 index 2c39f4f..0000000 --- a/platform/docs/xsl/xhtml/index.xsl +++ /dev/null @@ -1,264 +0,0 @@ - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    -
    -
    - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - -
    - - - - - - - - - -
    - -
    -
    -
    - - -

    - - -

    -
    - - - - - - - - - -
    -
    - - - - - - - - - - - -
    - -
    -
    - - - -
    -
    - - - - - - - - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    -
    -
    - - -
    - ( - - - - - - ) -
    -
    - - -
    - ( - - - - - - ) -
    -
    - - diff --git a/platform/docs/xsl/xhtml/info.xsl b/platform/docs/xsl/xhtml/info.xsl deleted file mode 100644 index 76285ab..0000000 --- a/platform/docs/xsl/xhtml/info.xsl +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/inline.xsl b/platform/docs/xsl/xhtml/inline.xsl deleted file mode 100644 index da72226..0000000 --- a/platform/docs/xsl/xhtml/inline.xsl +++ /dev/null @@ -1,1451 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - _blank - _top - - - - - - - - - - - - - - 1 - 0 - - - - - - - - - 1 - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - XLink to nonexistent id: - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - span - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ( - - ) - - - - - - - - - - - , - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - abbr - - - - - - acronym - - - - - - - - - - - - - - - - - - - - - - - - - - http://example.com/cgi-bin/man.cgi? - - ( - - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - SM - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Warning: glossary.collection specified, but there are - - automatic glossaries - - - - - - - - - - - - - - - - - - - - - - - - There's no entry for - - in - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Error: no glossentry for glossterm: - - . - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - element - - - - - - - - - - - - - - - - </ - - > - - - & - - ; - - - &# - - ; - - - % - - ; - - - <? - - > - - - <? - - ?> - - - < - - > - - - < - - /> - - - <!-- - - --> - - - - - - - - - - - - - - - - - - - - - - < - - - - - mailto: - - - - - - > - - - - - - - - - - - + - - - - - - - - + - - - - - - - - - - - - - - - - - - - ( - - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ - - - - - - - - - - - - - - - - - - - ] - - - [ - - ] - - - - - - - - - - - - - [ - - - - - - - - - - - - ] - - - [ - - ] - - - - - - - - - - - - -

    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/keywords.xsl b/platform/docs/xsl/xhtml/keywords.xsl deleted file mode 100644 index 5f6b4fb..0000000 --- a/platform/docs/xsl/xhtml/keywords.xsl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - , - - - - - diff --git a/platform/docs/xsl/xhtml/lists.xsl b/platform/docs/xsl/xhtml/lists.xsl deleted file mode 100644 index 58916e5..0000000 --- a/platform/docs/xsl/xhtml/lists.xsl +++ /dev/null @@ -1,1121 +0,0 @@ - - - - - - - - - - -
    - - - - - - - - - -
      - - - - - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - circle - disc - square - - - - - - -
  • - - - - list-style-type: - - - - - - - - - - - -
    - -
    -
    - - - -
    -
  • -
    - - - - - - - - - - - - - 1 - a - i - A - I - - - - Unexpected numeration: - - - - - - - -
    - - - - - - - - - - - - - - - - - - -
    -
    - -
      - - - - - - - - - - - - - - - - - -
    -
    -
    -
    -
    - - - - - - -
  • - - - - - - - - - - - - - - -
    - -
    -
    - - - -
    -
  • -
    - - - - - - - - - - - - - -
    - -
    -
    - - - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - -
    - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - -

    - - - - - - - - - - - - - -

    -
    -
    -
    - - -
    - - -
    -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - -

    - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - - - - - -
    - - - - - - - - - - - - - - - - - - -
    -
    -
    -
    -
    -
    - - - - - - - - - -
    - -
    -
    - - - -
    -
    - - - - - - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - - - 1 - - - -
    -
    - - - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 1 - - 1 - - - - - - - - -   - - - - - - - - - - - - - - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - 1 - 1 - - 1 - - - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - before - - - - - - - - - -
    - - - - - 0 - 1 - - - - - - - - - - - - -
      - - -
    -
    - -
      - - - - - -
    -
    -
    - - - - -
    -
    - - - - - - - - - - - - -
      - - -
    -
    - - -
  • - - - -
  • -
    - - - -
      - - -
    -
    - - -

    - - - - -

    -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - - -
    -
    - - -
    - - - - - - - -
    -
    - - - - - - - - - -
    - - - -
    -
    - - - - - - - - -
    - - - - - : - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    -
    - -
    - -
    -
    -
    -
    -
    - - - - - - - - - - - - - - - -

    - - - - -

    - - - - - -
    - -
    - - - - -
    -
    -
    -
    -
    - - - - - - - - - -

    - - - - - - - - - - - - - - - -

    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ??? - - - - - # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ??? - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/maketoc.xsl b/platform/docs/xsl/xhtml/maketoc.xsl deleted file mode 100644 index 0ae8055..0000000 --- a/platform/docs/xsl/xhtml/maketoc.xsl +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - filename=" - - " - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/manifest.xsl b/platform/docs/xsl/xhtml/manifest.xsl deleted file mode 100644 index 26b51d0..0000000 --- a/platform/docs/xsl/xhtml/manifest.xsl +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/math.xsl b/platform/docs/xsl/xhtml/math.xsl deleted file mode 100644 index b2cac2d..0000000 --- a/platform/docs/xsl/xhtml/math.xsl +++ /dev/null @@ -1,284 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unsupported TeX math notation: - - - - - - - - - - - - - \nopagenumbers - - - - - \bye - - - - - - - - - - - - - - - - - - - - - - - - \special{dvi2bitmap outputfile - - } - - - $ - - - - $ - - - \vfill\eject - - - - - - - - - - - - - - - - - - - - - - - - - \special{dvi2bitmap outputfile - - } - - - $$ - - - - $$ - - - \vfill\eject - - - - - - - - - - \documentclass{article} - - \pagestyle{empty} - - \begin{document} - - - - - \end{document} - - - - - - - - - - - - - - - - - - - - - - - - \special{dvi2bitmap outputfile - - } - - - $ - - - - $ - - - \newpage - - - - - - - - - - - - - - - - - - - - - - - - - \special{dvi2bitmap outputfile - - } - - - $$ - - - - $$ - - - \newpage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 1 - - - - - - diff --git a/platform/docs/xsl/xhtml/oldchunker.xsl b/platform/docs/xsl/xhtml/oldchunker.xsl deleted file mode 100644 index e727bf1..0000000 --- a/platform/docs/xsl/xhtml/oldchunker.xsl +++ /dev/null @@ -1,176 +0,0 @@ - - - - - - - - - - - - - - - - -Encoding used in generated HTML pages - -This encoding is used in files generated by chunking stylesheet. Currently -only Saxon is able to change output encoding. - - - - - - - - - -Saxon character representation used in generated HTML pages - -This character representation is used in files generated by chunking stylesheet. If -you want to suppress entity references for characters with direct representation -in default.encoding, set this parameter to value native. - - - - - - - - - - - - - - - - - - - - - - - - Chunking isn't supported with - - - - - - - - - - - - - - - Writing - - - for - - - ( - - ) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Can't make chunks with - - 's processor. - - - - - - - - - - - - - - - - Writing - - - for - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Can't make chunks with - - 's processor. - - - - - - diff --git a/platform/docs/xsl/xhtml/onechunk.xsl b/platform/docs/xsl/xhtml/onechunk.xsl deleted file mode 100644 index 15a04e1..0000000 --- a/platform/docs/xsl/xhtml/onechunk.xsl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - -1 - - - - # - - - - - - diff --git a/platform/docs/xsl/xhtml/param.xsl b/platform/docs/xsl/xhtml/param.xsl deleted file mode 100644 index bebab47..0000000 --- a/platform/docs/xsl/xhtml/param.xsl +++ /dev/null @@ -1,436 +0,0 @@ - - - - - - - - - -.png - -images/ - - - - - - -/* ====================================================================== - Annotations -*/ - -div.annotation-list { visibility: hidden; - } - -div.annotation-nocss { position: absolute; - visibility: hidden; - } - -div.annotation-popup { position: absolute; - z-index: 4; - visibility: hidden; - padding: 0px; - margin: 2px; - border-style: solid; - border-width: 1px; - width: 200px; - background-color: white; - } - -div.annotation-title { padding: 1px; - font-weight: bold; - border-bottom-style: solid; - border-bottom-width: 1px; - color: white; - background-color: black; - } - -div.annotation-body { padding: 2px; - } - -div.annotation-body p { margin-top: 0px; - padding-top: 0px; - } - -div.annotation-close { position: absolute; - top: 2px; - right: 2px; - } - - -http://docbook.sourceforge.net/release/images/annot-close.png -http://docbook.sourceforge.net/release/images/annot-open.png - - -http://docbook.sourceforge.net/release/script/AnchorPosition.js http://docbook.sourceforge.net/release/script/PopupWindow.js - - -A - - -. - -. -http://docbook.sourceforge.net/release/bibliography/bibliography.xml - - -normal - - -60 -.png - - -15 - -images/callouts/ - - -10 -10102 - - - - - - - - - - - -no - -1 - - - - - - left - before - - - -all - - -docbook.css.xml -no -images/draft.png - -::= - - - - -#F5DCB3 - - -com.example.help -DocBook Online Help Sample -Example provider -1 - - - - - - 1 - 0 - - - - -1 - - - -figure before -example before -equation before -table before -procedure before -task before - - -kr - - - - - - - - - - -appendix toc,title -article/appendix nop -article toc,title -book toc,title,figure,table,example,equation -chapter toc,title -part toc,title -preface toc,title -qandadiv toc -qandaset toc -reference toc,title -sect1 toc -sect2 toc -sect3 toc -sect4 toc -sect5 toc -section toc -set toc,title - - - - -no - - - - - - - - - - - - - -.html - - -copyright - - - -text/css -alias.h - - - - - - - -User1 - - -User2 - - - - - - - - - -htmlhelp.chm - - -iso-8859-1 - - - - - -toc.hhc -5 - - -index.hhk -htmlhelp.hhp - -Main - -context.h - - - - - - - - - - - - - -basic - - - - - - - -no - -no -iso-8859-1 - - -en - - - - -5 - - -3 - - - - - - - HTML.manifest - - - - -+ -.gif - -images/ -1 - - -6in - - -no -fragid= - -.olink - - replace - -pubid - /cgi-bin/olink -sysid -0 - -I - -90 -10 - - - - - - - - - - - - - - - - -; - - - - - -. -number - - - - - - - - - - I -index - -. -.!?: - -8 - - - - - 0 - #E0E0E0 - - - - - - -0 - - - - - -solid -0.5pt -a - - - -solid -0.5pt - - olinkdb.xml -target.db - -tex-math-equations.tex - - - -dl -8 -2 -_top - - - - - - - - -0 -, - - - writing-mode - - - - - - - - -: - - - - diff --git a/platform/docs/xsl/xhtml/pi.xsl b/platform/docs/xsl/xhtml/pi.xsl deleted file mode 100644 index 28f9efe..0000000 --- a/platform/docs/xsl/xhtml/pi.xsl +++ /dev/null @@ -1,1203 +0,0 @@ - - - - - - - -HTML Processing Instruction Reference - - $Id: pi.xsl 8394 2009-04-02 20:31:30Z mzjn $ - - - - Introduction - This is generated reference documentation for all - user-specifiable processing instructions (PIs) in the DocBook - XSL stylesheets for HTML output. - - You add these PIs at particular points in a document to - cause specific “exceptions” to formatting/output behavior. To - make global changes in formatting/output behavior across an - entire document, it’s better to do it by setting an - appropriate stylesheet parameter (if there is one). - - - - - - - - - Sets background color for an image - - Use the dbhtml background-color PI before or - after an image (graphic, inlinegraphic, - imagedata, or videodata element) as a - sibling to the element, to set a background color for the - image. - - - dbhtml background-color="color" - - - - background-color="color" - - An HTML color value - - - - - - Background color - - - - - - - - - - - - Sets background color on a CALS table row or table cell - - Use the dbhtml bgcolor PI as child of a CALS table row - or cell to set a background color for that table row or cell. - - - dbhtml bgcolor="color" - - - - bgcolor="color" - - An HTML color value - - - - - - Cell background color - - - - - - - - - - - - Specifies cellpadding in CALS table or qandaset output - - Use the dbhtml cellpadding PI as a child of a - CALS table or qandaset to specify the value - for the HTML cellpadding attribute in the - output HTML table. - - - dbhtml cellpadding="number" - - - - cellpadding="number" - - Specifies the cellpadding - - - - - - html.cellpadding - - - Cell spacing and cell padding, - Q and A formatting - - - - - - - - - - - - Specifies cellspacing in CALS table or qandaset output - - Use the dbhtml cellspacing PI as a child of a - CALS table or qandaset to specify the value - for the HTML cellspacing attribute in the - output HTML table. - - - dbhtml cellspacing="number" - - - - cellspacing="number" - - Specifies the cellspacing - - - - - - html.cellspacing - - - Cell spacing and cell padding, - Q and A formatting - - - - - - - - - - - - Set value of the class attribute for a CALS table row - - Use the dbhtml class PI as a child of a - row to specify a class - attribute and value in the HTML output for that row. - - - dbhtml class="name" - - - - class="name" - - Specifies the class name - - - - - - Table styles in HTML output - - - - - - - - - - - - Specifies a directory name in which to write files - - When chunking output, use the dbhtml dir PI - as a child of a chunk source to cause the output of that - chunk to be written to the specified directory; also, use it - as a child of a mediaobject to specify a - directory into which any long-description files for that - mediaobject will be written. - - - dbhtml dir="path" - - - - dir="path" - - Specifies the pathname for the directory - - - - - - base.dir - - - dbhtml dir processing instruction - - - - - - - - - - - - Specifies a filename for a chunk - - When chunking output, use the dbhtml filename - PI as a child of a chunk source to specify a filename for - the output file for that chunk. - - - dbhtml filename="filename" - - - - filename="path" - - Specifies the filename for the file - - - - - - use.id.as.filename - - - dbhtml filenames - - - - - - - - - - - - Specifies presentation style for a funcsynopsis - - Use the dbhtml funcsynopsis-style PI as a child of - a funcsynopsis or anywhere within a funcsynopsis - to control the presentation style for output of all - funcprototype instances within that funcsynopsis. - - - dbhtml funcsynopsis-style="kr"|"ansi" - - - - funcsynopsis-style="kr" - - Displays funcprototype output in K&R style - - - funcsynopsis-style="ansi" - - Displays funcprototype output in ANSI style - - - - - - funcsynopsis.style - - - - - - - - - - - - Specifies a path to the location of an image file - - Use the dbhtml img.src.path PI before or - after an image (graphic, - inlinegraphic, imagedata, or - videodata element) as a sibling to the element, - to specify a path to the location of the image; in HTML - output, the value specified for the - img.src.path attribute is prepended to the - filename. - - - dbhtml img.src.path="path" - - - - img.src.path="path" - - Specifies the pathname to prepend to the name of the image file - - - - - - img.src.path - - - Using fileref - - - - - - - - - - - - Specifies the label width for a qandaset - - Use the dbhtml label-width PI as a child of a - qandaset to specify the width of labels. - - - dbhtml label-width="width" - - - - label-width="width" - - Specifies the label width (including units) - - - - - - Q and A formatting - - - - - - - - - - - - Specifies interval for line numbers in verbatims - - Use the dbhtml linenumbering.everyNth PI as a child - of a “verbatim” element – programlisting, - screen, synopsis — to specify - the interval at which lines are numbered. - - - dbhtml linenumbering.everyNth="N" - - - - linenumbering.everyNth="N" - - Specifies numbering interval; a number is output - before every Nth line - - - - - - linenumbering.everyNth - - - Line numbering - - - - - - - - - - - - Specifies separator text for line numbers in verbatims - - Use the dbhtml linenumbering.separator PI as a child - of a “verbatim” element – programlisting, - screen, synopsis — to specify - the separator text output between the line numbers and content. - - - dbhtml linenumbering.separator="text" - - - - linenumbering.separator="text" - - Specifies the text (zero or more characters) - - - - - - linenumbering.separator - - - Line numbering - - - - - - - - - - - - Specifies width for line numbers in verbatims - - Use the dbhtml linenumbering.width PI as a child - of a “verbatim” element – programlisting, - screen, synopsis — to specify - the width set aside for line numbers. - - - dbhtml linenumbering.width="width" - - - - linenumbering.width="width" - - Specifies the width (inluding units) - - - - - - linenumbering.width - - - Line numbering - - - - - - - - - - - - Specifies presentation style for a variablelist or - segmentedlist - - Use the dbhtml list-presentation PI as a child of - a variablelist or segmentedlist to - control the presentation style for the list (to cause it, for - example, to be displayed as a table). - - - dbhtml list-presentation="list"|"table" - - - - list-presentation="list" - - Displays the list as a list - - - list-presentation="table" - - Displays the list as a table - - - - - - - - variablelist.as.table - - - segmentedlist.as.table - - - - - Variable list formatting in HTML - - - - - - - - - - - - Specifies the width of a variablelist or simplelist - - Use the dbhtml list-width PI as a child of a - variablelist or a simplelist presented - as a table, to specify the output width. - - - dbhtml list-width="width" - - - - list-width="width" - - Specifies the output width (including units) - - - - - - Variable list formatting in HTML - - - - - - - - - - - - Specifies the height for a CALS table row - - Use the dbhtml row-height PI as a child of a - row to specify the height of the row. - - - dbhtml row-height="height" - - - - row-height="height" - - Specifies the row height (including units) - - - - - - Row height - - - - - - - - - - - - (obsolete) Sets the starting number on an ordered list - - This PI is obsolete. The intent of - this PI was to provide a means for setting a specific starting - number for an ordered list. Instead of this PI, set a value - for the override attribute on the first - listitem in the list; that will have the same - effect as what this PI was intended for. - - - dbhtml start="character" - - - - start="character" - - Specifies the character to use as the starting - number; use 0-9, a-z, A-Z, or lowercase or uppercase - Roman numerals - - - - - - List starting number - - - - - - - - - - - - Do not chunk any descendants of this element. - - When generating chunked HTML output, adding this PI as the child of an element that contains elements that would normally be generated on separate pages if generating chunked output causes chunking to stop at this point. No descendants of the current element will be split into new HTML pages: -<section> -<title>Configuring pencil</title> -<?dbhtml stop-chunking?> - -... - -</section> - - - - dbhtml stop-chunking - - - Chunking into multiple HTML files - - - - - - Specifies summary for CALS table, variablelist, segmentedlist, or qandaset output - - Use the dbhtml table-summary PI as a child of - a CALS table, variablelist, - segmentedlist, or qandaset to specify - the text for the HTML summary attribute - in the output HTML table. - - - dbhtml table-summary="text" - - - - table-summary="text" - - Specifies the summary text (zero or more characters) - - - - - - Variable list formatting in HTML, - Table summary text - - - - - - - - - - - - Specifies the width for a CALS table - - Use the dbhtml table-width PI as a child of a - CALS table to specify the width of the table in - output. - - - dbhtml table-width="width" - - - - table-width="width" - - Specifies the table width (including units or as a percentage) - - - - - - default.table.width - - - Table width - - - - - - - - - - - - Sets character formatting for terms in a variablelist - - Use the dbhtml term-presentation PI as a child - of a variablelist to set character formatting for - the term output of the list. - - - dbhtml term-presentation="bold"|"italic"|"bold-italic" - - - - term-presentation="bold" - - Specifies that terms are displayed in bold - - - term-presentation="italic" - - Specifies that terms are displayed in italic - - - term-presentation="bold-italic" - - Specifies that terms are displayed in bold-italic - - - - - - Variable list formatting in HTML - - - - - - - - - - - - Specifies separator text among terms in a varlistentry - - Use the dbhtml term-separator PI as a child - of a variablelist to specify the separator text - among term instances. - - - dbhtml term-separator="text" - - - - term-separator="text" - - Specifies the text (zero or more characters) - - - - - - variablelist.term.separator - - - Variable list formatting in HTML - - - - - - - - - - - - Specifies the term width for a variablelist - - Use the dbhtml term-width PI as a child of a - variablelist to specify the width for - term output. - - - dbhtml term-width="width" - - - - term-width="width" - - Specifies the term width (including units) - - - - - - Variable list formatting in HTML - - - - - - - - - - - - Specifies whether a TOC should be generated for a qandaset - - Use the dbhtml toc PI as a child of a - qandaset to specify whether a table of contents - (TOC) is generated for the qandaset. - - - dbhtml toc="0"|"1" - - - - toc="0" - - If zero, no TOC is generated - - - toc="1" - - If 1 (or any non-zero value), - a TOC is generated - - - - - - Q and A list of questions, - Q and A formatting - - - - - - - - - - - - Generates a hyperlinked list of commands - - Use the dbcmdlist PI as the child of any - element (for example, refsynopsisdiv) containing multiple - cmdsynopsis instances; a hyperlinked navigational - “command list” will be generated at the top of output for that - element, enabling users to quickly jump - to each command synopsis. - - - dbcmdlist - - - [No parameters] - - - - - - No cmdsynopsis elements matched dbcmdlist PI, perhaps it's nested too deep? - - -
    - - - -
    -
    - - - Generates a hyperlinked list of functions - - Use the dbfunclist PI as the child of any - element (for example, refsynopsisdiv) containing multiple - funcsynopsis instances; a hyperlinked - navigational “function list” will be generated at the top of - output for that element, enabling users to quickly - jump to to each function synopsis. - - - dbfunclist - - - [No parameters] - - - - - - No funcsynopsis elements matched dbfunclist PI, perhaps it's nested too deep? - - -
    - - - -
    -
    - - - Copies an external well-formed HTML/XML file into current doc - - Use the dbhtml-include href PI anywhere in a - document to cause the contents of the file referenced by the - href pseudo-attribute to be copied/inserted “as - is” into your HTML output at the point in document order - where the PI occurs in the source. - - The referenced file may contain plain text (as long as - it is “wrapped” in an html element — see the - note below) or markup in any arbitrary vocabulary, - including HTML — but it must conform to XML - well-formedness constraints (because the feature in XSLT - 1.0 for opening external files, the - document() function, can only handle - files that meet XML well-formedness constraints). - Among other things, XML well-formedness constraints - require a document to have a single root - element. So if the content you want to - include is plain text or is markup that does - not have a single root element, - wrap the content in an - html element. The stylesheets will - strip out that surrounding html “wrapper” when - they find it, leaving just the content you want to - insert. - - - - dbhtml-include href="URI" - - - - href="URI" - - Specifies the URI for the file to include; the URI - can be, for example, a remote http: - URI, or a local filesystem file: - URI - - - - - - textinsert.extension - - - Inserting external HTML code, - External code files - - - - - - - href - - - - - - - - - - - - - - - - - - - - ERROR: dbhtml-include processing instruction - href has no content. - - - - - - - ERROR: dbhtml-include processing instruction has - missing or empty href value. - - - - - - - - Sets topic name and topic id for context-sensitive HTML Help - - Use the dbhh PI as a child of components - that should be used as targets for context-sensitive help requests. - - - dbhh topicname="name" topicid="id" - - - - topicname="name" - - Specifies a unique string constant that identifies a help topic - - - topicid="id" - - Specifies a unique integer value for the topicname string - - - - - - Context-sensitive help - - - - - - - - - - filename - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - # - - - - - - - - - - - - - - - - - - -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - -
    - - - # - - - - - - - - - - - - - - - - - - -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - / - - - - / - - - - -
    diff --git a/platform/docs/xsl/xhtml/profile-chunk-code.xsl b/platform/docs/xsl/xhtml/profile-chunk-code.xsl deleted file mode 100644 index 05c10c6..0000000 --- a/platform/docs/xsl/xhtml/profile-chunk-code.xsl +++ /dev/null @@ -1,617 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - bk - - - - - - - - - - - - - - - ar - - - - - - - - - - - - - - - pr - - - - - - - - - - - - - - - ch - - - - - - - - - - - - - - - ap - - - - - - - - - - - - - - - - - - - pt - - - - - - - - - - - - - - - - - - - rn - - - - - - - - - - - - - - - - - - - - - - - - re - - - - - - - - - - - - - - - - - - - co - - - - - - - - - - - s - - - - - - - - - - - - - - - - - - - bi - - - - - - - - - - - - - - - - - - - go - - - - - - - - - - - - - - - - - - - ix - - - - - - - - si - - - - - - - - chunk-filename-error- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Note: namesp. cut : stripped namespace before processingNote: namesp. cut : processing stripped document - - - - - - - - - - - - - - - - - ID ' - - ' not found in document. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/profile-chunk.xsl b/platform/docs/xsl/xhtml/profile-chunk.xsl deleted file mode 100644 index def7fff..0000000 --- a/platform/docs/xsl/xhtml/profile-chunk.xsl +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/profile-docbook.xsl b/platform/docs/xsl/xhtml/profile-docbook.xsl deleted file mode 100644 index 652fbb7..0000000 --- a/platform/docs/xsl/xhtml/profile-docbook.xsl +++ /dev/null @@ -1,408 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Element - - in namespace ' - - ' encountered - - in - - - , but no template matches. - - - - < - - > - - </ - - > - - - - - - - -rtl - - - - - - - - - - - <xsl:copy-of select="$title"/> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -Note: namesp. cut : stripped namespace before processingNote: namesp. cut : processing stripped document - - - - - - - - - - - - - - - - - - ID ' - - ' not found in document. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - diff --git a/platform/docs/xsl/xhtml/profile-onechunk.xsl b/platform/docs/xsl/xhtml/profile-onechunk.xsl deleted file mode 100644 index b84b3e9..0000000 --- a/platform/docs/xsl/xhtml/profile-onechunk.xsl +++ /dev/null @@ -1,36 +0,0 @@ - - - - - - - - - - - - - - - - - -1 - - - - # - - - - - - diff --git a/platform/docs/xsl/xhtml/qandaset.xsl b/platform/docs/xsl/xhtml/qandaset.xsl deleted file mode 100644 index 4a61c81..0000000 --- a/platform/docs/xsl/xhtml/qandaset.xsl +++ /dev/null @@ -1,420 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - -

    -
    - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - -

    -
    - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - -
    -
    - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - -
    - - - - -
    - - - -
    - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1% - - - - - - - - -
    -
    - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/refentry.xsl b/platform/docs/xsl/xhtml/refentry.xsl deleted file mode 100644 index dc2e57d..0000000 --- a/platform/docs/xsl/xhtml/refentry.xsl +++ /dev/null @@ -1,299 +0,0 @@ - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - -

    -
    - - - - -
    - - - - -
    -
    -
    -
    - - - - - - -
    -
    - - - - - - - - - - - - - - ( - - ) - - - - - - - - - - - -
    - - - - - - - - - - -

    - - - -

    -
    - -

    - - - - - - - - -

    -
    -
    - -

    - -

    -
    -
    - - - - - - , - - - - - - - - - em-dash - - - - - - - - - - - - - - - - : - - - - - - - -
    - - - - -

    - - - - - - - - - - -

    - -
    -
    - - - - - - - - - - - -
    - - - - - - - - - -
    -
    - - - - - - 0 - 1 - - - - 6 - - - - - - - - - - - - -

    - -

    -
    - - - -

    - -

    -
    - - - -

    - -

    -
    - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/sections.xsl b/platform/docs/xsl/xhtml/sections.xsl deleted file mode 100644 index aec647d..0000000 --- a/platform/docs/xsl/xhtml/sections.xsl +++ /dev/null @@ -1,541 +0,0 @@ - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - 1 - 2 - 3 - 4 - 5 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 6 - - - - - - - - - - clear: both - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - 1 - - - - - - - 2 - 3 - 4 - 5 - 6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/synop.xsl b/platform/docs/xsl/xhtml/synop.xsl deleted file mode 100644 index 8506707..0000000 --- a/platform/docs/xsl/xhtml/synop.xsl +++ /dev/null @@ -1,1513 +0,0 @@ - - - - - - - - - - - - - - -
    - -

    - - - - - - - - - - - - -

    -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - - - - ( - - ) - -   - - - - - - - - - - - - - - - - - - - ( - - ) - - - - - - - - - - - - - - - - - - - - - - -
    -    
    -    
    -  
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

    - - -
    - -
    -

    -
    - - - - - - ( - - - - - - - fsfunc - - - - - - - - - ) - ; - - - - ... - ) - ; - - - - - - - , - - - ) - ; - - - - - - - - - - - - - - - - - - - - -
    - - - - ; -
    - - - - - - - - - - - - - - - - - - ( - - ) - - - - - - - - - - - - - - - - - -
    - -
     
    - -
    - -
    -
    -
     
    -
    - - - - - - ( - - - - - - - fsfunc - - - - - - - - - - ) - ; - -   - - - - - ... - ) - ; - -   - - - - - - - - , - - - ) - ; - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - ; - - - - - - - - - - - - - - - - - - - - - - - - ( - - ) - ; - - - - - - -

    - -

    -
    - - - - - - ( - - - - - - - fsfunc - - - - - - - - - void) - ; - - - - ... - ) - ; - - - - - - - , - - - ) - ; - - - - - - - - - - - - - - - - - - - - - ( - - ) - - - - - - - - - - - - - - - - - -
    - -
     
    -
     
    -
    - - - - - - ( - - - - - - - fsfunc - - - - - - - - - - void) - ; - -   - - - - - ... - ) - ; - -   - - - - - - - - , - - - ) - ; - - - - - - - - - - - - - - - - - - - - - - ( - - ) - - - - -java - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unrecognized language on - - : - - - - - - - - - - - -
    -
    -
    - - - - - -
    -    
    -    
    -    
    -       extends
    -      
    -      
    -        
    -      -
    -
    - - implements - - -
    -      -
    -
    - - throws - - -  { -
    - - } -
    -
    - - - - - - - - - , - - - - - - - - - - - - - - - - -   - - - - - - - , - - - - - - - - - - , - - - - - - - - - - , - - - - - - - - - - - -    - - - ; - - - - - - - - -   - - - - - - - -   - - - - - - - - - - - - - - - void  - - - - - - - - - - - - 0 - - , -
    - - -   - - - -
    - - - - -
    - - - - - - - - - - - - - - -    - - - - - - - - - - - - - - - ( - - - - ) - -
    -     throws  - -
    - - - - - ; -
    - -
    - - - - -
    -    
    -    
    -    
    -      : 
    -      
    -      
    -        
    -      -
    -
    - - implements - - -
    -      -
    -
    - - throws - - -  { -
    - - } -
    -
    - - - - - - - - , - - - - - - - - - - - - -   - - - - - - - , - - - - - - - - - - , - - - - - - - - - - , - - - - - - - - - - - -    - - - ; - - - - - - - - -   - - - - - - - -   - - - - - - - - - - - - - - - void  - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - -    - - - - - - - - - - ( - - ) - -
    -     throws  - -
    - - - - - ; -
    - -
    - - - - -
    -    
    -    interface 
    -    
    -    
    -      : 
    -      
    -      
    -        
    -      -
    -
    - - implements - - -
    -      -
    -
    - - throws - - -  { -
    - - } -
    -
    - - - - - - - - , - - - - - - - - - - - - -   - - - - - - - , - - - - - - - - - - , - - - - - - - - - - , - - - - - - - - - - - -    - - - ; - - - - - - - - -   - - - - - - - -   - - - - - - - - - - - - - - - void  - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - -    - - - - - - - - - - ( - - ) - -
    -     raises( - - ) -
    - - - - - ; -
    - -
    - - - - -
    -    
    -    package 
    -    
    -    ;
    -    
    - - - @ISA = ( - - ); -
    -
    - - -
    -
    - - - - - - - - , - - - - - - - - - - - - -   - - - - - - - , - - - - - - - - - - , - - - - - - - - - - , - - - - - - - - - - - -    - - - ; - - - - - - - - -   - - - - - - - -   - - - - - - - - - - - - - - - void  - - - - - - - - - - - - - , - - - - - - - - - - - - - - - - - - - - - - sub - - - { ... }; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/table.xsl b/platform/docs/xsl/xhtml/table.xsl deleted file mode 100644 index 42fe259..0000000 --- a/platform/docs/xsl/xhtml/table.xsl +++ /dev/null @@ -1,1168 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - - - - - - - - - - - - - - border- - - : - - - - - - ; - - - - - border- - - -width: - - ; - - - - border- - - -style: - - ; - - - - border- - - -color: - - ; - - - - - - - - - - - Error: CALS tables must specify the number of columns. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 100% - - - - - - - - border-collapse: collapse; - - - - - - - - - - - - - - - - - - - - - - - - - - - - - border-collapse: collapse; - - - - - - - - - - - - - - - - - border-collapse: collapse; - - - - - - - - - - - border-collapse: collapse; - - - - - - - - - - - border-collapse: collapse; - - - - - - - - - - - - - - - - - border: none; - - - - - border-collapse: collapse; - - - - - - - 0 - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - 100% - - - - - - - - - - - - - - - - - - - - - - - - No convertLength function available. - - - - - - - - - - - - - - - - - - - - - - - - - - No adjustColumnWidths function available. - - - - - - - - - - - - - - - - - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Warning: overlapped row contains content! - - - This row intentionally left blank - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - th - th - - th - - td - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 0 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - : - - - - - - - - 0: - - - - - - - - - - - - - - - 0 - - : - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - 1 - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/task.xsl b/platform/docs/xsl/xhtml/task.xsl deleted file mode 100644 index 0a380d2..0000000 --- a/platform/docs/xsl/xhtml/task.xsl +++ /dev/null @@ -1,73 +0,0 @@ - - - - - - - - - - - - - - - - - - before - - - - - - - - -
    - - - - - - - - - - - - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/titlepage.templates.xsl b/platform/docs/xsl/xhtml/titlepage.templates.xsl deleted file mode 100644 index 1f72e23..0000000 --- a/platform/docs/xsl/xhtml/titlepage.templates.xsl +++ /dev/null @@ -1,3817 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - -
    - - -
    - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - 1 - - - -
    -
    - - - - - - - - - - 1 - - - -
    -
    - -
    -
    - - - - - - - - - - - - - - -
    - - - -
    -
    - - -
    - -
    -
    - -
    diff --git a/platform/docs/xsl/xhtml/titlepage.xsl b/platform/docs/xsl/xhtml/titlepage.xsl deleted file mode 100644 index c3f8217..0000000 --- a/platform/docs/xsl/xhtml/titlepage.xsl +++ /dev/null @@ -1,1030 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - -
    - - - - - - - - - - - -
    -
    - - - - - - - - - - - - - -
    - - - - - - - - -
    -
    - - -
    - - - - - - - - -
    -
    -
    -
    - - -
    - - -
    -
    - - - - - -
    -
    -
    - - - - - - -
    - - -

    -
    -

    - - - - - - - - - -

    - - - - - - - - - - - - - - - -
    -
    - - -
    - - -
    -
    - - -
    - - -

    Authors

    -
    - - - -
    -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - -
    -
    -
    - - - - - - - - - -
    - - -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - -   - - -
    - -

    -
    -
    -
    -
    - - - - -

    Copyright

    -
    - -

    - - - - - - - copyright - - - - - - - - - -

    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - -

    - - -

    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - -

    - - - - - - -

    -
    - - - - - - - - - - -
    -
    -
    - - - - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    - - - -
    -
    -
    - -
    - - - -
    -
    -
    -
    - - -

    -
    - - - - - -
    -
    -
    - - - - - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - : - - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - -
    - - -
    -
    - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - 3 - 2 - - - - - - - - RevHistory - - - - -
    - - - - - - - - -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - , - - - - - -   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    -
    -
    - - - - - -
    -
    -
    - - - - - -

    - - -

    -
    - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - -

    - - - - - - - - - - - - - - -

    -
    - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/docs/xsl/xhtml/toc.xsl b/platform/docs/xsl/xhtml/toc.xsl deleted file mode 100644 index 92b7b14..0000000 --- a/platform/docs/xsl/xhtml/toc.xsl +++ /dev/null @@ -1,330 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    - - -
    - - -
    -
    - -
    - - - - - - - - - -
    -
    -
    - - - - - - - - - - - - - - -
    - - -
    - - -
    -
    - -
    - - - - - - - - - -
    -
    -
    - - - - - - - - -
    - - - - - -
    -
    - - - - - - -
    -
    -
    - - - - - -
    - - -
    - -
    - -
  • - - - -
  • -
    -
    -
    - - - - -
    - - -
    -
    - -
  • - - -
  • -
    -
    -
    - - - - - - - - - - - - - - -
    - - - - - - - - - - - - -
    - - -
    - - -
    -
    - - -
    - - -
    -
    - - - - - - - - - - - - -
    - - -
    -
    - - - -
    -
    - - - - -
    - - - - -
    - - -
    - -
    - - - -
    -
    - - - - -
    - - -
    - -
    - - - -
    -
    - - - - - Warning: don't know what to generate for - lot that has no children. - - - - -
    - - -
    -
    - - -
    - - -
    -
    - - - - - diff --git a/platform/docs/xsl/xhtml/verbatim.xsl b/platform/docs/xsl/xhtml/verbatim.xsl deleted file mode 100644 index c0bc69d..0000000 --- a/platform/docs/xsl/xhtml/verbatim.xsl +++ /dev/null @@ -1,388 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - div - pre - - - - - - The shade.verbatim parameter is deprecated. - Use CSS instead, - - - for example: pre. - - { background-color: #E0E0E0; } - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - The shade.verbatim parameter is deprecated. - Use CSS instead, - - - for example: pre. - - { background-color: #E0E0E0; } - - - - - - - -
    -            
    -            
    -              
    -            
    -          
    -
    - -
    - -

    - - - -

    -
    -
    -
    -
    - - - -
    -            
    -            
    -          
    -
    - -
    - -

    - - - -

    -
    -
    -
    -
    -
    -
    - - - - - - - - - - -
    - -

    - - - -

    -
    -
    - - -
    - -

    - - - -

    -
    -
    -
    -
    - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Unexpected verbatim environment: - - - - - - - - - - 1 - - - - - - - - - - - - - No numberLines function available. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    diff --git a/platform/docs/xsl/xhtml/xref.xsl b/platform/docs/xsl/xhtml/xref.xsl deleted file mode 100644 index 74c6f20..0000000 --- a/platform/docs/xsl/xhtml/xref.xsl +++ /dev/null @@ -1,1316 +0,0 @@ - - - - - - - - -http://docbook.org/xlink/role/olink - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Endterm points to nonexistent ID: - - - ??? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ERROR: xref linking to - - has no generated link text. - - ??? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - XRef to nonexistent id: - - - ??? - - - - - - - - - - - - - - - - Endterm points to nonexistent ID: - - - - - ??? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - suppress anchor - - - - - - - - - - - removing - - - - - - - - - - - - - - - - - removing - - - - - - - - - - - - - - - - - - - - - - Don't know what gentext to create for xref to: " - - ", (" - - ") - - - ??? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ - - - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - No bibliography entry: - - found in - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - [ - - - - - - - - - ] - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Endterm points to nonexistent ID: - - - ??? - - - - - - - - - - - - - Link element has no content and no Endterm. - Nothing to show in the link to - - - ??? - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Olink debug: root element of target.database ' - - ' is ' - - '. - - - - - - - - - - - - - - - Error: unresolved olink: - targetdoc/targetptr = ' - - / - - '. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Warning: olink linkmode pointer is wrong. - - - - # - - - - - - - - - - - - - ? - - - - - & - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/platform/libraries/config.example.php b/platform/libraries/config.example.php deleted file mode 100644 index 7cc4f38..0000000 --- a/platform/libraries/config.example.php +++ /dev/null @@ -1,36 +0,0 @@ - diff --git a/platform/libraries/joomla/access/access.php b/platform/libraries/joomla/access/access.php deleted file mode 100644 index 5d79072..0000000 --- a/platform/libraries/joomla/access/access.php +++ /dev/null @@ -1,427 +0,0 @@ -allow($action, $identities); - } - - /** - * Method to check if a group is authorised to perform an action, optionally on an asset. - * - * @param integer $groupId The path to the group for which to check authorisation. - * @param string $action The name of the action to authorise. - * @param mixed $asset Integer asset id or the name of the asset as a string. Defaults to the global asset node. - * - * @return boolean True if authorised. - * - * @since 11.1 - */ - public static function checkGroup($groupId, $action, $asset = null) - { - // Sanitize inputs. - $groupId = (int) $groupId; - $action = strtolower(preg_replace('#[\s\-]+#', '.', trim($action))); - $asset = strtolower(preg_replace('#[\s\-]+#', '.', trim($asset))); - - // Get group path for group - $groupPath = self::getGroupPath($groupId); - - // Default to the root asset node. - if (empty($asset)) - { - $asset = 1; - } - - // Get the rules for the asset recursively to root if not already retrieved. - if (empty(self::$assetRules[$asset])) - { - self::$assetRules[$asset] = self::getAssetRules($asset, true); - } - - return self::$assetRules[$asset]->allow($action, $groupPath); - } - - /** - * Gets the parent groups that a leaf group belongs to in its branch back to the root of the tree - * (including the leaf group id). - * - * @param mixed $groupId An integer or array of integers representing the identities to check. - * - * @return mixed True if allowed, false for an explicit deny, null for an implicit deny. - * - * @since 11.1 - */ - protected static function getGroupPath($groupId) - { - static $groups, $paths; - - // Preload all groups - if (empty($groups)) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true) - ->select('parent.id, parent.lft, parent.rgt') - ->from('#__usergroups AS parent') - ->order('parent.lft'); - $db->setQuery($query); - $groups = $db->loadObjectList('id'); - } - - // Make sure groupId is valid - if (!array_key_exists($groupId, $groups)) - { - return array(); - } - - // Get parent groups and leaf group - if (!isset($paths[$groupId])) - { - $paths[$groupId] = array(); - - foreach ($groups as $group) - { - if ($group->lft <= $groups[$groupId]->lft && $group->rgt >= $groups[$groupId]->rgt) - { - $paths[$groupId][] = $group->id; - } - } - } - - return $paths[$groupId]; - } - - /** - * Method to return the JRules object for an asset. The returned object can optionally hold - * only the rules explicitly set for the asset or the summation of all inherited rules from - * parent assets and explicit rules. - * - * @param mixed $asset Integer asset id or the name of the asset as a string. - * @param boolean $recursive True to return the rules object with inherited rules. - * - * @return JRules JRules object for the asset. - * - * @since 11.1 - */ - public static function getAssetRules($asset, $recursive = false) - { - // Get the database connection object. - $db = JFactory::getDbo(); - - // Build the database query to get the rules for the asset. - $query = $db->getQuery(true); - $query->select($recursive ? 'b.rules' : 'a.rules'); - $query->from('#__assets AS a'); - - // If the asset identifier is numeric assume it is a primary key, else lookup by name. - if (is_numeric($asset)) - { - $query->where('a.id = ' . (int) $asset); - } - else - { - $query->where('a.name = ' . $db->quote($asset)); - } - - // If we want the rules cascading up to the global asset node we need a self-join. - if ($recursive) - { - $query->leftJoin('#__assets AS b ON b.lft <= a.lft AND b.rgt >= a.rgt'); - $query->order('b.lft'); - } - - // Execute the query and load the rules from the result. - $db->setQuery($query); - $result = $db->loadColumn(); - - // Get the root even if the asset is not found and in recursive mode - if ($recursive && empty($result)) - { - $query = $db->getQuery(true); - $query->select('rules'); - $query->from('#__assets'); - $query->where('parent_id = 0'); - $db->setQuery($query); - $result = $db->loadColumn(); - } - - // Instantiate and return the JRules object for the asset rules. - $rules = new JRules; - $rules->mergeCollection($result); - - return $rules; - } - - /** - * Method to return a list of user groups mapped to a user. The returned list can optionally hold - * only the groups explicitly mapped to the user or all groups both explicitly mapped and inherited - * by the user. - * - * @param integer $userId Id of the user for which to get the list of groups. - * @param boolean $recursive True to include inherited user groups. - * - * @return array List of user group ids to which the user is mapped. - * - * @since 11.1 - */ - public static function getGroupsByUser($userId, $recursive = true) - { - static $results = array(); - - // Creates a simple unique string for each parameter combination: - $storeId = $userId . ':' . (int) $recursive; - - if (!isset($results[$storeId])) - { - // Guest user - if (empty($userId)) - { - $result = array(JComponentHelper::getParams('com_users')->get('guest_usergroup', 1)); - } - // Registered user - else - { - $db = JFactory::getDbo(); - - // Build the database query to get the rules for the asset. - $query = $db->getQuery(true); - $query->select($recursive ? 'b.id' : 'a.id'); - $query->from('#__user_usergroup_map AS map'); - $query->where('map.user_id = ' . (int) $userId); - $query->leftJoin('#__usergroups AS a ON a.id = map.group_id'); - - // If we want the rules cascading up to the global asset node we need a self-join. - if ($recursive) - { - $query->leftJoin('#__usergroups AS b ON b.lft <= a.lft AND b.rgt >= a.rgt'); - } - - // Execute the query and load the rules from the result. - $db->setQuery($query); - $result = $db->loadColumn(); - - // Clean up any NULL or duplicate values, just in case - JArrayHelper::toInteger($result); - - if (empty($result)) - { - $result = array('1'); - } - else - { - $result = array_unique($result); - } - } - - $results[$storeId] = $result; - } - - return $results[$storeId]; - } - - /** - * Method to return a list of user Ids contained in a Group - * - * @param integer $groupId The group Id - * @param boolean $recursive Recursively include all child groups (optional) - * - * @return array - * - * @since 11.1 - * @todo This method should move somewhere else - */ - public static function getUsersByGroup($groupId, $recursive = false) - { - // Get a database object. - $db = JFactory::getDbo(); - - $test = $recursive ? '>=' : '='; - - // First find the users contained in the group - $query = $db->getQuery(true); - $query->select('DISTINCT(user_id)'); - $query->from('#__usergroups as ug1'); - $query->join('INNER', '#__usergroups AS ug2 ON ug2.lft' . $test . 'ug1.lft AND ug1.rgt' . $test . 'ug2.rgt'); - $query->join('INNER', '#__user_usergroup_map AS m ON ug2.id=m.group_id'); - $query->where('ug1.id=' . $db->Quote($groupId)); - - $db->setQuery($query); - - $result = $db->loadColumn(); - - // Clean up any NULL values, just in case - JArrayHelper::toInteger($result); - - return $result; - } - - /** - * Method to return a list of view levels for which the user is authorised. - * - * @param integer $userId Id of the user for which to get the list of authorised view levels. - * - * @return array List of view levels for which the user is authorised. - * - * @since 11.1 - */ - public static function getAuthorisedViewLevels($userId) - { - // Get all groups that the user is mapped to recursively. - $groups = self::getGroupsByUser($userId); - - // Only load the view levels once. - if (empty(self::$viewLevels)) - { - // Get a database object. - $db = JFactory::getDBO(); - - // Build the base query. - $query = $db->getQuery(true); - $query->select('id, rules'); - $query->from($query->qn('#__viewlevels')); - - // Set the query for execution. - $db->setQuery((string) $query); - - // Build the view levels array. - foreach ($db->loadAssocList() as $level) - { - self::$viewLevels[$level['id']] = (array) json_decode($level['rules']); - } - } - - // Initialise the authorised array. - $authorised = array(1); - - // Find the authorised levels. - foreach (self::$viewLevels as $level => $rule) - { - foreach ($rule as $id) - { - if (($id < 0) && (($id * -1) == $userId)) - { - $authorised[] = $level; - break; - } - // Check to see if the group is mapped to the level. - elseif (($id >= 0) && in_array($id, $groups)) - { - $authorised[] = $level; - break; - } - } - } - - return $authorised; - } - - /** - * Method to return a list of actions for which permissions can be set given a component and section. - * - * @param string $component The component from which to retrieve the actions. - * @param string $section The name of the section within the component from which to retrieve the actions. - * - * @return array List of actions available for the given component and section. - * - * @since 11.1 - * - * @todo Need to decouple this method from the CMS. Maybe check if $component is a - * valid file (or create a getActionsFromFile method). - */ - public static function getActions($component, $section = 'component') - { - $actions = array(); - - if (defined('JPATH_ADMINISTRATOR') && is_file(JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml')) - { - $xml = simplexml_load_file(JPATH_ADMINISTRATOR . '/components/' . $component . '/access.xml'); - - foreach ($xml->children() as $child) - { - if ($section == (string) $child['name']) - { - foreach ($child->children() as $action) - { - $actions[] = (object) array( - 'name' => (string) $action['name'], - 'title' => (string) $action['title'], - 'description' => (string) $action['description']); - } - - break; - } - } - } - - return $actions; - } -} diff --git a/platform/libraries/joomla/access/index.html b/platform/libraries/joomla/access/index.html deleted file mode 100644 index 2efb97f..0000000 --- a/platform/libraries/joomla/access/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/platform/libraries/joomla/access/rule.php b/platform/libraries/joomla/access/rule.php deleted file mode 100644 index a9b8ea8..0000000 --- a/platform/libraries/joomla/access/rule.php +++ /dev/null @@ -1,178 +0,0 @@ - true, 3 => true, 4 => false) - * or an equivalent JSON encoded string. - * - * @param mixed $identities A JSON format string (probably from the database) or a named array. - * - * @return JRule - * - * @since 11.1 - */ - public function __construct($identities) - { - // Convert string input to an array. - if (is_string($identities)) - { - $identities = json_decode($identities, true); - } - - $this->mergeIdentities($identities); - } - - /** - * Get the data for the action. - * - * @return array A named array - * - * @since 11.1 - */ - public function getData() - { - return $this->data; - } - - /** - * Merges the identities - * - * @param mixed $identities An integer or array of integers representing the identities to check. - * - * @return void - * - * @since 11.1 - */ - public function mergeIdentities($identities) - { - if ($identities instanceof JRule) - { - $identities = $identities->getData(); - } - - if (is_array($identities)) - { - foreach ($identities as $identity => $allow) - { - $this->mergeIdentity($identity, $allow); - } - } - } - - /** - * Merges the values for an identity. - * - * @param integer $identity The identity. - * @param boolean $allow The value for the identity (true == allow, false == deny). - * - * @return void - * - * @since 11.1 - */ - public function mergeIdentity($identity, $allow) - { - $identity = (int) $identity; - $allow = (int) ((boolean) $allow); - - // Check that the identity exists. - if (isset($this->data[$identity])) - { - // Explicit deny always wins a merge. - if ($this->data[$identity] !== 0) - { - $this->data[$identity] = $allow; - } - } - else - { - $this->data[$identity] = $allow; - } - } - - /** - * Checks that this action can be performed by an identity. - * - * The identity is an integer where +ve represents a user group, - * and -ve represents a user. - * - * @param mixed $identities An integer or array of integers representing the identities to check. - * - * @return mixed True if allowed, false for an explicit deny, null for an implicit deny. - * - * @since 11.1 - */ - public function allow($identities) - { - // Implicit deny by default. - $result = null; - - // Check that the inputs are valid. - if (!empty($identities)) - { - if (!is_array($identities)) - { - $identities = array($identities); - } - - foreach ($identities as $identity) - { - // Technically the identity just needs to be unique. - $identity = (int) $identity; - - // Check if the identity is known. - if (isset($this->data[$identity])) - { - $result = (boolean) $this->data[$identity]; - - // An explicit deny wins. - if ($result === false) - { - break; - } - } - - } - } - - return $result; - } - - /** - * Convert this object into a JSON encoded string. - * - * @return string JSON encoded string - * - * @since 11.1 - */ - public function __toString() - { - return json_encode($this->data); - } -} diff --git a/platform/libraries/joomla/access/rules.php b/platform/libraries/joomla/access/rules.php deleted file mode 100644 index c87c2d7..0000000 --- a/platform/libraries/joomla/access/rules.php +++ /dev/null @@ -1,223 +0,0 @@ - array(-42 => true, 3 => true, 4 => false)) - * or an equivalent JSON encoded string, or an object where properties are arrays. - * - * @param mixed $input A JSON format string (probably from the database) or a nested array. - * - * @return JRules - * - * @since 11.1 - */ - public function __construct($input = '') - { - // Convert in input to an array. - if (is_string($input)) - { - $input = json_decode($input, true); - } - elseif (is_object($input)) - { - $input = (array) $input; - } - - if (is_array($input)) - { - // Top level keys represent the actions. - foreach ($input as $action => $identities) - { - $this->mergeAction($action, $identities); - } - } - } - - /** - * Get the data for the action. - * - * @return array A named array of JRule objects. - * - * @since 11.1 - */ - public function getData() - { - return $this->data; - } - - /** - * Method to merge a collection of JRules. - * - * @param mixed $input JRule or array of JRules - * - * @return void - * - * @since 11.1 - */ - public function mergeCollection($input) - { - // Check if the input is an array. - if (is_array($input)) - { - foreach ($input as $actions) - { - $this->merge($actions); - } - } - } - - /** - * Method to merge actions with this object. - * - * @param mixed $actions JRule object, an array of actions or a JSON string array of actions. - * - * @return void - * - * @since 11.1 - */ - public function merge($actions) - { - if (is_string($actions)) - { - $actions = json_decode($actions, true); - } - - if (is_array($actions)) - { - foreach ($actions as $action => $identities) - { - $this->mergeAction($action, $identities); - } - } - elseif ($actions instanceof JRules) - { - $data = $actions->getData(); - - foreach ($data as $name => $identities) - { - $this->mergeAction($name, $identities); - } - } - } - - /** - * Merges an array of identities for an action. - * - * @param string $action The name of the action. - * @param array $identities An array of identities - * - * @return void - * - * @since 11.1 - */ - public function mergeAction($action, $identities) - { - if (isset($this->data[$action])) - { - // If exists, merge the action. - $this->data[$action]->mergeIdentities($identities); - } - else - { - // If new, add the action. - $this->data[$action] = new JRule($identities); - } - } - - /** - * Checks that an action can be performed by an identity. - * - * The identity is an integer where +ve represents a user group, - * and -ve represents a user. - * - * @param string $action The name of the action. - * @param mixed $identity An integer representing the identity, or an array of identities - * - * @return mixed Object or null if there is no information about the action. - * - * @since 11.1 - */ - public function allow($action, $identity) - { - // Check we have information about this action. - if (isset($this->data[$action])) - { - return $this->data[$action]->allow($identity); - } - - return null; - } - - /** - * Get the allowed actions for an identity. - * - * @param mixed $identity An integer representing the identity or an array of identities - * - * @return object Allowed actions for the identity or identities - * - * @since 11.1 - */ - function getAllowed($identity) - { - // Sweep for the allowed actions. - $allowed = new JObject; - foreach ($this->data as $name => &$action) - { - if ($action->allow($identity)) - { - $allowed->set($name, true); - } - } - return $allowed; - } - - /** - * Magic method to convert the object to JSON string representation. - * - * @return string JSON representation of the actions array - * - * @since 11.1 - */ - public function __toString() - { - $temp = array(); - - foreach ($this->data as $name => $rule) - { - // Convert the action to JSON, then back into an array otherwise - // re-encoding will quote the JSON for the identities in the action. - $temp[$name] = json_decode((string) $rule); - } - - return json_encode($temp); - } -} diff --git a/platform/libraries/joomla/application/application.php b/platform/libraries/joomla/application/application.php deleted file mode 100644 index 409e88f..0000000 --- a/platform/libraries/joomla/application/application.php +++ /dev/null @@ -1,1180 +0,0 @@ -_name = $this->getName(); - - // Only set the clientId if available. - if (isset($config['clientId'])) - { - $this->_clientId = $config['clientId']; - } - - // Enable sessions by default. - if (!isset($config['session'])) - { - $config['session'] = true; - } - - // Create the input object - if (class_exists('JInput')) - { - $this->input = new JInput; - } - - // Set the session default name. - if (!isset($config['session_name'])) - { - $config['session_name'] = $this->_name; - } - - // Set the default configuration file. - if (!isset($config['config_file'])) - { - $config['config_file'] = 'configuration.php'; - } - - // Create the configuration object. - if (file_exists(JPATH_CONFIGURATION . '/' . $config['config_file'])) - { - $this->_createConfiguration(JPATH_CONFIGURATION . '/' . $config['config_file']); - } - - // Create the session if a session name is passed. - if ($config['session'] !== false) - { - $this->_createSession(JUtility::getHash($config['session_name'])); - } - - $this->set('requestTime', gmdate('Y-m-d H:i')); - - // Used by task system to ensure that the system doesn't go over time. - $this->set('startTime', JProfiler::getmicrotime()); - } - - /** - * Returns the global JApplication object, only creating it if it - * doesn't already exist. - * - * @param mixed $client A client identifier or name. - * @param array $config An optional associative array of configuration settings. - * @param strong $prefix A prefix for class names - * - * @return JApplication A JApplication object. - * - * @since 11.1 - */ - public static function getInstance($client, $config = array(), $prefix = 'J') - { - static $instances; - - if (!isset($instances)) - { - $instances = array(); - } - - if (empty($instances[$client])) - { - // Load the router object. - jimport('joomla.application.helper'); - $info = JApplicationHelper::getClientInfo($client, true); - - $path = $info->path . '/includes/application.php'; - if (file_exists($path)) - { - include_once $path; - - // Create a JRouter object. - $classname = $prefix . ucfirst($client); - $instance = new $classname($config); - } - else - { - $error = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_APPLICATION_LOAD', $client)); - return $error; - } - - $instances[$client] = &$instance; - } - - return $instances[$client]; - } - - /** - * Initialise the application. - * - * @param array $options An optional associative array of configuration settings. - * - * @return void - * - * @since 11.1 - */ - public function initialise($options = array()) - { - jimport('joomla.plugin.helper'); - - // Set the language in the class. - $config = JFactory::getConfig(); - - // Check that we were given a language in the array (since by default may be blank). - if (isset($options['language'])) - { - $config->set('language', $options['language']); - } - - // Set user specific editor. - $user = JFactory::getUser(); - $editor = $user->getParam('editor', $this->getCfg('editor')); - if (!JPluginHelper::isEnabled('editors', $editor)) - { - $editor = $this->getCfg('editor'); - if (!JPluginHelper::isEnabled('editors', $editor)) - { - $editor = 'none'; - } - } - - $config->set('editor', $editor); - - // Trigger the onAfterInitialise event. - JPluginHelper::importPlugin('system'); - $this->triggerEvent('onAfterInitialise'); - } - - /** - * Route the application. - * - * Routing is the process of examining the request environment to determine which - * component should receive the request. The component optional parameters - * are then set in the request object to be processed when the application is being - * dispatched. - * - * @return void - * - * @since 11.1 - */ - public function route() - { - // Get the full request URI. - $uri = clone JURI::getInstance(); - - $router = $this->getRouter(); - $result = $router->parse($uri); - - JRequest::set($result, 'get', false); - - // Trigger the onAfterRoute event. - JPluginHelper::importPlugin('system'); - $this->triggerEvent('onAfterRoute'); - } - - /** - * Dispatch the application. - * - * Dispatching is the process of pulling the option from the request object and - * mapping them to a component. If the component does not exist, it handles - * determining a default component to dispatch. - * - * @param string $component The component to dispatch. - * - * @return void - * - * @since 11.1 - */ - public function dispatch($component = null) - { - $document = JFactory::getDocument(); - - $document->setTitle($this->getCfg('sitename') . ' - ' . JText::_('JADMINISTRATION')); - $document->setDescription($this->getCfg('MetaDesc')); - - $contents = JComponentHelper::renderComponent($component); - $document->setBuffer($contents, 'component'); - - // Trigger the onAfterDispatch event. - JPluginHelper::importPlugin('system'); - $this->triggerEvent('onAfterDispatch'); - } - - /** - * Render the application. - * - * Rendering is the process of pushing the document buffers into the template - * placeholders, retrieving data from the document and pushing it into - * the JResponse buffer. - * - * @return void - * - * @since 11.1 - */ - public function render() - { - $params = array('template' => $this->getTemplate(), 'file' => 'index.php', 'directory' => JPATH_THEMES, 'params' => $template->params); - - // Parse the document. - $document = JFactory::getDocument(); - $document->parse($params); - - // Trigger the onBeforeRender event. - JPluginHelper::importPlugin('system'); - $this->triggerEvent('onBeforeRender'); - - // Render the document. - $caching = ($this->getCfg('caching') >= 2) ? true : false; - JResponse::setBody($document->render($caching, $params)); - - // Trigger the onAfterRender event. - $this->triggerEvent('onAfterRender'); - } - - /** - * Exit the application. - * - * @param integer $code Exit code - * - * @return void Exits the application. - * - * @since 11.1 - */ - public function close($code = 0) - { - exit($code); - } - - /** - * Redirect to another URL. - * - * Optionally enqueues a message in the system message queue (which will be displayed - * the next time a page is loaded) using the enqueueMessage method. If the headers have - * not been sent the redirect will be accomplished using a "301 Moved Permanently" - * code in the header pointing to the new location. If the headers have already been - * sent this will be accomplished using a JavaScript statement. - * - * @param string $url The URL to redirect to. Can only be http/https URL - * @param string $msg An optional message to display on redirect. - * @param string $msgType An optional message type. Defaults to message. - * @param boolean $moved True if the page is 301 Permanently Moved, otherwise 303 See Other is assumed. - * - * @return void Calls exit(). - * - * @since 11.1 - * - * @see JApplication::enqueueMessage() - */ - public function redirect($url, $msg = '', $msgType = 'message', $moved = false) - { - // Check for relative internal links. - if (preg_match('#^index2?\.php#', $url)) - { - $url = JURI::base() . $url; - } - - // Strip out any line breaks. - $url = preg_split("/[\r\n]/", $url); - $url = $url[0]; - - // If we don't start with a http we need to fix this before we proceed. - // We could validly start with something else (e.g. ftp), though this would - // be unlikely and isn't supported by this API. - if (!preg_match('#^http#i', $url)) - { - $uri = JURI::getInstance(); - $prefix = $uri->toString(array('scheme', 'user', 'pass', 'host', 'port')); - - if ($url[0] == '/') - { - // We just need the prefix since we have a path relative to the root. - $url = $prefix . $url; - } - else - { - // It's relative to where we are now, so lets add that. - $parts = explode('/', $uri->toString(array('path'))); - array_pop($parts); - $path = implode('/', $parts) . '/'; - $url = $prefix . $path . $url; - } - } - - // If the message exists, enqueue it. - if (trim($msg)) - { - $this->enqueueMessage($msg, $msgType); - } - - // Persist messages if they exist. - if (count($this->_messageQueue)) - { - $session = JFactory::getSession(); - $session->set('application.queue', $this->_messageQueue); - } - - // If the headers have been sent, then we cannot send an additional location header - // so we will output a javascript redirect statement. - if (headers_sent()) - { - echo "\n"; - } - else - { - $document = JFactory::getDocument(); - jimport('joomla.environment.browser'); - $navigator = JBrowser::getInstance(); - jimport('phputf8.utils.ascii'); - if ($navigator->isBrowser('msie') && !utf8_is_ascii($url)) - { - // MSIE type browser and/or server cause issues when url contains utf8 character,so use a javascript redirect method - echo ''; - } - elseif (!$moved and $navigator->isBrowser('konqueror')) - { - // WebKit browser (identified as konqueror by Joomla!) - Do not use 303, as it causes subresources - // reload (https://bugs.webkit.org/show_bug.cgi?id=38690) - echo ''; - } - else - { - // All other browsers, use the more efficient HTTP header method - header($moved ? 'HTTP/1.1 301 Moved Permanently' : 'HTTP/1.1 303 See other'); - header('Location: ' . $url); - header('Content-Type: text/html; charset=' . $document->getCharset()); - } - } - $this->close(); - } - - /** - * Enqueue a system message. - * - * @param string $msg The message to enqueue. - * @param string $type The message type. Default is message. - * - * @return void - * - * @since 11.1 - */ - public function enqueueMessage($msg, $type = 'message') - { - // For empty queue, if messages exists in the session, enqueue them first. - if (!count($this->_messageQueue)) - { - $session = JFactory::getSession(); - $sessionQueue = $session->get('application.queue'); - - if (count($sessionQueue)) - { - $this->_messageQueue = $sessionQueue; - $session->set('application.queue', null); - } - } - - // Enqueue the message. - $this->_messageQueue[] = array('message' => $msg, 'type' => strtolower($type)); - } - - /** - * Get the system message queue. - * - * @return array The system message queue. - * - * @since 11.1 - */ - public function getMessageQueue() - { - // For empty queue, if messages exists in the session, enqueue them. - if (!count($this->_messageQueue)) - { - $session = JFactory::getSession(); - $sessionQueue = $session->get('application.queue'); - - if (count($sessionQueue)) - { - $this->_messageQueue = $sessionQueue; - $session->set('application.queue', null); - } - } - - return $this->_messageQueue; - } - - /** - * Gets a configuration value. - * - * An example is in application/japplication-getcfg.php Getting a configuration - * - * @param string $varname The name of the value to get. - * @param string $default Default value to return - * - * @return mixed The user state. - * - * @since 11.1 - */ - public function getCfg($varname, $default = null) - { - $config = JFactory::getConfig(); - return $config->get('' . $varname, $default); - } - - /** - * Method to get the application name. - * - * The dispatcher name is by default parsed using the classname, or it can be set - * by passing a $config['name'] in the class constructor. - * - * @return string The name of the dispatcher. - * - * @since 11.1 - */ - public function getName() - { - $name = $this->_name; - - if (empty($name)) - { - $r = null; - if (!preg_match('/J(.*)/i', get_class($this), $r)) - { - JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_APPLICATION_GET_NAME')); - } - $name = strtolower($r[1]); - } - - return $name; - } - - /** - * Gets a user state. - * - * @param string $key The path of the state. - * @param mixed $default Optional default value, returned if the internal value is null. - * - * @return mixed The user state or null. - * - * @since 11.1 - */ - public function getUserState($key, $default = null) - { - $session = JFactory::getSession(); - $registry = $session->get('registry'); - - if (!is_null($registry)) - { - return $registry->get($key, $default); - } - - return $default; - } - - /** - * Sets the value of a user state variable. - * - * @param string $key The path of the state. - * @param string $value The value of the variable. - * - * @return mixed The previous state, if one existed. - * - * @since 11.1 - */ - public function setUserState($key, $value) - { - $session = JFactory::getSession(); - $registry = $session->get('registry'); - - if (!is_null($registry)) - { - return $registry->set($key, $value); - } - - return null; - } - - /** - * Gets the value of a user state variable. - * - * @param string $key The key of the user state variable. - * @param string $request The name of the variable passed in a request. - * @param string $default The default value for the variable if not found. Optional. - * @param string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional. - * - * @return The request user state. - * - * @since 11.1 - */ - public function getUserStateFromRequest($key, $request, $default = null, $type = 'none') - { - $cur_state = $this->getUserState($key, $default); - $new_state = JRequest::getVar($request, null, 'default', $type); - - // Save the new value only if it was set in this request. - if ($new_state !== null) - { - $this->setUserState($key, $new_state); - } - else - { - $new_state = $cur_state; - } - - return $new_state; - } - - /** - * Registers a handler to a particular event group. - * - * @param string $event The event name. - * @param mixed $handler The handler, a function or an instance of a event object. - * - * @return void - * - * @since 11.1 - */ - public static function registerEvent($event, $handler) - { - $dispatcher = JDispatcher::getInstance(); - $dispatcher->register($event, $handler); - } - - /** - * Calls all handlers associated with an event group. - * - * @param string $event The event name. - * @param array $args An array of arguments. - * - * @return array An array of results from each function call. - * - * @since 11.1 - */ - function triggerEvent($event, $args = null) - { - $dispatcher = JDispatcher::getInstance(); - - return $dispatcher->trigger($event, $args); - } - - /** - * Login authentication function. - * - * Username and encoded password are passed the onUserLogin event which - * is responsible for the user validation. A successful validation updates - * the current session record with the user's details. - * - * Username and encoded password are sent as credentials (along with other - * possibilities) to each observer (authentication plugin) for user - * validation. Successful validation will update the current session with - * the user details. - * - * @param array $credentials Array('username' => string, 'password' => string) - * @param array $options Array('remember' => boolean) - * - * @return boolean True on success. - * - * @since 11.1 - */ - public function login($credentials, $options = array()) - { - // Get the global JAuthentication object. - jimport('joomla.user.authentication'); - - $authenticate = JAuthentication::getInstance(); - $response = $authenticate->authenticate($credentials, $options); - - if ($response->status === JAuthentication::STATUS_SUCCESS) - { - // validate that the user should be able to login (different to being authenticated) - // this permits authentication plugins blocking the user - $authorisations = $authenticate->authorise($response, $options); - foreach ($authorisations as $authorisation) - { - $denied_states = array(JAuthentication::STATUS_EXPIRED, JAuthentication::STATUS_DENIED); - if (in_array($authorisation->status, $denied_states)) - { - // Trigger onUserAuthorisationFailure Event. - $this->triggerEvent('onUserAuthorisationFailure', array((array) $authorisation)); - - // If silent is set, just return false. - if (isset($options['silent']) && $options['silent']) - { - return false; - } - - // Return the error. - switch ($authorisation->status) - { - case JAuthentication::STATUS_EXPIRED: - return JError::raiseWarning('102002', JText::_('JLIB_LOGIN_EXPIRED')); - break; - case JAuthentication::STATUS_DENIED: - return JError::raiseWarning('102003', JText::_('JLIB_LOGIN_DENIED')); - break; - default: - return JError::raiseWarning('102004', JText::_('JLIB_LOGIN_AUTHORISATION')); - break; - } - } - } - - // Import the user plugin group. - JPluginHelper::importPlugin('user'); - - // OK, the credentials are authenticated and user is authorised. Lets fire the onLogin event. - $results = $this->triggerEvent('onUserLogin', array((array) $response, $options)); - - /* - * If any of the user plugins did not successfully complete the login routine - * then the whole method fails. - * - * Any errors raised should be done in the plugin as this provides the ability - * to provide much more information about why the routine may have failed. - */ - - if (!in_array(false, $results, true)) - { - // Set the remember me cookie if enabled. - if (isset($options['remember']) && $options['remember']) - { - jimport('joomla.utilities.simplecrypt'); - jimport('joomla.utilities.utility'); - - // Create the encryption key, apply extra hardening using the user agent string. - $key = JUtility::getHash(@$_SERVER['HTTP_USER_AGENT']); - - $crypt = new JSimpleCrypt($key); - $rcookie = $crypt->encrypt(serialize($credentials)); - $lifetime = time() + 365 * 24 * 60 * 60; - - // Use domain and path set in config for cookie if it exists. - $cookie_domain = $this->getCfg('cookie_domain', ''); - $cookie_path = $this->getCfg('cookie_path', '/'); - setcookie(JUtility::getHash('JLOGIN_REMEMBER'), $rcookie, $lifetime, $cookie_path, $cookie_domain); - } - - return true; - } - } - - // Trigger onUserLoginFailure Event. - $this->triggerEvent('onUserLoginFailure', array((array) $response)); - - // If silent is set, just return false. - if (isset($options['silent']) && $options['silent']) - { - return false; - } - - // If status is success, any error will have been raised by the user plugin - if ($response->status !== JAuthentication::STATUS_SUCCESS) - { - JError::raiseWarning('102001', $response->error_message); - } - - return false; - } - - /** - * Logout authentication function. - * - * Passed the current user information to the onUserLogout event and reverts the current - * session record back to 'anonymous' parameters. - * If any of the authentication plugins did not successfully complete - * the logout routine then the whole method fails. Any errors raised - * should be done in the plugin as this provides the ability to give - * much more information about why the routine may have failed. - * - * @param integer $userid The user to load - Can be an integer or string - If string, it is converted to ID automatically - * @param array $options Array('clientid' => array of client id's) - * - * @return boolean True on success - * - * @since 11.1 - */ - public function logout($userid = null, $options = array()) - { - // Initialise variables. - $retval = false; - - // Get a user object from the JApplication. - $user = JFactory::getUser($userid); - - // Build the credentials array. - $parameters['username'] = $user->get('username'); - $parameters['id'] = $user->get('id'); - - // Set clientid in the options array if it hasn't been set already. - if (!isset($options['clientid'])) - { - $options['clientid'] = $this->getClientId(); - } - - // Import the user plugin group. - JPluginHelper::importPlugin('user'); - - // OK, the credentials are built. Lets fire the onLogout event. - $results = $this->triggerEvent('onUserLogout', array($parameters, $options)); - - // Check if any of the plugins failed. If none did, success. - - if (!in_array(false, $results, true)) - { - // Use domain and path set in config for cookie if it exists. - $cookie_domain = $this->getCfg('cookie_domain', ''); - $cookie_path = $this->getCfg('cookie_path', '/'); - setcookie(JUtility::getHash('JLOGIN_REMEMBER'), false, time() - 86400, $cookie_path, $cookie_domain); - - return true; - } - - // Trigger onUserLoginFailure Event. - $this->triggerEvent('onUserLogoutFailure', array($parameters)); - - return false; - } - - /** - * Gets the name of the current template. - * - * @param array $params An optional associative array of configuration settings - * - * @return string System is the fallback. - * - * @since 11.1 - */ - public function getTemplate($params = false) - { - return 'system'; - } - - /** - * Returns the application JRouter object. - * - * @param string $name The name of the application. - * @param array $options An optional associative array of configuration settings. - * - * @return JRouter A JRouter object - * - * @since 11.1 - */ - static public function getRouter($name = null, array $options = array()) - { - if (!isset($name)) - { - $app = JFactory::getApplication(); - $name = $app->getName(); - } - - jimport('joomla.application.router'); - $router = JRouter::getInstance($name, $options); - - if (JError::isError($router)) - { - return null; - } - - return $router; - } - - /** - * This method transliterates a string into an URL - * safe string or returns a URL safe UTF-8 string - * based on the global configuration - * - * @param string $string String to process - * - * @return string Processed string - * - * @since 11.1 - */ - static public function stringURLSafe($string) - { - if (JFactory::getConfig()->get('unicodeslugs') == 1) - { - $output = JFilterOutput::stringURLUnicodeSlug($string); - } - else - { - $output = JFilterOutput::stringURLSafe($string); - } - - return $output; - } - - /** - * Returns the application JPathway object. - * - * @param string $name The name of the application. - * @param array $options An optional associative array of configuration settings. - * - * @return JPathway A JPathway object - * - * @since 11.1 - */ - public function getPathway($name = null, $options = array()) - { - if (!isset($name)) - { - $name = $this->_name; - } - - jimport('joomla.application.pathway'); - $pathway = JPathway::getInstance($name, $options); - - if (JError::isError($pathway)) - { - return null; - } - - return $pathway; - } - - /** - * Returns the application JPathway object. - * - * @param string $name The name of the application/client. - * @param array $options An optional associative array of configuration settings. - * - * @return JMenu JMenu object. - * - * @since 11.1 - */ - public function getMenu($name = null, $options = array()) - { - if (!isset($name)) - { - $name = $this->_name; - } - - jimport('joomla.application.menu'); - $menu = JMenu::getInstance($name, $options); - - if (JError::isError($menu)) - { - return null; - } - - return $menu; - } - - /** - * Provides a secure hash based on a seed - * - * @param string $seed Seed string. - * - * @return string A secure hash - * - * @since 11.1 - */ - public static function getHash($seed) - { - $conf = JFactory::getConfig(); - - return md5($conf->get('secret') . $seed); - } - - /** - * Create the configuration registry. - * - * @param string $file The path to the configuration file - * - * @return object A JConfig object - * - * @since 11.1 - */ - protected function _createConfiguration($file) - { - jimport('joomla.registry.registry'); - - include_once $file; - - // Create the JConfig object. - $config = new JConfig; - - // Get the global configuration object. - $registry = JFactory::getConfig(); - - // Load the configuration values into the registry. - $registry->loadObject($config); - - return $config; - } - - /** - * Create the user session. - * - * Old sessions are flushed based on the configuration value for the cookie - * lifetime. If an existing session, then the last access time is updated. - * If a new session, a session id is generated and a record is created in - * the #__sessions table. - * - * @param string $name The sessions name. - * - * @return JSession JSession on success. May call exit() on database error. - * - * @since 11.1 - */ - protected function _createSession($name) - { - $options = array(); - $options['name'] = $name; - - switch ($this->_clientId) - { - case 0: - if ($this->getCfg('force_ssl') == 2) - { - $options['force_ssl'] = true; - } - break; - - case 1: - if ($this->getCfg('force_ssl') >= 1) - { - $options['force_ssl'] = true; - } - break; - } - - $session = JFactory::getSession($options); - - //TODO: At some point we need to get away from having session data always in the db. - - $db = JFactory::getDBO(); - - // Remove expired sessions from the database. - $time = time(); - if ($time % 2) - { - // The modulus introduces a little entropy, making the flushing less accurate - // but fires the query less than half the time. - $query = $db->getQuery(true); - $db->setQuery('DELETE FROM ' . $query->qn('#__session') . ' WHERE ' . $query->qn('time') . ' < ' . (int) ($time - $session->getExpire())); - $db->query(); - } - - // Check to see the the session already exists. - if (($this->getCfg('session_handler') != 'database' && ($time % 2 || $session->isNew())) - || ($this->getCfg('session_handler') == 'database' && $session->isNew()) - ) - { - $this->checkSession(); - } - - return $session; - } - - /** - * Checks the user session. - * - * If the session record doesn't exist, initialise it. - * If session is new, create session variables - * - * @return void - * - * @since 11.1 - */ - public function checkSession() - { - $db = JFactory::getDBO(); - $session = JFactory::getSession(); - $user = JFactory::getUser(); - - $query = $db->getQuery(true); - $db->setQuery( - 'SELECT ' . $query->qn('session_id') . ' FROM ' . $query->qn('#__session') . ' WHERE ' . $query->qn('session_id') . ' = ' . - $query->q($session->getId()), - 0, 1 - ); - $exists = $db->loadResult(); - - // If the session record doesn't exist initialise it. - if (!$exists) - { - if ($session->isNew()) - { - $db->setQuery( - 'INSERT INTO ' . $query->qn('#__session') . ' (' . $query->qn('session_id') . ', ' . $query->qn('client_id') . ', ' . - $query->qn('time') . ')' . ' VALUES (' . $query->q($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . - (int) time() . ')' - ); - } - else - { - $db->setQuery( - 'INSERT INTO ' . $query->qn('#__session') . ' (' . $query->qn('session_id') . ', ' . $query->qn('client_id') . ', ' . - $query->qn('guest') . ', ' . $query->qn('time') . ', ' . $query->qn('userid') . ', ' . $query->qn('username') . ')' . - ' VALUES (' . $query->q($session->getId()) . ', ' . (int) $this->getClientId() . ', ' . (int) $user->get('guest') . ', ' . - (int) $session->get('session.timer.start') . ', ' . (int) $user->get('id') . ', ' . $query->q($user->get('username')) . ')' - ); - } - - // If the insert failed, exit the application. - if (!$db->query()) - { - jexit($db->getErrorMSG()); - } - - // Session doesn't exist yet, so create session variables - if ($session->isNew()) - { - $session->set('registry', new JRegistry('session')); - $session->set('user', new JUser); - } - } - } - - /** - * Gets the client id of the current running application. - * - * @return integer A client identifier. - * - * @since 11.1 - */ - public function getClientId() - { - return $this->_clientId; - } - - /** - * Is admin interface? - * - * @return boolean True if this application is administrator. - * - * @since 11.1 - */ - public function isAdmin() - { - return ($this->_clientId == 1); - } - - /** - * Is site interface? - * - * @return boolean True if this application is site. - * - * @since 11.1 - */ - public function isSite() - { - return ($this->_clientId == 0); - } - - /** - * Method to determine if the host OS is Windows - * - * @return boolean True if Windows OS - * - * @since 11.1 - */ - static function isWinOS() - { - return strtoupper(substr(PHP_OS, 0, 3)) === 'WIN'; - } - - /** - * Returns the response as a string. - * - * @return string The response - * - * @since 11.1 - */ - public function __toString() - { - $compress = $this->getCfg('gzip', false); - - return JResponse::toString($compress); - } -} diff --git a/platform/libraries/joomla/application/applicationexception.php b/platform/libraries/joomla/application/applicationexception.php deleted file mode 100644 index e3084d3..0000000 --- a/platform/libraries/joomla/application/applicationexception.php +++ /dev/null @@ -1,21 +0,0 @@ -_extension = $options['extension']; - $this->_table = $options['table']; - $this->_field = (isset($options['field']) && $options['field']) ? $options['field'] : 'catid'; - $this->_key = (isset($options['key']) && $options['key']) ? $options['key'] : 'id'; - $this->_statefield = (isset($options['statefield'])) ? $options['statefield'] : 'state'; - $options['access'] = (isset($options['access'])) ? $options['access'] : 'true'; - $options['published'] = (isset($options['published'])) ? $options['published'] : 1; - $this->_options = $options; - - return true; - } - - /** - * Returns a reference to a JCategories object - * - * @param string $extension Name of the categories extension - * @param array $options An array of options - * - * @return JCategories JCategories object - * - * @since 11.1 - */ - public static function getInstance($extension, $options = array()) - { - $hash = md5($extension . serialize($options)); - - if (isset(self::$instances[$hash])) - { - return self::$instances[$hash]; - } - - $parts = explode('.', $extension); - $component = 'com_' . strtolower($parts[0]); - $section = count($parts) > 1 ? $parts[1] : ''; - $classname = ucfirst(substr($component, 4)) . ucfirst($section) . 'Categories'; - - if (!class_exists($classname)) - { - $path = JPATH_SITE . '/components/' . $component . '/helpers/category.php'; - if (is_file($path)) - { - include_once $path; - } - else - { - return false; - } - } - - self::$instances[$hash] = new $classname($options); - - return self::$instances[$hash]; - } - - /** - * Loads a specific category and all its children in a JCategoryNode object - * - * @param mixed $id an optional id integer or equal to 'root' - * @param boolean $forceload True to force the _load method to execute - * - * @return mixed JCategoryNode object or null if $id is not valid - * - * @since 11.1 - */ - public function get($id = 'root', $forceload = false) - { - if ($id !== 'root') - { - $id = (int) $id; - - if ($id == 0) - { - $id = 'root'; - } - } - - // If this $id has not been processed yet, execute the _load method - if ((!isset($this->_nodes[$id]) && !isset($this->_checkedCategories[$id])) || $forceload) - { - $this->_load($id); - } - - // If we already have a value in _nodes for this $id, then use it. - if (isset($this->_nodes[$id])) - { - return $this->_nodes[$id]; - } - // If we processed this $id already and it was not valid, then return null. - elseif (isset($this->_checkedCategories[$id])) - { - return null; - } - - return false; - } - - /** - * Load method - * - * @param integer $id Id of category to load - * - * @return void - * - * @since 11.1 - */ - protected function _load($id) - { - $db = JFactory::getDbo(); - $app = JFactory::getApplication(); - $user = JFactory::getUser(); - $extension = $this->_extension; - // Record that has this $id has been checked - $this->_checkedCategories[$id] = true; - - $query = $db->getQuery(true); - - // Right join with c for category - $query->select('c.*'); - $query->select('CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as slug'); - $query->from('#__categories as c'); - $query->where('(c.extension=' . $db->Quote($extension) . ' OR c.extension=' . $db->Quote('system') . ')'); - - if ($this->_options['access']) - { - $query->where('c.access IN (' . implode(',', $user->getAuthorisedViewLevels()) . ')'); - } - - if ($this->_options['published'] == 1) - { - $query->where('c.published = 1'); - } - - $query->order('c.lft'); - - // s for selected id - if ($id != 'root') - { - // Get the selected category - $query->leftJoin('#__categories AS s ON (s.lft <= c.lft AND s.rgt >= c.rgt) OR (s.lft > c.lft AND s.rgt < c.rgt)'); - $query->where('s.id=' . (int) $id); - } - - $subQuery = ' (SELECT cat.id as id FROM #__categories AS cat JOIN #__categories AS parent ' . - 'ON cat.lft BETWEEN parent.lft AND parent.rgt WHERE parent.extension = ' . $db->quote($extension) . - ' AND parent.published != 1 GROUP BY cat.id) '; - $query->leftJoin($subQuery . 'AS badcats ON badcats.id = c.id'); - $query->where('badcats.id is null'); - - // i for item - if (isset($this->_options['countItems']) && $this->_options['countItems'] == 1) - { - if ($this->_options['published'] == 1) - { - $query->leftJoin( - $db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id AND i.' . $this->_statefield . ' = 1' - ); - } - else - { - $query->leftJoin($db->quoteName($this->_table) . ' AS i ON i.' . $db->quoteName($this->_field) . ' = c.id'); - } - - $query->select('COUNT(i.' . $db->quoteName($this->_key) . ') AS numitems'); - } - - // Group by - $query->group('c.id'); - - // Filter by language - if ($app->isSite() && $app->getLanguageFilter()) - { - $query->where( - '(' . ($id != 'root' ? 'c.id=s.id OR ' : '') . 'c.language in (' . $db->Quote(JFactory::getLanguage()->getTag()) . ',' . - $db->Quote('*') . '))' - ); - } - - // Get the results - $db->setQuery($query); - $results = $db->loadObjectList('id'); - $childrenLoaded = false; - - if (count($results)) - { - // Foreach categories - foreach ($results as $result) - { - // Deal with root category - if ($result->id == 1) - { - $result->id = 'root'; - } - - // Deal with parent_id - if ($result->parent_id == 1) - { - $result->parent_id = 'root'; - } - - // Create the node - if (!isset($this->_nodes[$result->id])) - { - // Create the JCategoryNode and add to _nodes - $this->_nodes[$result->id] = new JCategoryNode($result, $this); - - // If this is not root and if the current node's parent is in the list or the current node parent is 0 - if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id == 1)) - { - // Compute relationship between node and its parent - set the parent in the _nodes field - $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); - } - - // If the node's parent id is not in the _nodes list and the node is not root (doesn't have parent_id == 0), - // then remove the node from the list - if (!(isset($this->_nodes[$result->parent_id]) || $result->parent_id == 0)) - { - unset($this->_nodes[$result->id]); - continue; - } - - if ($result->id == $id || $childrenLoaded) - { - $this->_nodes[$result->id]->setAllLoaded(); - $childrenLoaded = true; - } - } - elseif ($result->id == $id || $childrenLoaded) - { - // Create the JCategoryNode - $this->_nodes[$result->id] = new JCategoryNode($result, $this); - - if ($result->id != 'root' && (isset($this->_nodes[$result->parent_id]) || $result->parent_id)) - { - // Compute relationship between node and its parent - $this->_nodes[$result->id]->setParent($this->_nodes[$result->parent_id]); - } - - if (!isset($this->_nodes[$result->parent_id])) - { - unset($this->_nodes[$result->id]); - continue; - } - - if ($result->id == $id || $childrenLoaded) - { - $this->_nodes[$result->id]->setAllLoaded(); - $childrenLoaded = true; - } - - } - } - } - else - { - $this->_nodes[$id] = null; - } - } -} - -/** - * Helper class to load Categorytree - * - * @package Joomla.Platform - * @subpackage Application - * @since 11.1 - */ -class JCategoryNode extends JObject -{ - - /** - * Primary key - * - * @var integer - * @since 11.1 - */ - public $id = null; - - /** - * The id of the category in the asset table - * - * @var integer - * @since 11.1 - */ - public $asset_id = null; - - /** - * The id of the parent of category in the asset table, 0 for category root - * - * @var integer - * @since 11.1 - */ - - public $parent_id = null; - - /** - * The lft value for this category in the category tree - * - * @var integer - * @since 11.1 - */ - - public $lft = null; - - /** - * The rgt value for this category in the category tree - * - * @var integer - * @since 11.1 - */ - public $rgt = null; - - /** - * The depth of this category's position in the category tree - * - * @var integer - * @since 11.1 - */ - public $level = null; - - /** - * The extension this category is associated with - * - * @var integer - * @since 11.1 - */ - public $extension = null; - - /** - * The menu title for the category (a short name) - * - * @var string - * @since 11.1 - */ - public $title = null; - - /** - * The the alias for the category - * - * @var string - * @since 11.1 - */ - public $alias = null; - - /** - * Description of the category. - * - * @var string - * @since 11.1 - */ - public $description = null; - - /** - * The publication status of the category - * - * @var boolean - * @since 11.1 - */ - public $published = null; - - /** - * Whether the category is or is not checked out - * - * @var boolean - * @since 11.1 - */ - public $checked_out = 0; - - /** - * The time at which the category was checked out - * - * @var time - * @since 11.1 - */ - public $checked_out_time = 0; - - /** - * Access level for the category - * - * @var integer - * @since 11.1 - */ - public $access = null; - - /** - * JSON string of parameters - * - * @var string - * @since 11.1 - */ - public $params = null; - - /** - * Metadata description - * - * @var string - * @since 11.1 - */ - - public $metadesc = null; - - /** - * Key words for meta data - * - * @var string - * @since 11.1 - */ - public $metakey = null; - - /** - * JSON string of other meta data - * - * @var string - * @since 11.1 - */ - public $metadata = null; - - public $created_user_id = null; - - /** - * The time at which the category was created - * - * @var time - * @since 11.1 - */ - public $created_time = null; - - public $modified_user_id = null; - - /** - * The time at which the category was modified - * - * @var time - * @since 11.1 - */ - public $modified_time = null; - - /** - * Nmber of times the category has been viewed - * - * @var integer - * @since 11.1 - */ - public $hits = null; - - /** - * The language for the category in xx-XX format - * - * @var time - * @since 11.1 - */ - public $language = null; - - /** - * Number of items in this category or descendants of this category - * - * @var integer - * @since 11.1 - */ - public $numitems = null; - - /** - * Number of children items - * - * @var - * @since 11.1 - */ - - public $childrennumitems = null; - - /** - * Slug fo the category (used in URL) - * - * @var string - * @since 11.1 - */ - public $slug = null; - - /** - * Array of assets - * - * @var array - * @since 11.1 - */ - public $assets = null; - - /** - * Parent Category object - * - * @var object - * @since 11.1 - */ - protected $_parent = null; - - /** - * @var Array of Children - * @since 11.1 - */ - protected $_children = array(); - - /** - * Path from root to this category - * - * @var array - * @since 11.1 - */ - protected $_path = array(); - - /** - * Category left of this one - * - * @var integer - * @since 11.1 - */ - protected $_leftSibling = null; - - /** - * Category right of this one - * - * @var - * @since 11.1 - */ - protected $_rightSibling = null; - - /** - * true if all children have been loaded - * - * @var boolean - * @since 11.1 - */ - protected $_allChildrenloaded = false; - - /** - * Constructor of this tree - * - * @var - * @since 11.1 - */ - protected $_constructor = null; - - /** - * Class constructor - * - * @param array $category The category data. - * @param JCategoryNode &$constructor The tree constructor. - * - * @return JCategoryNode - * - * @since 11.1 - */ - public function __construct($category = null, &$constructor = null) - { - if ($category) - { - $this->setProperties($category); - if ($constructor) - { - $this->_constructor = &$constructor; - } - - return true; - } - - return false; - } - - /** - * Set the parent of this category - * - * If the category already has a parent, the link is unset - * - * @param mixed &$parent JCategoryNode for the parent to be set or null - * - * @return void - * - * @since 11.1 - */ - function setParent(&$parent) - { - if ($parent instanceof JCategoryNode || is_null($parent)) - { - if (!is_null($this->_parent)) - { - $key = array_search($this, $this->_parent->_children); - unset($this->_parent->_children[$key]); - } - - if (!is_null($parent)) - { - $parent->_children[] = & $this; - } - - $this->_parent = & $parent; - - if ($this->id != 'root') - { - if ($this->parent_id != 1) - { - $this->_path = $parent->getPath(); - } - $this->_path[] = $this->id . ':' . $this->alias; - } - - if (count($parent->_children) > 1) - { - end($parent->_children); - $this->_leftSibling = prev($parent->_children); - $this->_leftSibling->_rightsibling = &$this; - } - } - } - - /** - * Add child to this node - * - * If the child already has a parent, the link is unset - * - * @param JNode &$child The child to be added. - * - * @return void - * - * @since 11.1 - */ - function addChild(&$child) - { - if ($child instanceof JCategoryNode) - { - $child->setParent($this); - } - } - - /** - * Remove a specific child - * - * @param integer $id ID of a category - * - * @return void - * - * @since 11.1 - */ - function removeChild($id) - { - $key = array_search($this, $this->_parent->_children); - unset($this->_parent->_children[$key]); - } - - /** - * Get the children of this node - * - * @param boolean $recursive False by default - * - * @return array The children - * - * @since 11.1 - */ - function &getChildren($recursive = false) - { - if (!$this->_allChildrenloaded) - { - $temp = $this->_constructor->get($this->id, true); - if ($temp) - { - $this->_children = $temp->getChildren(); - $this->_leftSibling = $temp->getSibling(false); - $this->_rightSibling = $temp->getSibling(true); - $this->setAllLoaded(); - } - } - - if ($recursive) - { - $items = array(); - foreach ($this->_children as $child) - { - $items[] = $child; - $items = array_merge($items, $child->getChildren(true)); - } - return $items; - } - - return $this->_children; - } - - /** - * Get the parent of this node - * - * @return mixed JNode or null - * - * @since 11.1 - */ - function &getParent() - { - return $this->_parent; - } - - /** - * Test if this node has children - * - * @return boolean True if there is a child - * - * @since 11.1 - */ - function hasChildren() - { - return count($this->_children); - } - - /** - * Test if this node has a parent - * - * @return boolean True if there is a parent - * - * @since 11.1 - */ - function hasParent() - { - return $this->getParent() != null; - } - - /** - * Function to set the left or right sibling of a category - * - * @param object $sibling JCategoryNode object for the sibling - * @param boolean $right If set to false, the sibling is the left one - * - * @return void - * - * @since 11.1 - */ - function setSibling($sibling, $right = true) - { - if ($right) - { - $this->_rightSibling = $sibling; - } - else - { - $this->_leftSibling = $sibling; - } - } - - /** - * Returns the right or left sibling of a category - * - * @param boolean $right If set to false, returns the left sibling - * - * @return mixed JCategoryNode object with the sibling information or - * NULL if there is no sibling on that side. - * - * @since 11.1 - */ - function getSibling($right = true) - { - if (!$this->_allChildrenloaded) - { - $temp = $this->_constructor->get($this->id, true); - $this->_children = $temp->getChildren(); - $this->_leftSibling = $temp->getSibling(false); - $this->_rightSibling = $temp->getSibling(true); - $this->setAllLoaded(); - } - - if ($right) - { - return $this->_rightSibling; - } - else - { - return $this->_leftSibling; - } - } - - /** - * Returns the category parameters - * - * @return JRegistry - * - * @since 11.1 - */ - function getParams() - { - if (!($this->params instanceof JRegistry)) - { - $temp = new JRegistry; - $temp->loadString($this->params); - $this->params = $temp; - } - - return $this->params; - } - - /** - * Returns the category metadata - * - * @return JRegistry A JRegistry object containing the metadata - * - * @since 11.1 - */ - function getMetadata() - { - if (!($this->metadata instanceof JRegistry)) - { - $temp = new JRegistry; - $temp->loadString($this->metadata); - $this->metadata = $temp; - } - - return $this->metadata; - } - - /** - * Returns the category path to the root category - * - * @return array - * - * @since 11.1 - */ - function getPath() - { - return $this->_path; - } - - /** - * Returns the user that created the category - * - * @param boolean $modified_user Returns the modified_user when set to true - * - * @return JUser A JUser object containing a userid - * - * @since 11.1 - */ - function getAuthor($modified_user = false) - { - if ($modified_user) - { - return JFactory::getUser($this->modified_user_id); - } - - return JFactory::getUser($this->created_user_id); - } - - /** - * Set to load all children - * - * @return void - * - * @since 11.1 - */ - function setAllLoaded() - { - $this->_allChildrenloaded = true; - foreach ($this->_children as $child) - { - $child->setAllLoaded(); - } - } - - /** - * Returns the number of items. - * - * @param boolean $recursive If false number of children, if true number of descendants - * - * @return integer Number of children or descendants - * - * @since 11.1 - */ - function getNumItems($recursive = false) - { - if ($recursive) - { - $count = $this->numitems; - - foreach ($this->getChildren() as $child) - { - $count = $count + $child->getNumItems(true); - } - - return $count; - } - - return $this->numitems; - } -} diff --git a/platform/libraries/joomla/application/cli.php b/platform/libraries/joomla/application/cli.php deleted file mode 100644 index dddd8ed..0000000 --- a/platform/libraries/joomla/application/cli.php +++ /dev/null @@ -1,388 +0,0 @@ -close(); - } - // @codeCoverageIgnoreEnd - - // If a input object is given use it. - if ($input instanceof JInput) - { - $this->input = $input; - } - // Create the input based on the application logic. - else - { - if (class_exists('Jinput')) - { - $this->input = new JInputCLI; - } - } - - // If a config object is given use it. - if ($config instanceof JRegistry) - { - $this->config = $config; - } - // Instantiate a new configuration object. - else - { - $this->config = new JRegistry; - } - - // If a dispatcher object is given use it. - if ($dispatcher instanceof JDispatcher) - { - $this->dispatcher = $dispatcher; - } - // Create the dispatcher based on the application logic. - else - { - $this->loadDispatcher(); - } - - // Load the configuration object. - $this->loadConfiguration($this->fetchConfigurationData()); - - // Set the execution datetime and timestamp; - $this->set('execution.datetime', gmdate('Y-m-d H:i:s')); - $this->set('execution.timestamp', time()); - - // Set the current directory. - $this->set('cwd', getcwd()); - } - - /** - * Returns a property of the object or the default value if the property is not set. - * - * @param string $key The name of the property. - * @param mixed $default The default value (optional) if none is set. - * - * @return mixed The value of the configuration. - * - * @since 11.3 - */ - public function get($key, $default = null) - { - return $this->config->get($key, $default); - } - - /** - * Returns a reference to the global JCli object, only creating it if it doesn't already exist. - * - * This method must be invoked as: $cli = JCli::getInstance(); - * - * @param string $name The name (optional) of the JCli class to instantiate. - * - * @return JCli - * - * @since 11.1 - */ - public static function getInstance($name = null) - { - // Only create the object if it doesn't exist. - if (empty(self::$instance)) - { - if (class_exists($name) && (is_subclass_of($name, 'JCli'))) - { - self::$instance = new $name; - } - else - { - self::$instance = new JCli; - } - } - - return self::$instance; - } - - /** - * Execute the application. - * - * @return void - * - * @since 11.1 - */ - public function execute() - { - // Trigger the onBeforeExecute event. - $this->triggerEvent('onBeforeExecute'); - - // Perform application routines. - $this->doExecute(); - - // Trigger the onAfterExecute event. - $this->triggerEvent('onAfterExecute'); - } - - /** - * Method to run the application routines. Most likely you will want to instantiate a controller - * and execute it, or perform some sort of task directly. - * - * @return void - * - * @codeCoverageIgnore - * @since 11.3 - */ - protected function doExecute() - { - // Your application routines go here. - } - - /** - * Exit the application. - * - * @param integer $code The exit code (optional; default is 0). - * - * @return void - * - * @codeCoverageIgnore - * @since 11.1 - */ - public function close($code = 0) - { - exit($code); - } - - /** - * Load an object or array into the application configuration object. - * - * @param mixed $data Either an array or object to be loaded into the configuration object. - * - * @return JCli Instance of $this to allow chaining. - * - * @since 11.1 - */ - public function loadConfiguration($data) - { - // Load the data into the configuration object. - if (is_array($data)) - { - $this->config->loadArray($data); - } - elseif (is_object($data)) - { - $this->config->loadObject($data); - } - - return $this; - } - - /** - * Write a string to standard output. - * - * @param string $text The text to display. - * @param boolean $nl True (default) to append a new line at the end of the output string. - * - * @return JCli Instance of $this to allow chaining. - * - * @codeCoverageIgnore - * @since 11.1 - */ - public function out($text = '', $nl = true) - { - fwrite(STDOUT, $text . ($nl ? "\n" : null)); - - return $this; - } - - /** - * Get a value from standard input. - * - * @return string The input string from standard input. - * - * @codeCoverageIgnore - * @since 11.1 - */ - public function in() - { - return rtrim(fread(STDIN, 8192), "\n"); - } - - /** - * Registers a handler to a particular event group. - * - * @param string $event The event name. - * @param callback $handler The handler, a function or an instance of a event object. - * - * @return JCli Instance of $this to allow chaining. - * - * @since 11.1 - */ - public function registerEvent($event, $handler) - { - if ($this->dispatcher instanceof JDispatcher) - { - $this->dispatcher->register($event, $handler); - } - - return $this; - } - - /** - * Calls all handlers associated with an event group. - * - * @param string $event The event name. - * @param array $args An array of arguments (optional). - * - * @return array An array of results from each function call, or null if no dispatcher is defined. - * - * @since 11.1 - */ - public function triggerEvent($event, $args = null) - { - if ($this->dispatcher instanceof JDispatcher) - { - return $this->dispatcher->trigger($event, $args); - } - - return null; - } - - /** - * Modifies a property of the object, creating it if it does not already exist. - * - * @param string $key The name of the property. - * @param mixed $value The value of the property to set (optional). - * - * @return mixed Previous value of the property - * - * @since 11.3 - */ - public function set($key, $value = null) - { - $previous = $this->config->get($key); - $this->config->set($key, $value); - - return $previous; - } - - /** - * Method to load a PHP configuration class file based on convention and return the instantiated data object. You - * will extend this method in child classes to provide configuration data from whatever data source is relevant - * for your specific application. - * - * @param string $fileName The name of the configuration file (default is 'configuration'). - * Note that .php is appended to this name - * - * @return mixed Either an array or object to be loaded into the configuration object. - * - * @since 11.1 - */ - protected function fetchConfigurationData($fileName = 'configuration') - { - // Instantiate variables. - $config = array(); - - if (empty($fileName)) - { - $fileName = 'configuration'; - } - - // Handle the convention-based default case for configuration file. - if (defined('JPATH_BASE')) - { - // Set the configuration file name and check to see if it exists. - $file = JPATH_BASE . '/' . preg_replace('#[^A-Z0-9-_.]#i', '', $fileName) . '.php'; - if (is_file($file)) - { - // Import the configuration file. - include_once $file; - - // Instantiate the configuration object if it exists. - if (class_exists('JConfig')) - { - $config = new JConfig; - } - } - } - - return $config; - } - - /** - * Method to create an event dispatcher for the application. The logic and options for creating - * this object are adequately generic for default cases but for many applications it will make sense - * to override this method and create event dispatchers based on more specific needs. - * - * @return void - * - * @since 11.3 - */ - protected function loadDispatcher() - { - $this->dispatcher = JDispatcher::getInstance(); - } -} diff --git a/platform/libraries/joomla/application/cli/daemon.php b/platform/libraries/joomla/application/cli/daemon.php deleted file mode 100644 index e63213e..0000000 --- a/platform/libraries/joomla/application/cli/daemon.php +++ /dev/null @@ -1,821 +0,0 @@ -config->get('max_execution_time', 0)); - if ($this->config->get('max_memory_limit') !== null) - { - ini_set('memory_limit', $this->config->get('max_memory_limit', '256M')); - } - - // Flush content immediatly. - ob_implicit_flush(); - } - - /** - * Method to handle POSIX signals. - * - * @param integer $signal The recieved POSIX signal. - * - * @return void - * - * @since 11.1 - * @see pcntl_signal() - */ - public static function signal($signal) - { - // Log all signals sent to the daemon. - JLog::add('Received signal: ' . $signal, JLog::DEBUG); - - // Let's make sure we have an application instance. - if (!is_subclass_of(static::$instance, 'JDaemon')) - { - JLog::add('Cannot find the application instance.', JLog::EMERGENCY); - throw new ApplicationException; - } - - // Fire the onRecieveSignal event. - static::$instance->triggerEvent('onRecieveSignal', array($signal)); - - switch ($signal) - { - case SIGTERM: - // Handle shutdown tasks - if (static::$instance->running && static::$instance->isActive()) - { - static::$instance->shutdown(); - } - else - { - static::$instance->close(); - } - break; - case SIGHUP: - // Handle restart tasks - if (static::$instance->running && static::$instance->isActive()) - { - static::$instance->shutdown(true); - } - else - { - static::$instance->close(); - } - break; - case SIGCHLD: - // A child process has died - while (static::$instance->pcntlWait($signal, WNOHANG or WUNTRACED) > 0) - { - usleep(1000); - } - break; - case SIGCLD: - while (($pid = static::$instance->pcntlWait($signal, WNOHANG)) > 0) - { - $signal = static::$instance->pcntlChildExitStatus($signal); - } - break; - default: - break; - } - } - - /** - * Check to see if the daemon is active. This does not assume that $this daemon is active, but - * only if an instance of the application is active as a daemon. - * - * @return boolean True if daemon is active. - * - * @since 11.1 - */ - public function isActive() - { - // Get the process id file location for the application. - $pidFile = $this->config->get('application_pid_file'); - - // If the process id file doesn't exist then the daemon is obviously not running. - if (!is_file($pidFile)) - { - return false; - } - - // Read the contents of the process id file as an integer. - $fp = fopen($pidFile, 'r'); - $pid = fread($fp, filesize($pidFile)); - $pid = intval($pid); - fclose($fp); - - // Check to make sure that the process id exists as a positive integer. - if (!$pid) - { - return false; - } - - // Check to make sure the process is active by pinging it and ensure it responds. - if (!posix_kill($pid, 0)) - { - - // No response so remove the process id file and log the situation. - @ unlink($pidFile); - JLog::add('The process found based on PID file was unresponsive.', JLog::WARNING); - - return false; - } - - return true; - } - - /** - * Load an object or array into the application configuration object. - * - * @param mixed $data Either an array or object to be loaded into the configuration object. - * - * @return JCli Instance of $this to allow chaining. - * - * @since 11.1 - */ - public function loadConfiguration($data) - { - // Execute the parent load method. - parent::loadConfiguration($data); - - /* - * Setup some application metadata options. This is useful if we ever want to write out startup scripts - * or just have some sort of information available to share about things. - */ - - // The application author name. This string is used in generating startup scripts and has - // a maximum of 50 characters. - $tmp = (string) $this->config->get('author_name', 'Joomla Platform'); - $this->config->set('author_name', (strlen($tmp) > 50) ? substr($tmp, 0, 50) : $tmp); - - // The application author email. This string is used in generating startup scripts. - $tmp = (string) $this->config->get('author_email', 'admin@joomla.org'); - $this->config->set('author_email', filter_var($tmp, FILTER_VALIDATE_EMAIL)); - - // The application name. This string is used in generating startup scripts. - $tmp = (string) $this->config->get('application_name', 'JDaemon'); - $this->config->set('application_name', (string) preg_replace('/[^A-Z0-9_-]/i', '', $tmp)); - - // The application description. This string is used in generating startup scripts. - $tmp = (string) $this->config->get('application_description', 'A generic Joomla Platform application.'); - $this->config->set('application_description', filter_var($tmp, FILTER_SANITIZE_STRING)); - - /* - * Setup the application path options. This defines the default executable name, executable directory, - * and also the path to the daemon process id file. - */ - - // The application executable daemon. This string is used in generating startup scripts. - $tmp = (string) $this->config->get('application_executable', basename($this->input->executable)); - $this->config->set('application_executable', $tmp); - - // The home directory of the daemon. - $tmp = (string) $this->config->get('application_directory', dirname($this->input->executable)); - $this->config->set('application_directory', $tmp); - - // The pid file location. This defaults to a path inside the /tmp directory. - $name = $this->config->get('application_name'); - $tmp = (string) $this->config->get('application_pid_file', strtolower('/tmp/' . $name . '/' . $name . '.pid')); - $this->config->set('application_pid_file', $tmp); - - /* - * Setup the application identity options. It is important to remember if the default of 0 is set for - * either UID or GID then changing that setting will not be attempted as there is no real way to "change" - * the identity of a process from some user to root. - */ - - // The user id under which to run the daemon. - $tmp = (int) $this->config->get('application_uid', 0); - $options = array('options' => array('min_range' => 0, 'max_range' => 65000)); - $this->config->set('application_uid', filter_var($tmp, FILTER_VALIDATE_INT, $options)); - - // The group id under which to run the daemon. - $tmp = (int) $this->config->get('application_gid', 0); - $options = array('options' => array('min_range' => 0, 'max_range' => 65000)); - $this->config->set('application_gid', filter_var($tmp, FILTER_VALIDATE_INT, $options)); - - // Option to kill the daemon if it cannot switch to the chosen identity. - $tmp = (bool) $this->config->get('application_require_identity', 1); - $this->config->set('application_require_identity', $tmp); - - /* - * Setup the application runtime options. By default our execution time limit is infinite obviously - * because a daemon should be constantly running unless told otherwise. The default limit for memory - * usage is 128M, which admittedly is a little high, but remember it is a "limit" and PHP's memory - * management leaves a bit to be desired :-) - */ - - // The maximum execution time of the application in seconds. Zero is infinite. - $tmp = $this->config->get('max_execution_time'); - if ($tmp !== null) - { - $this->config->set('max_execution_time', (int) $tmp); - } - - // The maximum amount of memory the application can use. - $tmp = $this->config->get('max_memory_limit', '256M'); - if ($tmp !== null) - { - $this->config->set('max_memory_limit', (string) $tmp); - } - - return $this; - } - - /** - * Restart daemon process. - * - * @return void - * - * @codeCoverageIgnore - * @since 11.1 - */ - public function restart() - { - JLog::add('Stopping ' . $this->name, JLog::INFO); - $this->shutdown(true); - } - - /** - * Spawn daemon process. - * - * @return boolean True if successfully spawned - * - * @since 11.1 - */ - public function start() - { - // Enable basic garbage collection. Only available in PHP 5.3+ - if (function_exists('gc_enable')) - { - gc_enable(); - } - - JLog::add('Starting ' . $this->name, JLog::INFO); - - // Set off the process for becoming a daemon. - if ($this->daemonize()) - { - - // Daemonization succeeded (is that a word?), so now we start our main execution loop. - while (true) - { - // Perform basic garbage collection. - $this->gc(); - - // Don't completely overload the CPU. - usleep(1000); - - // Execute the main application logic. - $this->doExecute(); - } - } - // We were not able to daemonize the application so log the failure and die gracefully. - else - { - JLog::add('Starting ' . $this->name . ' failed', JLog::INFO); - } - } - - /** - * Stop daemon process. - * - * @return void - * - * @codeCoverageIgnore - * @since 11.1 - */ - public function stop() - { - JLog::add('Stopping ' . $this->name, JLog::INFO); - $this->shutdown(); - } - - /** - * Method to change the identity of the daemon process and resources. - * - * @return boolean True if identity successfully changed - * - * @since 11.1 - * @see posix_setuid() - */ - protected function changeIdentity() - { - // Get the group and user ids to set for the daemon. - $uid = (int) $this->config->get('application_uid', 0); - $gid = (int) $this->config->get('application_gid', 0); - - // Get the application process id file path. - $file = $this->config->get('application_pid_file'); - - // Change the user id for the process id file if necessary. - if ($uid && (fileowner($file) != $uid) && (!@ chown($file, $uid))) - { - JLog::add('Unable to change user ownership of the proccess id file.', JLog::ERROR); - return false; - } - - // Change the group id for the process id file if necessary. - if ($gid && (filegroup($file) != $gid) && (!@ chgrp($file, $gid))) - { - JLog::add('Unable to change group ownership of the proccess id file.', JLog::ERROR); - return false; - } - - // Set the correct home directory for the process. - if ($uid && ($info = posix_getpwuid($uid)) && is_dir($info['dir'])) - { - system('export HOME="' . $info['dir'] . '"'); - } - - // Change the user id for the process necessary. - if ($uid && (posix_getuid($file) != $uid) && (!@ posix_setuid($uid))) - { - JLog::add('Unable to change user ownership of the proccess.', JLog::ERROR); - return false; - } - - // Change the group id for the process necessary. - if ($gid && (posix_getgid($file) != $gid) && (!@ posix_setgid($gid))) - { - JLog::add('Unable to change group ownership of the proccess.', JLog::ERROR); - return false; - } - - // Get the user and group information based on uid and gid. - $user = posix_getpwuid($uid); - $group = posix_getgrgid($gid); - - JLog::add('Changed daemon identity to ' . $user['name'] . ':' . $group['name'], JLog::INFO); - - return true; - } - - /** - * Method to put the application into the background. - * - * @return boolean - * - * @since 11.1 - * @throws ApplicationException - */ - protected function daemonize() - { - // Is there already an active daemon running? - if ($this->isActive()) - { - JLog::add($this->name . ' daemon is still running. Exiting the application.', JLog::EMERGENCY); - return false; - } - - // Reset Process Information - $this->safeMode = !!@ ini_get('safe_mode'); - $this->processId = 0; - $this->running = false; - - // Fork process! - try - { - $this->fork(); - } - catch (ApplicationException $e) - { - JLog::add('Unable to fork.', JLog::EMERGENCY); - return false; - } - - // Verify the process id is valid. - if ($this->processId < 1) - { - JLog::add('The process id is invalid; the fork failed.', JLog::EMERGENCY); - return false; - } - - // Clear the umask. - @ umask(0); - - // Write out the process id file for concurrency management. - if (!$this->writeProcessIdFile()) - { - JLog::add('Unable to write the pid file at: ' . $this->config->get('application_pid_file'), JLog::EMERGENCY); - return false; - } - - // Attempt to change the identity of user running the process. - if (!$this->changeIdentity()) - { - - // If the identity change was required then we need to return false. - if ($this->config->get('application_require_identity')) - { - JLog::add('Unable to change process owner.', JLog::CRITICAL); - return false; - } - else - { - JLog::add('Unable to change process owner.', JLog::WARNING); - } - } - - // Setup the signal handlers for the daemon. - if (!$this->setupSignalHandlers()) - { - return false; - } - - // Change the current working directory to the application working directory. - @ chdir($this->config->get('application_directory')); - - return true; - } - - /** - * This is truly where the magic happens. This is where we fork the process and kill the parent - * process, which is essentially what turns the application into a daemon. - * - * @return void - * - * @since 11.1 - * @throws ApplicationException - */ - protected function fork() - { - JLog::add('Forking the ' . $this->name . ' daemon.', JLog::DEBUG); - - // Attempt to fork the process. - $pid = $this->pcntlFork(); - - // If we could not fork the process log the error and throw an exception. - if ($pid === -1) - { - // Error - JLog::add('Process could not be forked.', JLog::WARNING); - throw new ApplicationException; - } - // If the pid is positive then we successfully forked, and can close this application. - elseif ($pid) - { - - // Add the log entry for debugging purposes and exit gracefully. - JLog::add('Ending ' . $this->name . ' parent process', JLog::DEBUG); - $this->close(); - } - // We are in the forked child process. - else - { - - // Setup some protected values. - $this->exiting = false; - $this->running = true; - $this->processId = (int) posix_getpid(); - } - } - - /** - * Method to perform basic garbage collection and memory management in the sense of clearing the - * stat cache. We will probably call this method pretty regularly in our main loop. - * - * @return void - * - * @codeCoverageIgnore - * @since 11.1 - */ - protected function gc() - { - // Perform generic garbage collection. Only available in PHP 5.3+ - if (function_exists('gc_collect_cycles')) - { - gc_collect_cycles(); - } - - // Clear the stat cache so it doesn't blow up memory. - clearstatcache(); - } - - /** - * Method to attach the JDaemon signal handler to the known signals. Applications can override - * these handlers by using the pcntl_signal() function and attaching a different callback method. - * - * @return boolean - * - * @since 11.1 - * @see pcntl_signal() - */ - protected function setupSignalHandlers() - { - // We add the error suppression for the loop because on some platforms some constants are not defined. - foreach (self::$signals as $signal) - { - // Ignore signals that are not defined. - if (!defined($signal) || !is_int(constant($signal)) || (constant($signal) === 0)) - { - continue; - } - - // Attach the signal handler for the signal. - if (!$this->pcntlSignal(constant($signal), array('JDaemon', 'signal'))) - { - JLog::add(sprintf('Unable to reroute signal handler: %s', $signal), JLog::EMERGENCY); - return false; - } - } - - return true; - } - - /** - * Method to shut down the daemon and optionally restart it. - * - * @param boolean $restart True to restart the daemon on exit. - * - * @return void - * - * @since 11.1 - */ - protected function shutdown($restart = false) - { - // If we are already exiting, chill. - if ($this->exiting) - { - return; - } - // If not, now we are. - else - { - $this->exiting = true; - } - - // If we aren't already daemonized then just kill the application. - if ($this->running && $this->isActive()) - { - JLog::add('Process was not daemonized yet, just halting current process', JLog::INFO); - $this->close(); - } - - // Read the contents of the process id file as an integer. - $fp = fopen($this->config->get('application_pid_file'), 'r'); - $pid = fread($fp, filesize($this->config->get('application_pid_file'))); - $pid = intval($pid); - fclose($fp); - - // Remove the process id file. - @ unlink($this->config->get('application_pid_file')); - - // If we are supposed to restart the daemon we need to execute the same command. - if ($restart) - { - $this->close(exec(implode(' ', $GLOBALS['argv']) . ' > /dev/null &')); - } - // If we are not supposed to restart the daemon let's just kill -9. - else - { - passthru('kill -9 ' . $pid); - $this->close(); - } - } - - /** - * Method to write the process id file out to disk. - * - * @return boolean - * - * @since 11.1 - */ - protected function writeProcessIdFile() - { - // Verify the process id is valid. - if ($this->processId < 1) - { - JLog::add('The process id is invalid.', JLog::EMERGENCY); - return false; - } - - // Get the application process id file path. - $file = $this->config->get('application_pid_file'); - if (empty($file)) - { - JLog::add('The process id file path is empty.', JLog::ERROR); - return false; - } - - // Make sure that the folder where we are writing the process id file exists. - $folder = dirname($file); - if (!is_dir($folder) && !JFolder::create($folder)) - { - JLog::add('Unable to create directory: ' . $folder, JLog::ERROR); - return false; - } - - // Write the process id file out to disk. - if (!file_put_contents($file, $this->processId)) - { - JLog::add('Unable to write proccess id file: ' . $file, JLog::ERROR); - return false; - } - - // Make sure the permissions for the proccess id file are accurate. - if (!chmod($file, 0644)) - { - JLog::add('Unable to adjust permissions for the proccess id file: ' . $file, JLog::ERROR); - return false; - } - - return true; - } - - /** - * Method to return the exit code of a terminated child process. - * - * @param integer $status The status parameter is the status parameter supplied to a successful call to pcntl_waitpid(). - * - * @return integer The child process exit code. - * - * @codeCoverageIgnore - * @see pcntl_wexitstatus() - * @since 11.3 - */ - protected function pcntlChildExitStatus($status) - { - return pcntl_wexitstatus($status); - } - - /** - * Method to return the exit code of a terminated child process. - * - * @return integer On success, the PID of the child process is returned in the parent's thread - * of execution, and a 0 is returned in the child's thread of execution. On - * failure, a -1 will be returned in the parent's context, no child process - * will be created, and a PHP error is raised. - * - * @codeCoverageIgnore - * @see pcntl_fork() - * @since 11.3 - */ - protected function pcntlFork() - { - return pcntl_fork(); - } - - /** - * Method to install a signal handler. - * - * @param integer $signal The signal number. - * @param callback $handler The signal handler which may be the name of a user created function, - * or method, or either of the two global constants SIG_IGN or SIG_DFL. - * @param boolean $restart Specifies whether system call restarting should be used when this - * signal arrives. - * - * @return boolean True on success. - * - * @codeCoverageIgnore - * @see pcntl_signal() - * @since 11.3 - */ - protected function pcntlSignal($signal , $handler, $restart = true) - { - return pcntl_signal($signal, $handler, $restart); - } - - /** - * Method to wait on or return the status of a forked child. - * - * @param integer &$status Status information. - * @param integer $options If wait3 is available on your system (mostly BSD-style systems), - * you can provide the optional options parameter. - * - * @return integer The process ID of the child which exited, -1 on error or zero if WNOHANG - * was provided as an option (on wait3-available systems) and no child was available. - * - * @codeCoverageIgnore - * @see pcntl_wait() - * @since 11.3 - */ - protected function pcntlWait(&$status, $options = 0) - { - return pcntl_wait($status, $options); - } -} diff --git a/platform/libraries/joomla/application/component/controller.php b/platform/libraries/joomla/application/component/controller.php deleted file mode 100644 index 8351e97..0000000 --- a/platform/libraries/joomla/application/component/controller.php +++ /dev/null @@ -1,1139 +0,0 @@ -clean(array_pop(array_keys($command)), 'cmd'); - } - else - { - $command = $filter->clean($command, 'cmd'); - } - - // Check for a controller.task command. - if (strpos($command, '.') !== false) - { - // Explode the controller.task command. - list ($type, $task) = explode('.', $command); - - // Define the controller filename and path. - $file = self::createFileName('controller', array('name' => $type, 'format' => $format)); - $path = $basePath . '/controllers/' . $file; - - // Reset the task without the contoller context. - JRequest::setVar('task', $task); - } - else - { - // Base controller. - $type = null; - $task = $command; - - // Define the controller filename and path. - $file = self::createFileName('controller', array('name' => 'controller', 'format' => $format)); - $path = $basePath . '/' . $file; - } - - // Get the controller class name. - $class = ucfirst($prefix) . 'Controller' . ucfirst($type); - - // Include the class if not present. - if (!class_exists($class)) - { - // If the controller file path exists, include it. - if (file_exists($path)) - { - require_once $path; - } - else - { - throw new JException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER', $type, $format), 1056, E_ERROR, $type, true); - } - } - - // Instantiate the class. - if (class_exists($class)) - { - $instance = new $class($config); - } - else - { - throw new JException(JText::sprintf('JLIB_APPLICATION_ERROR_INVALID_CONTROLLER_CLASS', $class), 1057, E_ERROR, $class, true); - } - - return $instance; - } - - /** - * Constructor. - * - * @param array $config An optional associative array of configuration settings. - * Recognized key values include 'name', 'default_task', 'model_path', and - * 'view_path' (this list is not meant to be comprehensive). - * - * @return JController - * - * @since 11.1 - */ - public function __construct($config = array()) - { - // Initialise variables. - $this->methods = array(); - $this->message = null; - $this->messageType = 'message'; - $this->paths = array(); - $this->redirect = null; - $this->taskMap = array(); - - // Determine the methods to exclude from the base class. - $xMethods = get_class_methods('JController'); - - // Get the public methods in this class using reflection. - $r = new ReflectionClass($this); - $rName = $r->getName(); - $rMethods = $r->getMethods(ReflectionMethod::IS_PUBLIC); - $methods = array(); - - foreach ($rMethods as $rMethod) - { - $mName = $rMethod->getName(); - - // Add default display method if not explicitly declared. - if (!in_array($mName, $xMethods) || $mName == 'display') - { - $this->methods[] = strtolower($mName); - // Auto register the methods as tasks. - $this->taskMap[strtolower($mName)] = $mName; - } - } - - //set the view name - if (empty($this->name)) - { - if (array_key_exists('name', $config)) - { - $this->name = $config['name']; - } - else - { - $this->name = $this->getName(); - } - } - - // Set a base path for use by the controller - if (array_key_exists('base_path', $config)) - { - $this->basePath = $config['base_path']; - } - else - { - $this->basePath = JPATH_COMPONENT; - } - - // If the default task is set, register it as such - if (array_key_exists('default_task', $config)) - { - $this->registerDefaultTask($config['default_task']); - } - else - { - $this->registerDefaultTask('display'); - } - - // Set the models prefix - if (empty($this->model_prefix)) - { - if (array_key_exists('model_prefix', $config)) - { - // User-defined prefix - $this->model_prefix = $config['model_prefix']; - } - else - { - $this->model_prefix = $this->name . 'Model'; - } - } - - // Set the default model search path - if (array_key_exists('model_path', $config)) - { - // user-defined dirs - $this->addModelPath($config['model_path'], $this->model_prefix); - } - else - { - $this->addModelPath($this->basePath . '/models', $this->model_prefix); - } - - // Set the default view search path - if (array_key_exists('view_path', $config)) - { - // User-defined dirs - $this->setPath('view', $config['view_path']); - } - else - { - $this->setPath('view', $this->basePath . '/views'); - } - - // Set the default view. - if (array_key_exists('default_view', $config)) - { - $this->default_view = $config['default_view']; - } - elseif (empty($this->default_view)) - { - $this->default_view = $this->getName(); - } - - } - - /** - * Adds to the search path for templates and resources. - * - * @param string $type The path type (e.g. 'model', 'view'). - * @param mixed $path The directory string or stream array to search. - * - * @return JController A JController object to support chaining. - * - * @since 11.1 - * @note Replaces _addPath. - */ - protected function addPath($type, $path) - { - // Just force path to array - settype($path, 'array'); - - if (!isset($this->paths[$type])) - { - $this->paths[$type] = array(); - } - - // Loop through the path directories - foreach ($path as $dir) - { - // No surrounding spaces allowed! - $dir = rtrim(JPath::check($dir, '/'), '/') . '/'; - - // Add to the top of the search dirs - array_unshift($this->paths[$type], $dir); - } - - return $this; - } - - /** - * Add one or more view paths to the controller's stack, in LIFO order. - * - * @param mixed $path The directory (string) or list of directories (array) to add. - * - * @return JController This object to support chaining. - */ - public function addViewPath($path) - { - $this->addPath('view', $path); - - return $this; - } - - /** - * Authorisation check - * - * @param string $task The ACO Section Value to check access on - * - * @return boolean True if authorised - * - * @since 11.1 - * - * @deprecated 12.1 Use JAuthorise - */ - public function authorize($task) - { - // Deprecation warning. - JLog::add('JController::authorize() is deprecated.', JLog::WARNING, 'deprecated'); - - $this->authorise($task); - } - - /** - * Authorisation check - * - * @param string $task The ACO Section Value to check access on. - * - * @return boolean True if authorised - * - * @since 11.1 - */ - public function authorise($task) - { - // Only do access check if the aco section is set - if ($this->_acoSection) - { - // If we have a section value set that trumps the passed task. - if ($this->_acoSectionValue) - { - // We have one, so set it and lets do the check - $task = $this->_acoSectionValue; - } - // Get the JUser object for the current user and return the authorization boolean - $user = JFactory::getUser(); - - return $user->authorise($this->_acoSection, $task); - } - else - { - // Nothing set, nothing to check... so obviously it's ok :) - return true; - } - } - - /** - * Method to check whether an ID is in the edit list. - * - * @param string $context The context for the session storage. - * @param integer $id The ID of the record to add to the edit list. - * - * @return boolean True if the ID is in the edit list. - * - * @since 11.1 - */ - protected function checkEditId($context, $id) - { - if ($id) - { - $app = JFactory::getApplication(); - $values = (array) $app->getUserState($context . '.id'); - - $result = in_array((int) $id, $values); - - if (JDEBUG) - { - jimport('joomla.error.log'); - $log = JLog::getInstance('jcontroller.log.php')->addEntry( - array( - 'comment' => sprintf( - 'Checking edit ID %s.%s: %d %s', - $context, - $id, - (int) $result, - str_replace("\n", ' ', print_r($values, 1)) - ) - ) - ); - } - - return $result; - } - else - { - // No id for a new item. - return true; - } - } - - /** - * Method to load and return a model object. - * - * @param string $name The name of the model. - * @param string $prefix Optional model prefix. - * @param array $config Configuration array for the model. Optional. - * - * @return mixed Model object on success; otherwise null failure. - * - * @since 11.1 - * @note Replaces _createModel. - */ - protected function createModel($name, $prefix = '', $config = array()) - { - // Clean the model name - $modelName = preg_replace('/[^A-Z0-9_]/i', '', $name); - $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); - - $result = JModel::getInstance($modelName, $classPrefix, $config); - - return $result; - } - - /** - * Method to load and return a view object. This method first looks in the - * current template directory for a match and, failing that, uses a default - * set path to load the view class file. - * - * Note the "name, prefix, type" order of parameters, which differs from the - * "name, type, prefix" order used in related public methods. - * - * @param string $name The name of the view. - * @param string $prefix Optional prefix for the view class name. - * @param string $type The type of view. - * @param array $config Configuration array for the view. Optional. - * - * @return mixed View object on success; null or error result on failure. - * - * @since 11.1 - * @note Replaces _createView. - */ - protected function createView($name, $prefix = '', $type = '', $config = array()) - { - // Clean the view name - $viewName = preg_replace('/[^A-Z0-9_]/i', '', $name); - $classPrefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); - $viewType = preg_replace('/[^A-Z0-9_]/i', '', $type); - - // Build the view class name - $viewClass = $classPrefix . $viewName; - - if (!class_exists($viewClass)) - { - jimport('joomla.filesystem.path'); - $path = JPath::find($this->paths['view'], $this->createFileName('view', array('name' => $viewName, 'type' => $viewType))); - - if ($path) - { - require_once $path; - - if (!class_exists($viewClass)) - { - $result = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_CLASS_NOT_FOUND', $viewClass, $path)); - - return null; - } - } - else - { - return null; - } - } - - return new $viewClass($config); - } - - /** - * Typical view method for MVC based architecture - * - * This function is provide as a default implementation, in most cases - * you will need to override it in your own controllers. - * - * @param boolean $cachable If true, the view output will be cached - * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. - * - * @return JController A JController object to support chaining. - * - * @since 11.1 - */ - public function display($cachable = false, $urlparams = false) - { - $document = JFactory::getDocument(); - $viewType = $document->getType(); - $viewName = JRequest::getCmd('view', $this->default_view); - $viewLayout = JRequest::getCmd('layout', 'default'); - - $view = $this->getView($viewName, $viewType, '', array('base_path' => $this->basePath)); - - // Get/Create the model - if ($model = $this->getModel($viewName)) - { - // Push the model into the view (as default) - $view->setModel($model, true); - } - - // Set the layout - $view->setLayout($viewLayout); - - $view->assignRef('document', $document); - - $conf = JFactory::getConfig(); - - // Display the view - if ($cachable && $viewType != 'feed' && $conf->get('caching') >= 1) - { - $option = JRequest::getCmd('option'); - $cache = JFactory::getCache($option, 'view'); - - if (is_array($urlparams)) - { - $app = JFactory::getApplication(); - - $registeredurlparams = $app->get('registeredurlparams'); - - if (empty($registeredurlparams)) - { - $registeredurlparams = new stdClass; - } - - foreach ($urlparams as $key => $value) - { - // Add your safe url parameters with variable type as value {@see JFilterInput::clean()}. - $registeredurlparams->$key = $value; - } - - $app->set('registeredurlparams', $registeredurlparams); - } - - $cache->get($view, 'display'); - - } - else - { - $view->display(); - } - - return $this; - } - - /** - * Execute a task by triggering a method in the derived class. - * - * @param string $task The task to perform. If no matching task is found, the '__default' task is executed, if defined. - * - * @return mixed The value returned by the called method, false in error case. - * - * @since 11.1 - */ - public function execute($task) - { - $this->task = $task; - - $task = strtolower($task); - if (isset($this->taskMap[$task])) - { - $doTask = $this->taskMap[$task]; - } - elseif (isset($this->taskMap['__default'])) - { - $doTask = $this->taskMap['__default']; - } - else - { - return JError::raiseError(404, JText::sprintf('JLIB_APPLICATION_ERROR_TASK_NOT_FOUND', $task)); - } - - // Record the actual task being fired - $this->doTask = $doTask; - - // Make sure we have access - if ($this->authorise($doTask)) - { - $retval = $this->$doTask(); - return $retval; - } - else - { - return JError::raiseError(403, JText::_('JLIB_APPLICATION_ERROR_ACCESS_FORBIDDEN')); - } - } - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return object The model. - * - * @since 11.1 - */ - public function getModel($name = '', $prefix = '', $config = array()) - { - if (empty($name)) - { - $name = $this->getName(); - } - - if (empty($prefix)) - { - $prefix = $this->model_prefix; - } - - if ($model = $this->createModel($name, $prefix, $config)) - { - // Task is a reserved state - $model->setState('task', $this->task); - - // Let's get the application object and set menu information if it's available - $app = JFactory::getApplication(); - $menu = $app->getMenu(); - - if (is_object($menu)) - { - if ($item = $menu->getActive()) - { - $params = $menu->getParams($item->id); - // Set default state data - $model->setState('parameters.menu', $params); - } - } - } - return $model; - } - - /** - * Method to get the controller name - * - * The dispatcher name is set by default parsed using the classname, or it can be set - * by passing a $config['name'] in the class constructor - * - * @return string The name of the dispatcher - * - * @since 11.1 - */ - public function getName() - { - $name = $this->name; - - if (empty($name)) - { - $r = null; - if (!preg_match('/(.*)Controller/i', get_class($this), $r)) - { - JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME')); - } - $name = strtolower($r[1]); - } - - return $name; - } - - /** - * Get the last task that is being performed or was most recently performed. - * - * @return string The task that is being performed or was most recently performed. - * - * @since 11.1 - */ - public function getTask() - { - return $this->task; - } - - /** - * Gets the available tasks in the controller. - * - * @return array Array[i] of task names. - * - * @since 11.1 - */ - public function getTasks() - { - return $this->methods; - } - - /** - * Method to get a reference to the current view and load it if necessary. - * - * @param string $name The view name. Optional, defaults to the controller name. - * @param string $type The view type. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for view. Optional. - * - * @return object Reference to the view or an error. - * - * @since 11.1 - */ - public function getView($name = '', $type = '', $prefix = '', $config = array()) - { - static $views; - - if (!isset($views)) - { - $views = array(); - } - - if (empty($name)) - { - $name = $this->getName(); - } - - if (empty($prefix)) - { - $prefix = $this->getName() . 'View'; - } - - if (empty($views[$name])) - { - if ($view = $this->createView($name, $prefix, $type, $config)) - { - $views[$name] = & $view; - } - else - { - $result = JError::raiseError(500, JText::sprintf('JLIB_APPLICATION_ERROR_VIEW_NOT_FOUND', $name, $type, $prefix)); - - return $result; - } - } - - return $views[$name]; - } - - /** - * Method to add a record ID to the edit list. - * - * @param string $context The context for the session storage. - * @param integer $id The ID of the record to add to the edit list. - * - * @return void - * - * @since 11.1 - */ - protected function holdEditId($context, $id) - { - // Initialise variables. - $app = JFactory::getApplication(); - $values = (array) $app->getUserState($context . '.id'); - - // Add the id to the list if non-zero. - if (!empty($id)) - { - array_push($values, (int) $id); - $values = array_unique($values); - $app->setUserState($context . '.id', $values); - - if (JDEBUG) - { - jimport('joomla.error.log'); - $log = JLog::getInstance('jcontroller.log.php')->addEntry( - array( - 'comment' => sprintf('Holding edit ID %s.%s %s', $context, $id, str_replace("\n", ' ', print_r($values, 1))) - ) - ); - } - } - } - - /** - * Redirects the browser or returns false if no redirect is set. - * - * @return boolean False if no redirect exists. - * - * @since 11.1 - */ - public function redirect() - { - if ($this->redirect) - { - $app = JFactory::getApplication(); - $app->redirect($this->redirect, $this->message, $this->messageType); - } - - return false; - } - - /** - * Register the default task to perform if a mapping is not found. - * - * @param string $method The name of the method in the derived class to perform if a named task is not found. - * - * @return JController A JController object to support chaining. - * - * @since 11.1 - */ - public function registerDefaultTask($method) - { - $this->registerTask('__default', $method); - - return $this; - } - - /** - * Register (map) a task to a method in the class. - * - * @param string $task The task. - * @param string $method The name of the method in the derived class to perform for this task. - * - * @return JController A JController object to support chaining. - * - * @since 11.1 - */ - public function registerTask($task, $method) - { - if (in_array(strtolower($method), $this->methods)) - { - $this->taskMap[strtolower($task)] = $method; - } - - return $this; - } - - /** - * Unregister (unmap) a task in the class. - * - * @param string $task The task. - * - * @return JController This object to support chaining. - * - * @since 11.1 - */ - public function unregisterTask($task) - { - unset($this->taskMap[strtolower($task)]); - - return $this; - } - - /** - * Method to check whether an ID is in the edit list. - * - * @param string $context The context for the session storage. - * @param integer $id The ID of the record to add to the edit list. - * - * @return void - * - * @since 11.1 - */ - protected function releaseEditId($context, $id) - { - $app = JFactory::getApplication(); - $values = (array) $app->getUserState($context . '.id'); - - // Do a strict search of the edit list values. - $index = array_search((int) $id, $values, true); - - if (is_int($index)) - { - unset($values[$index]); - $app->setUserState($context . '.id', $values); - - if (JDEBUG) - { - jimport('joomla.error.log'); - $log = JLog::getInstance('jcontroller.log.php')->addEntry( - array( - 'comment' => sprintf('Releasing edit ID %s.%s %s', $context, $id, str_replace("\n", ' ', print_r($values, 1))) - ) - ); - } - } - } - - /** - * Sets the access control levels. - * - * @param string $section The ACO section (eg, the component). - * @param string $value The ACO section value (if using a constant value). - * - * @return void - * - * @deprecated 12.1 Use JAccess - * @see Jaccess - * @since 11.1 - */ - public function setAccessControl($section, $value = null) - { - // Deprecation warning. - JLog::add('JController::setAccessControl() is deprecated.', JLog::WARNING, 'deprecated'); - $this->_acoSection = $section; - $this->_acoSectionValue = $value; - } - - /** - * Sets the internal message that is passed with a redirect - * - * @param string $text Message to display on redirect. - * @param string $type Message type (since 11.1). Optional, defaults to 'message'. - * - * @return string Previous message - * - * @since 11.1 - */ - public function setMessage($text, $type = 'message') - { - $previous = $this->message; - $this->message = $text; - $this->messageType = $type; - - return $previous; - } - - /** - * Sets an entire array of search paths for resources. - * - * @param string $type The type of path to set, typically 'view' or 'model'. - * @param string $path The new set of search paths. If null or false, resets to the current directory only. - * - * @return void - * - * @note Replaces _setPath. - * @since 11.1 - */ - protected function setPath($type, $path) - { - // clear out the prior search dirs - $this->paths[$type] = array(); - - // actually add the user-specified directories - $this->addPath($type, $path); - } - - /** - * Set a URL for browser redirection. - * - * @param string $url URL to redirect to. - * @param string $msg Message to display on redirect. Optional, defaults to value set internally by controller, if any. - * @param string $type Message type. Optional, defaults to 'message' or the type set by a previous call to setMessage. - * - * @return JController This object to support chaining. - * - * @since 11.1 - */ - public function setRedirect($url, $msg = null, $type = null) - { - $this->redirect = $url; - if ($msg !== null) - { - // Controller may have set this directly - $this->message = $msg; - } - - // Ensure the type is not overwritten by a previous call to setMessage. - if (empty($type)) - { - if (empty($this->messageType)) - { - $this->messageType = 'message'; - } - } - // If the type is explicitly set, set it. - else - { - $this->messageType = $type; - } - - return $this; - } -} diff --git a/platform/libraries/joomla/application/component/controlleradmin.php b/platform/libraries/joomla/application/component/controlleradmin.php deleted file mode 100644 index de4c404..0000000 --- a/platform/libraries/joomla/application/component/controlleradmin.php +++ /dev/null @@ -1,325 +0,0 @@ -registerTask('unpublish', 'publish'); // value = 0 - $this->registerTask('archive', 'publish'); // value = 2 - $this->registerTask('trash', 'publish'); // value = -2 - $this->registerTask('report', 'publish'); // value = -3 - $this->registerTask('orderup', 'reorder'); - $this->registerTask('orderdown', 'reorder'); - - // Guess the option as com_NameOfController. - if (empty($this->option)) - { - $this->option = 'com_' . strtolower($this->getName()); - } - - // Guess the JText message prefix. Defaults to the option. - if (empty($this->text_prefix)) - { - $this->text_prefix = strtoupper($this->option); - } - - // Guess the list view as the suffix, eg: OptionControllerSuffix. - if (empty($this->view_list)) - { - $r = null; - if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r)) - { - JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME')); - } - $this->view_list = strtolower($r[2]); - } - } - - /** - * Removes an item. - * - * @return void - * - * @since 11.1 - */ - function delete() - { - // Check for request forgeries - JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); - - // Get items to remove from the request. - $cid = JRequest::getVar('cid', array(), '', 'array'); - - if (!is_array($cid) || count($cid) < 1) - { - JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); - } - else - { - // Get the model. - $model = $this->getModel(); - - // Make sure the item ids are integers - jimport('joomla.utilities.arrayhelper'); - JArrayHelper::toInteger($cid); - - // Remove the items. - if ($model->delete($cid)) - { - $this->setMessage(JText::plural($this->text_prefix . '_N_ITEMS_DELETED', count($cid))); - } - else - { - $this->setMessage($model->getError()); - } - } - - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); - } - - /** - * Display is not supported by this controller. - * - * @param boolean $cachable If true, the view output will be cached - * @param array $urlparams An array of safe url parameters and their variable types, for valid values see {@link JFilterInput::clean()}. - * - * @return JController A JController object to support chaining. - * - * @since 11.1 - */ - public function display($cachable = false, $urlparams = false) - { - return $this; - } - - /** - * Method to publish a list of taxa - * - * @return void - * - * @since 11.1 - */ - function publish() - { - // Check for request forgeries - JRequest::checkToken() or die(JText::_('JINVALID_TOKEN')); - - $session = JFactory::getSession(); - $registry = $session->get('registry'); - - // Get items to publish from the request. - $cid = JRequest::getVar('cid', array(), '', 'array'); - $data = array('publish' => 1, 'unpublish' => 0, 'archive' => 2, 'trash' => -2, 'report' => -3); - $task = $this->getTask(); - $value = JArrayHelper::getValue($data, $task, 0, 'int'); - - if (empty($cid)) - { - JError::raiseWarning(500, JText::_($this->text_prefix . '_NO_ITEM_SELECTED')); - } - else - { - // Get the model. - $model = $this->getModel(); - - // Make sure the item ids are integers - JArrayHelper::toInteger($cid); - - // Publish the items. - if (!$model->publish($cid, $value)) - { - JError::raiseWarning(500, $model->getError()); - } - else - { - if ($value == 1) - { - $ntext = $this->text_prefix . '_N_ITEMS_PUBLISHED'; - } - elseif ($value == 0) - { - $ntext = $this->text_prefix . '_N_ITEMS_UNPUBLISHED'; - } - elseif ($value == 2) - { - $ntext = $this->text_prefix . '_N_ITEMS_ARCHIVED'; - } - else - { - $ntext = $this->text_prefix . '_N_ITEMS_TRASHED'; - } - $this->setMessage(JText::plural($ntext, count($cid))); - } - } - $extension = JRequest::getCmd('extension'); - $extensionURL = ($extension) ? '&extension=' . JRequest::getCmd('extension') : ''; - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $extensionURL, false)); - } - - /** - * Changes the order of one or more records. - * - * @return void - * - * @since 11.1 - */ - public function reorder() - { - // Check for request forgeries. - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $user = JFactory::getUser(); - $ids = JRequest::getVar('cid', null, 'post', 'array'); - $inc = ($this->getTask() == 'orderup') ? -1 : +1; - - $model = $this->getModel(); - $return = $model->reorder($ids, $inc); - if ($return === false) - { - // Reorder failed. - $message = JText::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError()); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); - return false; - } - else - { - // Reorder succeeded. - $message = JText::_('JLIB_APPLICATION_SUCCESS_ITEM_REORDERED'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message); - return true; - } - } - - /** - * Method to save the submitted ordering values for records. - * - * @return void - * - * @since 11.1 - */ - public function saveorder() - { - // Check for request forgeries. - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Get the input - $pks = JRequest::getVar('cid', null, 'post', 'array'); - $order = JRequest::getVar('order', null, 'post', 'array'); - - // Sanitize the input - JArrayHelper::toInteger($pks); - JArrayHelper::toInteger($order); - - // Get the model - $model = $this->getModel(); - - // Save the ordering - $return = $model->saveorder($pks, $order); - - if ($return === false) - { - // Reorder failed - $message = JText::sprintf('JLIB_APPLICATION_ERROR_REORDER_FAILED', $model->getError()); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); - return false; - } - else - { - // Reorder succeeded. - $this->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_ORDERING_SAVED')); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false)); - return true; - } - } - - /** - * Check in of one or more records. - * - * @return void - * - * @since 11.1 - */ - public function checkin() - { - // Check for request forgeries. - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $user = JFactory::getUser(); - $ids = JRequest::getVar('cid', null, 'post', 'array'); - - $model = $this->getModel(); - $return = $model->checkin($ids); - if ($return === false) - { - // Checkin failed. - $message = JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message, 'error'); - return false; - } - else - { - // Checkin succeeded. - $message = JText::plural($this->text_prefix . '_N_ITEMS_CHECKED_IN', count($ids)); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list, false), $message); - return true; - } - } -} diff --git a/platform/libraries/joomla/application/component/controllerform.php b/platform/libraries/joomla/application/component/controllerform.php deleted file mode 100644 index c89f904..0000000 --- a/platform/libraries/joomla/application/component/controllerform.php +++ /dev/null @@ -1,734 +0,0 @@ -option)) - { - $this->option = 'com_' . strtolower($this->getName()); - } - - // Guess the JText message prefix. Defaults to the option. - if (empty($this->text_prefix)) - { - $this->text_prefix = strtoupper($this->option); - } - - // Guess the context as the suffix, eg: OptionControllerContent. - if (empty($this->context)) - { - $r = null; - if (!preg_match('/(.*)Controller(.*)/i', get_class($this), $r)) - { - JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_CONTROLLER_GET_NAME')); - } - $this->context = strtolower($r[2]); - } - - // Guess the item view as the context. - if (empty($this->view_item)) - { - $this->view_item = $this->context; - } - - // Guess the list view as the plural of the item view. - if (empty($this->view_list)) - { - // @TODO Probably worth moving to an inflector class based on - // http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/ - - // Simple pluralisation based on public domain snippet by Paul Osman - // For more complex types, just manually set the variable in your class. - $plural = array( - array('/(x|ch|ss|sh)$/i', "$1es"), - array('/([^aeiouy]|qu)y$/i', "$1ies"), - array('/([^aeiouy]|qu)ies$/i', "$1y"), - array('/(bu)s$/i', "$1ses"), - array('/s$/i', "s"), - array('/$/', "s")); - - // check for matches using regular expressions - foreach ($plural as $pattern) - { - if (preg_match($pattern[0], $this->view_item)) - { - $this->view_list = preg_replace($pattern[0], $pattern[1], $this->view_item); - break; - } - } - } - - // Apply, Save & New, and Save As copy should be standard on forms. - $this->registerTask('apply', 'save'); - $this->registerTask('save2new', 'save'); - $this->registerTask('save2copy', 'save'); - } - - /** - * Method to add a new record. - * - * @return mixed True if the record can be added, a JError object if not. - * - * @since 11.1 - */ - public function add() - { - // Initialise variables. - $app = JFactory::getApplication(); - $context = "$this->option.edit.$this->context"; - - // Access check. - if (!$this->allowAdd()) - { - // Set the internal error and also the redirect error. - $this->setError(JText::_('JLIB_APPLICATION_ERROR_CREATE_RECORD_NOT_PERMITTED')); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); - - return false; - } - - // Clear the record edit information from the session. - $app->setUserState($context . '.data', null); - - // Redirect to the edit screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(), - false - ) - ); - - return true; - } - - /** - * Method to check if you can add a new record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * - * @return boolean - * - * @since 11.1 - */ - protected function allowAdd($data = array()) - { - $user = JFactory::getUser(); - return ($user->authorise('core.create', $this->option) || count($user->getAuthorisedCategories($this->option, 'core.create'))); - } - - /** - * Method to check if you can add a new record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key; default is id. - * - * @return boolean - * - * @since 11.1 - */ - protected function allowEdit($data = array(), $key = 'id') - { - return JFactory::getUser()->authorise('core.edit', $this->option); - } - - /** - * Method to check if you can save a new or existing record. - * - * Extended classes can override this if necessary. - * - * @param array $data An array of input data. - * @param string $key The name of the key for the primary key. - * - * @return boolean - * - * @since 11.1 - */ - protected function allowSave($data, $key = 'id') - { - // Initialise variables. - $recordId = isset($data[$key]) ? $data[$key] : '0'; - - if ($recordId) - { - return $this->allowEdit($data, $key); - } - else - { - return $this->allowAdd($data); - } - } - - /** - * Method to run batch operations. - * - * @param object $model The model of the component being processed. - * - * @return boolean True if successful, false otherwise and internal error is set. - * - * @since 11.1 - */ - public function batch($model) - { - // Initialise variables. - $app = JFactory::getApplication(); - $vars = JRequest::getVar('batch', array(), 'post', 'array'); - $cid = JRequest::getVar('cid', array(), 'post', 'array'); - - // Attempt to run the batch operation. - if ($model->batch($vars, $cid)) - { - $this->setMessage(JText::_('JLIB_APPLICATION_SUCCESS_BATCH')); - - return true; - } - else - { - $this->setMessage(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_FAILED', $model->getError())); - return false; - } - } - - /** - * Method to cancel an edit. - * - * @param string $key The name of the primary key of the URL variable. - * - * @return boolean True if access level checks pass, false otherwise. - * - * @since 11.1 - */ - public function cancel($key = null) - { - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel(); - $table = $model->getTable(); - $checkin = property_exists($table, 'checked_out'); - $context = "$this->option.edit.$this->context"; - - if (empty($key)) - { - $key = $table->getKeyName(); - } - - $recordId = JRequest::getInt($key); - - // Attempt to check-in the current record. - if ($recordId) - { - // Check we are holding the id in the edit list. - if (!$this->checkEditId($context, $recordId)) - { - // Somehow the person just went to the form - we don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId)); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), - false - ) - ); - - return false; - } - - if ($checkin) - { - if ($model->checkin($recordId) === false) - { - // Check-in failed, go back to the record and display a notice. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError())); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . - $this->getRedirectToItemAppend($recordId, $key), - false - ) - ); - - return false; - } - } - } - - // Clean the session data and redirect. - $this->releaseEditId($context, $recordId); - $app->setUserState($context . '.data', null); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); - - return true; - } - - /** - * Method to edit an existing record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key - * (sometimes required to avoid router collisions). - * - * @return boolean True if access level check and checkout passes, false otherwise. - * - * @since 11.1 - */ - public function edit($key = null, $urlVar = null) - { - // Initialise variables. - $app = JFactory::getApplication(); - $model = $this->getModel(); - $table = $model->getTable(); - $cid = JRequest::getVar('cid', array(), 'post', 'array'); - $context = "$this->option.edit.$this->context"; - $append = ''; - - // Determine the name of the primary key for the data. - if (empty($key)) - { - $key = $table->getKeyName(); - } - - // To avoid data collisions the urlVar may be different from the primary key. - if (empty($urlVar)) - { - $urlVar = $key; - } - - // Get the previous record id (if any) and the current record id. - $recordId = (int) (count($cid) ? $cid[0] : JRequest::getInt($urlVar)); - $checkin = property_exists($table, 'checked_out'); - - // Access check. - if (!$this->allowEdit(array($key => $recordId), $key)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_EDIT_NOT_PERMITTED')); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); - - return false; - } - - // Attempt to check-out the new record for editing and redirect. - if ($checkin && !$model->checkout($recordId)) - { - // Check-out failed, display a notice but allow the user to see the record. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKOUT_FAILED', $model->getError())); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false)); - - return false; - } - else - { - // Check-out succeeded, push the new record id into the session. - $this->holdEditId($context, $recordId); - $app->setUserState($context . '.data', null); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $urlVar), false)); - - return true; - } - } - - /** - * Method to get a model object, loading it if required. - * - * @param string $name The model name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration array for model. Optional. - * - * @return object The model. - * - * @since 11.1 - */ - public function getModel($name = '', $prefix = '', $config = array('ignore_request' => true)) - { - if (empty($name)) - { - $name = $this->context; - } - - return parent::getModel($name, $prefix, $config); - } - - /** - * Gets the URL arguments to append to an item redirect. - * - * @param integer $recordId The primary key id for the item. - * @param string $urlVar The name of the URL variable for the id. - * - * @return string The arguments to append to the redirect URL. - * - * @since 11.1 - */ - protected function getRedirectToItemAppend($recordId = null, $urlVar = 'id') - { - $tmpl = JRequest::getCmd('tmpl'); - $layout = JRequest::getCmd('layout', 'edit'); - $append = ''; - - // Setup redirect info. - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - if ($layout) - { - $append .= '&layout=' . $layout; - } - - if ($recordId) - { - $append .= '&' . $urlVar . '=' . $recordId; - } - - return $append; - } - - /** - * Gets the URL arguments to append to a list redirect. - * - * @return string The arguments to append to the redirect URL. - * - * @since 11.1 - */ - protected function getRedirectToListAppend() - { - $tmpl = JRequest::getCmd('tmpl'); - $append = ''; - - // Setup redirect info. - if ($tmpl) - { - $append .= '&tmpl=' . $tmpl; - } - - return $append; - } - - /** - * Function that allows child controller access to model data - * after the data has been saved. - * - * @param JModel &$model The data model object. - * @param array $validData The validated data. - * - * @return void - * - * @since 11.1 - */ - protected function postSaveHook(JModel &$model, $validData = array()) - { - } - - /** - * Method to save a record. - * - * @param string $key The name of the primary key of the URL variable. - * @param string $urlVar The name of the URL variable if different from the primary key (sometimes required to avoid router collisions). - * - * @return boolean True if successful, false otherwise. - * - * @since 11.1 - */ - public function save($key = null, $urlVar = null) - { - // Check for request forgeries. - JRequest::checkToken() or jexit(JText::_('JINVALID_TOKEN')); - - // Initialise variables. - $app = JFactory::getApplication(); - $lang = JFactory::getLanguage(); - $model = $this->getModel(); - $table = $model->getTable(); - $data = JRequest::getVar('jform', array(), 'post', 'array'); - $checkin = property_exists($table, 'checked_out'); - $context = "$this->option.edit.$this->context"; - $task = $this->getTask(); - - // Determine the name of the primary key for the data. - if (empty($key)) - { - $key = $table->getKeyName(); - } - - // To avoid data collisions the urlVar may be different from the primary key. - if (empty($urlVar)) - { - $urlVar = $key; - } - - $recordId = JRequest::getInt($urlVar); - - $session = JFactory::getSession(); - $registry = $session->get('registry'); - - if (!$this->checkEditId($context, $recordId)) - { - // Somehow the person just went to the form and tried to save it. We don't allow that. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $recordId)); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); - - return false; - } - - // Populate the row id from the session. - $data[$key] = $recordId; - - // The save2copy task needs to be handled slightly differently. - if ($task == 'save2copy') - { - // Check-in the original row. - if ($checkin && $model->checkin($data[$key]) === false) - { - // Check-in failed. Go back to the item and display a notice. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError())); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . - $this->getRedirectToItemAppend($recordId, $urlVar), - false - ) - ); - - return false; - } - - // Reset the ID and then treat the request as for Apply. - $data[$key] = 0; - $task = 'apply'; - } - - // Access check. - if (!$this->allowSave($data, $key)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_SAVE_NOT_PERMITTED')); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), false)); - - return false; - } - - // Validate the posted data. - // Sometimes the form needs some posted data, such as for plugins and modules. - $form = $model->getForm($data, false); - - if (!$form) - { - $app->enqueueMessage($model->getError(), 'error'); - - return false; - } - - // Test whether the data is valid. - $validData = $model->validate($form, $data); - - // Check for validation errors. - if ($validData === false) - { - // Get the validation messages. - $errors = $model->getErrors(); - - // Push up to three validation messages out to the user. - for ($i = 0, $n = count($errors); $i < $n && $i < 3; $i++) - { - if (JError::isError($errors[$i])) - { - $app->enqueueMessage($errors[$i]->getMessage(), 'warning'); - } - else - { - $app->enqueueMessage($errors[$i], 'warning'); - } - } - - // Save the data in the session. - $app->setUserState($context . '.data', $data); - - // Redirect back to the edit screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), - false - ) - ); - - return false; - } - - // Attempt to save the data. - if (!$model->save($validData)) - { - // Save the data in the session. - $app->setUserState($context . '.data', $validData); - - // Redirect back to the edit screen. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_SAVE_FAILED', $model->getError())); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), - false - ) - ); - - return false; - } - - // Save succeeded, so check-in the record. - if ($checkin && $model->checkin($validData[$key]) === false) - { - // Save the data in the session. - $app->setUserState($context . '.data', $validData); - - // Check-in failed, so go back to the record and display a notice. - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError())); - $this->setMessage($this->getError(), 'error'); - $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), false)); - - return false; - } - - $this->setMessage( - JText::_( - ($lang->hasKey($this->text_prefix . ($recordId == 0 && $app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS') - ? $this->text_prefix - : 'JLIB_APPLICATION') . ($recordId == 0 && $app->isSite() ? '_SUBMIT' : '') . '_SAVE_SUCCESS' - ) - ); - - // Redirect the user and adjust session state based on the chosen task. - switch ($task) - { - case 'apply': - // Set the record data in the session. - $recordId = $model->getState($this->context . '.id'); - $this->holdEditId($context, $recordId); - $app->setUserState($context . '.data', null); - $model->checkout($recordId); - - // Redirect back to the edit screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), - false - ) - ); - break; - - case 'save2new': - // Clear the record id and data from the session. - $this->releaseEditId($context, $recordId); - $app->setUserState($context . '.data', null); - - // Redirect back to the edit screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend(null, $key), - false - ) - ); - break; - - default: - // Clear the record id and data from the session. - $this->releaseEditId($context, $recordId); - $app->setUserState($context . '.data', null); - - // Redirect to the list screen. - $this->setRedirect( - JRoute::_( - 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend(), - false - ) - ); - break; - } - - // Invoke the postSave method to allow for the child class to access the model. - $this->postSaveHook($model, $validData); - - return true; - } -} diff --git a/platform/libraries/joomla/application/component/helper.php b/platform/libraries/joomla/application/component/helper.php deleted file mode 100644 index 2682e4a..0000000 --- a/platform/libraries/joomla/application/component/helper.php +++ /dev/null @@ -1,231 +0,0 @@ -enabled = $strict ? false : true; - $result->params = new JRegistry; - } - } - else - { - $result = self::$_components[$option]; - } - - return $result; - } - - /** - * Checks if the component is enabled - * - * @param string $option The component option. - * @param boolean $strict If set and the component does not exist, false will be returned. - * - * @return boolean - * - * @since 11.1 - */ - public static function isEnabled($option, $strict = false) - { - $result = self::getComponent($option, $strict); - - return ($result->enabled | JFactory::getApplication()->isAdmin()); - } - - /** - * Gets the parameter object for the component - * - * @param string $option The option for the component. - * @param boolean $strict If set and the component does not exist, false will be returned - * - * @return JRegistry A JRegistry object. - * - * @see JRegistry - * @since 11.1 - */ - public static function getParams($option, $strict = false) - { - $component = self::getComponent($option, $strict); - - return $component->params; - } - - /** - * Render the component. - * - * @param string $option The component option. - * @param array $params The component parameters - * - * @return void - * - * @since 11.1 - */ - public static function renderComponent($option, $params = array()) - { - // Initialise variables. - $app = JFactory::getApplication(); - - // Load template language files. - $template = $app->getTemplate(true)->template; - $lang = JFactory::getLanguage(); - $lang->load('tpl_' . $template, JPATH_BASE, null, false, false) - || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", null, false, false) - || $lang->load('tpl_' . $template, JPATH_BASE, $lang->getDefault(), false, false) - || $lang->load('tpl_' . $template, JPATH_THEMES . "/$template", $lang->getDefault(), false, false); - - if (empty($option)) - { - // Throw 404 if no component - JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); - return; - } - - // Record the scope - $scope = $app->scope; - // Set scope to component name - $app->scope = $option; - - // Build the component path. - $option = preg_replace('/[^A-Z0-9_\.-]/i', '', $option); - $file = substr($option, 4); - - // Define component path. - define('JPATH_COMPONENT', JPATH_BASE . '/components/' . $option); - define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/' . $option); - define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option); - - // Get component path - if ($app->isAdmin() && file_exists(JPATH_COMPONENT . '/admin.' . $file . '.php')) - { - $path = JPATH_COMPONENT . '/admin.' . $file . '.php'; - } - else - { - $path = JPATH_COMPONENT . '/' . $file . '.php'; - } - - // If component is disabled throw error - if (!self::isEnabled($option) || !file_exists($path)) - { - JError::raiseError(404, JText::_('JLIB_APPLICATION_ERROR_COMPONENT_NOT_FOUND')); - } - - $task = JRequest::getString('task'); - - // Load common and local language files. - $lang->load($option, JPATH_BASE, null, false, false) || $lang->load($option, JPATH_COMPONENT, null, false, false) - || $lang->load($option, JPATH_BASE, $lang->getDefault(), false, false) - || $lang->load($option, JPATH_COMPONENT, $lang->getDefault(), false, false); - - // Handle template preview outlining. - $contents = null; - - // Execute the component. - ob_start(); - require_once $path; - $contents = ob_get_contents(); - ob_end_clean(); - - // Build the component toolbar - jimport('joomla.application.helper'); - - if (($path = JApplicationHelper::getPath('toolbar')) && $app->isAdmin()) - { - // Get the task again, in case it has changed - $task = JRequest::getString('task'); - - // Make the toolbar - include_once $path; - } - - // Revert the scope - $app->scope = $scope; - - return $contents; - } - - /** - * Load the installed components into the _components property. - * - * @param string $option The element value for the extension - * - * @return boolean True on success - * - * @since 11.1 - */ - protected static function _load($option) - { - $db = JFactory::getDbo(); - $query = $db->getQuery(true); - $query->select('extension_id AS "id", element AS "option", params, enabled'); - $query->from('#__extensions'); - $query->where($query->qn('type') . ' = ' . $db->quote('component')); - $query->where($query->qn('element') . ' = ' . $db->quote($option)); - $db->setQuery($query); - - $cache = JFactory::getCache('_system', 'callback'); - - self::$_components[$option] = $cache->get(array($db, 'loadObject'), null, $option, false); - - if ($error = $db->getErrorMsg() || empty(self::$_components[$option])) - { - // Fatal error. - JError::raiseWarning(500, JText::sprintf('JLIB_APPLICATION_ERROR_COMPONENT_NOT_LOADING', $option, $error)); - return false; - } - - // Convert the params to an object. - if (is_string(self::$_components[$option]->params)) - { - $temp = new JRegistry; - $temp->loadString(self::$_components[$option]->params); - self::$_components[$option]->params = $temp; - } - - return true; - } -} diff --git a/platform/libraries/joomla/application/component/index.html b/platform/libraries/joomla/application/component/index.html deleted file mode 100644 index 2efb97f..0000000 --- a/platform/libraries/joomla/application/component/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/platform/libraries/joomla/application/component/model.php b/platform/libraries/joomla/application/component/model.php deleted file mode 100644 index 83e3942..0000000 --- a/platform/libraries/joomla/application/component/model.php +++ /dev/null @@ -1,523 +0,0 @@ - $type))); - if (!$path) - { - $path = JPath::find(JModel::addIncludePath(null, ''), JModel::_createFileName('model', array('name' => $type))); - } - if ($path) - { - require_once $path; - - if (!class_exists($modelClass)) - { - JError::raiseWarning(0, JText::sprintf('JLIB_APPLICATION_ERROR_MODELCLASS_NOT_FOUND', $modelClass)); - return false; - } - } - else - { - return false; - } - } - - return new $modelClass($config); - } - - /** - * Constructor - * - * @param array $config An array of configuration options (name, state, dbo, table_path, ignore_request). - * - * @return JModel A JModel object - * - * @since 11.1 - */ - public function __construct($config = array()) - { - // Guess the option from the class name (Option)Model(View). - if (empty($this->option)) - { - $r = null; - - if (!preg_match('/(.*)Model/i', get_class($this), $r)) - { - JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_MODEL_GET_NAME')); - } - - $this->option = 'com_' . strtolower($r[1]); - } - - // Set the view name - if (empty($this->name)) - { - if (array_key_exists('name', $config)) - { - $this->name = $config['name']; - } - else - { - $this->name = $this->getName(); - } - } - - // Set the model state - if (array_key_exists('state', $config)) - { - $this->state = $config['state']; - } - else - { - $this->state = new JObject; - } - - // Set the model dbo - if (array_key_exists('dbo', $config)) - { - $this->_db = $config['dbo']; - } - else - { - $this->_db = JFactory::getDbo(); - } - - // Set the default view search path - if (array_key_exists('table_path', $config)) - { - $this->addTablePath($config['table_path']); - } - elseif (defined('JPATH_COMPONENT_ADMINISTRATOR')) - { - $this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR . '/tables'); - } - - // Set the internal state marker - used to ignore setting state from the request - if (!empty($config['ignore_request'])) - { - $this->__state_set = true; - } - - // Set the clean cache event - if (isset($config['event_clean_cache'])) - { - $this->event_clean_cache = $config['event_clean_cache']; - } - elseif (empty($this->event_clean_cache)) - { - $this->event_clean_cache = 'onContentCleanCache'; - } - - } - - /** - * Gets an array of objects from the results of database query. - * - * @param string $query The query. - * @param integer $limitstart Offset. - * @param integer $limit The number of records. - * - * @return array An array of results. - * - * @since 11.1 - */ - protected function _getList($query, $limitstart = 0, $limit = 0) - { - $this->_db->setQuery($query, $limitstart, $limit); - $result = $this->_db->loadObjectList(); - - return $result; - } - - /** - * Returns a record count for the query - * - * @param string $query The query. - * - * @return integer Number of rows for query - * - * @since 11.1 - */ - protected function _getListCount($query) - { - $this->_db->setQuery($query); - $this->_db->query(); - - return $this->_db->getNumRows(); - } - - /** - * Method to load and return a model object. - * - * @param string $name The name of the view - * @param string $prefix The class prefix. Optional. - * @param array $config Configuration settings to pass to JTable::getInsance - * - * @return mixed Model object or boolean false if failed - * - * @since 11.1 - * @see JTable::getInstance - */ - protected function _createTable($name, $prefix = 'Table', $config = array()) - { - // Clean the model name - $name = preg_replace('/[^A-Z0-9_]/i', '', $name); - $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); - - // Make sure we are returning a DBO object - if (!array_key_exists('dbo', $config)) - { - $config['dbo'] = $this->getDbo(); - } - - return JTable::getInstance($name, $prefix, $config); - } - - /** - * Method to get the database connector object - * - * @return JDatabase JDatabase connector object - */ - public function getDbo() - { - return $this->_db; - } - - /** - * Method to get the model name - * - * The model name. By default parsed using the classname or it can be set - * by passing a $config['name'] in the class constructor - * - * @return string The name of the model - * - * @since 11.1 - */ - public function getName() - { - $name = $this->name; - - if (empty($name)) - { - $r = null; - if (!preg_match('/Model(.*)/i', get_class($this), $r)) - { - JError::raiseError(500, 'JLIB_APPLICATION_ERROR_MODEL_GET_NAME'); - } - $name = strtolower($r[1]); - } - - return $name; - } - - /** - * Method to get model state variables - * - * @param string $property Optional parameter name - * @param mixed $default Optional default value - * - * @return object The property where specified, the state object where omitted - * - * @since 11.1 - */ - public function getState($property = null, $default = null) - { - if (!$this->__state_set) - { - // Protected method to auto-populate the model state. - $this->populateState(); - - // Set the model state set flag to true. - $this->__state_set = true; - } - - return $property === null ? $this->state : $this->state->get($property, $default); - } - - /** - * Method to get a table object, load it if necessary. - * - * @param string $name The table name. Optional. - * @param string $prefix The class prefix. Optional. - * @param array $options Configuration array for model. Optional. - * - * @return JTable A JTable object - * - * @since 11.1 - */ - public function getTable($name = '', $prefix = '', $options = array()) - { - if (empty($name)) - { - $name = $this->getName(); - } - - if (empty($prefix)) - { - $prefix = $this->getName() . 'Table'; - } - - if ($table = $this->_createTable($name, $prefix, $options)) - { - return $table; - } - - if ($table = $this->_createTable($name, 'Table', $options)) - { - return $table; - } - - JError::raiseError(0, JText::sprintf('JLIB_APPLICATION_ERROR_TABLE_NAME_NOT_SUPPORTED', $name)); - - return null; - } - - /** - * Method to auto-populate the model state. - * - * This method should only be called once per instantiation and is designed - * to be called on the first call to the getState() method unless the model - * configuration flag to ignore the request is set. - * - * @return void - * - * @note Calling getState in this method will result in recursion. - * @since 11.1 - */ - protected function populateState() - { - } - - /** - * Method to set the database connector object - * - * @param object &$db A JDatabase based object - * - * @return void - * - * @since 11.1 - */ - public function setDbo(&$db) - { - $this->_db = &$db; - } - - /** - * Method to set model state variables - * - * @param string $property The name of the property. - * @param mixed $value The value of the property to set or null. - * - * @return mixed The previous value of the property or null if not set. - * - * @since 11.1 - */ - public function setState($property, $value = null) - { - return $this->state->set($property, $value); - } - - /** - * Clean the cache - * - * @param string $group The cache group - * @param string $client_id The ID of the client - * - * @return void - * - * @since 11.1 - */ - protected function cleanCache($group = null, $client_id = 0) - { - // Initialise variables; - $conf = JFactory::getConfig(); - $dispatcher = JDispatcher::getInstance(); - - $options = array( - 'defaultgroup' => ($group) ? $group : (isset($this->option) ? $this->option : JRequest::getCmd('option')), - 'cachebase' => ($client_id) ? JPATH_ADMINISTRATOR . '/cache' : $conf->get('cache_path', JPATH_SITE . '/cache')); - - jimport('joomla.cache.cache'); - $cache = JCache::getInstance('callback', $options); - $cache->clean(); - - // Trigger the onContentCleanCache event. - $dispatcher->trigger($this->event_clean_cache, $options); - } -} diff --git a/platform/libraries/joomla/application/component/modeladmin.php b/platform/libraries/joomla/application/component/modeladmin.php deleted file mode 100644 index 87c066d..0000000 --- a/platform/libraries/joomla/application/component/modeladmin.php +++ /dev/null @@ -1,1074 +0,0 @@ -event_after_delete = $config['event_after_delete']; - } - elseif (empty($this->event_after_delete)) - { - $this->event_after_delete = 'onContentAfterDelete'; - } - - if (isset($config['event_after_save'])) - { - $this->event_after_save = $config['event_after_save']; - } - elseif (empty($this->event_after_save)) - { - $this->event_after_save = 'onContentAfterSave'; - } - - if (isset($config['event_before_delete'])) - { - $this->event_before_delete = $config['event_before_delete']; - } - elseif (empty($this->event_before_delete)) - { - $this->event_before_delete = 'onContentBeforeDelete'; - } - - if (isset($config['event_before_save'])) - { - $this->event_before_save = $config['event_before_save']; - } - elseif (empty($this->event_before_save)) - { - $this->event_before_save = 'onContentBeforeSave'; - } - - if (isset($config['event_change_state'])) - { - $this->event_change_state = $config['event_change_state']; - } - elseif (empty($this->event_change_state)) - { - $this->event_change_state = 'onContentChangeState'; - } - - // Guess the JText message prefix. Defaults to the option. - if (isset($config['text_prefix'])) - { - $this->text_prefix = strtoupper($config['text_prefix']); - } - elseif (empty($this->text_prefix)) - { - $this->text_prefix = strtoupper($this->option); - } - } - - /** - * Method to perform batch operations on an item or a set of items. - * - * @param array $commands An array of commands to perform. - * @param array $pks An array of item ids. - * - * @return boolean Returns true on success, false on failure. - * - * @since 11.1 - */ - public function batch($commands, $pks) - { - // Sanitize user ids. - $pks = array_unique($pks); - JArrayHelper::toInteger($pks); - - // Remove any values of zero. - if (array_search(0, $pks, true)) - { - unset($pks[array_search(0, $pks, true)]); - } - - if (empty($pks)) - { - $this->setError(JText::_('JGLOBAL_NO_ITEM_SELECTED')); - return false; - } - - $done = false; - - if (!empty($commands['category_id'])) - { - $cmd = JArrayHelper::getValue($commands, 'move_copy', 'c'); - - if ($cmd == 'c') - { - $result = $this->batchCopy($commands['category_id'], $pks); - if (is_array($result)) - { - $pks = $result; - } - else - { - return false; - } - } - elseif ($cmd == 'm' && !$this->batchMove($commands['category_id'], $pks)) - { - return false; - } - $done = true; - } - - if (!empty($commands['assetgroup_id'])) - { - if (!$this->batchAccess($commands['assetgroup_id'], $pks)) - { - return false; - } - - $done = true; - } - - if (!$done) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_INSUFFICIENT_BATCH_INFORMATION')); - return false; - } - - // Clear the cache - $this->cleanCache(); - - return true; - } - - /** - * Batch access level changes for a group of rows. - * - * @param integer $value The new value matching an Asset Group ID. - * @param array $pks An array of row IDs. - * - * @return booelan True if successful, false otherwise and internal error is set. - * - * @since 11.1 - */ - protected function batchAccess($value, $pks) - { - // Check that user has edit permission for items - $extension = JRequest::getCmd('option'); - $user = JFactory::getUser(); - if (!$user->authorise('core.edit', $extension)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); - return false; - } - - $table = $this->getTable(); - - foreach ($pks as $pk) - { - $table->reset(); - $table->load($pk); - $table->access = (int) $value; - - if (!$table->store()) - { - $this->setError($table->getError()); - return false; - } - } - - // Clean the cache - $this->cleanCache(); - - return true; - } - - /** - * Batch copy items to a new category or current. - * - * @param integer $value The new category. - * @param array $pks An array of row IDs. - * - * @return mixed An array of new IDs on success, boolean false on failure. - * - * @since 11.1 - */ - protected function batchCopy($value, $pks) - { - $categoryId = (int) $value; - - $table = $this->getTable(); - $db = $this->getDbo(); - $i = 0; - - // Check that the category exists - if ($categoryId) - { - $categoryTable = JTable::getInstance('Category'); - if (!$categoryTable->load($categoryId)) - { - if ($error = $categoryTable->getError()) - { - // Fatal error - $this->setError($error); - return false; - } - else - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); - return false; - } - } - } - - if (empty($categoryId)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); - return false; - } - - // Check that the user has create permission for the component - $extension = JRequest::getCmd('option'); - $user = JFactory::getUser(); - if (!$user->authorise('core.create', $extension)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); - return false; - } - - // Parent exists so we let's proceed - while (!empty($pks)) - { - // Pop the first ID off the stack - $pk = array_shift($pks); - - $table->reset(); - - // Check that the row actually exists - if (!$table->load($pk)) - { - if ($error = $table->getError()) - { - // Fatal error - $this->setError($error); - return false; - } - else - { - // Not fatal error - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); - continue; - } - } - - // Alter the title & alias - $data = $this->generateNewTitle($categoryId, $table->alias, $table->title); - $table->title = $data['0']; - $table->alias = $data['1']; - - // Reset the ID because we are making a copy - $table->id = 0; - - // New category ID - $table->catid = $categoryId; - - // TODO: Deal with ordering? - //$table->ordering = 1; - - // Check the row. - if (!$table->check()) - { - $this->setError($table->getError()); - return false; - } - - // Store the row. - if (!$table->store()) - { - $this->setError($table->getError()); - return false; - } - - // Get the new item ID - $newId = $table->get('id'); - - // Add the new ID to the array - $newIds[$i] = $newId; - $i++; - } - - // Clean the cache - $this->cleanCache(); - - return $newIds; - } - - /** - * Batch move articles to a new category - * - * @param integer $value The new category ID. - * @param array $pks An array of row IDs. - * - * @return booelan True if successful, false otherwise and internal error is set. - * - * @since 11.1 - */ - protected function batchMove($value, $pks) - { - $categoryId = (int) $value; - - $table = $this->getTable(); - $db = $this->getDbo(); - - // Check that the category exists - if ($categoryId) - { - $categoryTable = JTable::getInstance('Category'); - if (!$categoryTable->load($categoryId)) - { - if ($error = $categoryTable->getError()) - { - // Fatal error - $this->setError($error); - return false; - } - else - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); - return false; - } - } - } - - if (empty($categoryId)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_MOVE_CATEGORY_NOT_FOUND')); - return false; - } - - // Check that user has create and edit permission for the component - $extension = JRequest::getCmd('option'); - $user = JFactory::getUser(); - if (!$user->authorise('core.create', $extension)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_CREATE')); - return false; - } - - if (!$user->authorise('core.edit', $extension)) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT')); - return false; - } - - // Parent exists so we let's proceed - foreach ($pks as $pk) - { - // Check that the row actually exists - if (!$table->load($pk)) - { - if ($error = $table->getError()) - { - // Fatal error - $this->setError($error); - return false; - } - else - { - // Not fatal error - $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk)); - continue; - } - } - - // Set the new category ID - $table->catid = $categoryId; - - // Check the row. - if (!$table->check()) - { - $this->setError($table->getError()); - return false; - } - - // Store the row. - if (!$table->store()) - { - $this->setError($table->getError()); - return false; - } - } - - // Clean the cache - $this->cleanCache(); - - return true; - } - - /** - * Method to test whether a record can be deleted. - * - * @param object $record A record object. - * - * @return boolean True if allowed to delete the record. Defaults to the permission for the component. - * - * @since 11.1 - */ - protected function canDelete($record) - { - $user = JFactory::getUser(); - return $user->authorise('core.delete', $this->option); - } - - /** - * Method to test whether a record can be deleted. - * - * @param object $record A record object. - * - * @return boolean True if allowed to change the state of the record. Defaults to the permission for the component. - * - * @since 11.1 - */ - protected function canEditState($record) - { - $user = JFactory::getUser(); - return $user->authorise('core.edit.state', $this->option); - } - - /** - * Method override to check-in a record or an array of record - * - * @param mixed $pks The ID of the primary key or an array of IDs - * - * @return mixed Boolean false if there is an error, otherwise the count of records checked in. - * - * @since 11.1 - */ - public function checkin($pks = array()) - { - // Initialise variables. - $user = JFactory::getUser(); - $pks = (array) $pks; - $table = $this->getTable(); - $count = 0; - - if (empty($pks)) - { - $pks = array((int) $this->getState($this->getName() . '.id')); - } - - // Check in all items. - foreach ($pks as $i => $pk) - { - if ($table->load($pk)) - { - - if ($table->checked_out > 0) - { - if (!parent::checkin($pk)) - { - return false; - } - $count++; - } - } - else - { - $this->setError($table->getError()); - - return false; - } - } - - return $count; - } - - /** - * Method override to check-out a record. - * - * @param integer $pk The ID of the primary key. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 11.1 - */ - public function checkout($pk = null) - { - // Initialise variables. - $pk = (!empty($pk)) ? $pk : (int) $this->getState($this->getName() . '.id'); - - return parent::checkout($pk); - } - - /** - * Method to delete one or more records. - * - * @param array &$pks An array of record primary keys. - * - * @return boolean True if successful, false if an error occurs. - * - * @since 11.1 - */ - public function delete(&$pks) - { - // Initialise variables. - $dispatcher = JDispatcher::getInstance(); - $user = JFactory::getUser(); - $pks = (array) $pks; - $table = $this->getTable(); - - // Include the content plugins for the on delete events. - JPluginHelper::importPlugin('content'); - - // Iterate the items to delete each one. - foreach ($pks as $i => $pk) - { - - if ($table->load($pk)) - { - - if ($this->canDelete($table)) - { - - $context = $this->option . '.' . $this->name; - - // Trigger the onContentBeforeDelete event. - $result = $dispatcher->trigger($this->event_before_delete, array($context, $table)); - if (in_array(false, $result, true)) - { - $this->setError($table->getError()); - return false; - } - - if (!$table->delete($pk)) - { - $this->setError($table->getError()); - return false; - } - - // Trigger the onContentAfterDelete event. - $dispatcher->trigger($this->event_after_delete, array($context, $table)); - - } - else - { - - // Prune items that you can't change. - unset($pks[$i]); - $error = $this->getError(); - if ($error) - { - JError::raiseWarning(500, $error); - return false; - } - else - { - JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_DELETE_NOT_PERMITTED')); - return false; - } - } - - } - else - { - $this->setError($table->getError()); - return false; - } - } - - // Clear the component's cache - $this->cleanCache(); - - return true; - } - - /** - * Method to change the title & alias. - * - * @param integer $category_id The id of the category. - * @param string $alias The alias. - * @param string $title The title. - * - * @return array Contains the modified title and alias. - * - * @since 11.1 - */ - protected function generateNewTitle($category_id, $alias, $title) - { - // Alter the title & alias - $table = $this->getTable(); - while ($table->load(array('alias' => $alias, 'catid' => $category_id))) - { - $title = JString::increment($title); - $alias = JString::increment($alias, 'dash'); - } - - return array($title, $alias); - } - - /** - * Method to get a single record. - * - * @param integer $pk The id of the primary key. - * - * @return mixed Object on success, false on failure. - * - * @since 11.1 - */ - public function getItem($pk = null) - { - // Initialise variables. - $pk = (!empty($pk)) ? $pk : (int) $this->getState($this->getName() . '.id'); - $table = $this->getTable(); - - if ($pk > 0) - { - // Attempt to load the row. - $return = $table->load($pk); - - // Check for a table object error. - if ($return === false && $table->getError()) - { - $this->setError($table->getError()); - return false; - } - } - - // Convert to the JObject before adding other data. - $properties = $table->getProperties(1); - $item = JArrayHelper::toObject($properties, 'JObject'); - - if (property_exists($item, 'params')) - { - $registry = new JRegistry; - $registry->loadString($item->params); - $item->params = $registry->toArray(); - } - - return $item; - } - - /** - * A protected method to get a set of ordering conditions. - * - * @param object $table A JTable object. - * - * @return array An array of conditions to add to ordering queries. - * - * @since 11.1 - */ - protected function getReorderConditions($table) - { - return array(); - } - - /** - * Stock method to auto-populate the model state. - * - * @return void - * - * @since 11.1 - */ - protected function populateState() - { - // Initialise variables. - $app = JFactory::getApplication('administrator'); - $table = $this->getTable(); - $key = $table->getKeyName(); - - // Get the pk of the record from the request. - $pk = JRequest::getInt($key); - $this->setState($this->getName() . '.id', $pk); - - // Load the parameters. - $value = JComponentHelper::getParams($this->option); - $this->setState('params', $value); - } - - /** - * Prepare and sanitise the table data prior to saving. - * - * @param JTable &$table A reference to a JTable object. - * - * @return void - * - * @since 11.1 - */ - protected function prepareTable(&$table) - { - // Derived class will provide its own implentation if required. - } - - /** - * Method to change the published state of one or more records. - * - * @param array &$pks A list of the primary keys to change. - * @param integer $value The value of the published state. - * - * @return boolean True on success. - * - * @since 11.1 - */ - function publish(&$pks, $value = 1) - { - // Initialise variables. - $dispatcher = JDispatcher::getInstance(); - $user = JFactory::getUser(); - $table = $this->getTable(); - $pks = (array) $pks; - - // Include the content plugins for the change of state event. - JPluginHelper::importPlugin('content'); - - // Access checks. - foreach ($pks as $i => $pk) - { - $table->reset(); - - if ($table->load($pk)) - { - if (!$this->canEditState($table)) - { - // Prune items that you can't change. - unset($pks[$i]); - JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); - return false; - } - } - } - - // Attempt to change the state of the records. - if (!$table->publish($pks, $value, $user->get('id'))) - { - $this->setError($table->getError()); - return false; - } - - $context = $this->option . '.' . $this->name; - - // Trigger the onContentChangeState event. - $result = $dispatcher->trigger($this->event_change_state, array($context, $pks, $value)); - - if (in_array(false, $result, true)) - { - $this->setError($table->getError()); - return false; - } - - // Clear the component's cache - $this->cleanCache(); - - return true; - } - - /** - * Method to adjust the ordering of a row. - * - * Returns NULL if the user did not have edit - * privileges for any of the selected primary keys. - * - * @param integer $pks The ID of the primary key to move. - * @param integer $delta Increment, usually +1 or -1 - * - * @return mixed False on failure or error, true on success, null if the $pk is empty (no items selected). - * - * @since 11.1 - */ - public function reorder($pks, $delta = 0) - { - // Initialise variables. - $user = JFactory::getUser(); - $table = $this->getTable(); - $pks = (array) $pks; - $result = true; - - $allowed = true; - - foreach ($pks as $i => $pk) - { - $table->reset(); - - if ($table->load($pk) && $this->checkout($pk)) - { - // Access checks. - if (!$this->canEditState($table)) - { - // Prune items that you can't change. - unset($pks[$i]); - $this->checkin($pk); - JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); - $allowed = false; - continue; - } - - $where = array(); - $where = $this->getReorderConditions($table); - - if (!$table->move($delta, $where)) - { - $this->setError($table->getError()); - unset($pks[$i]); - $result = false; - } - - $this->checkin($pk); - } - else - { - $this->setError($table->getError()); - unset($pks[$i]); - $result = false; - } - } - - if ($allowed === false && empty($pks)) - { - $result = null; - } - - // Clear the component's cache - if ($result == true) - { - $this->cleanCache(); - } - - return $result; - } - - /** - * Method to save the form data. - * - * @param array $data The form data. - * - * @return boolean True on success, False on error. - * - * @since 11.1 - */ - public function save($data) - { - // Initialise variables; - $dispatcher = JDispatcher::getInstance(); - $table = $this->getTable(); - $key = $table->getKeyName(); - $pk = (!empty($data[$key])) ? $data[$key] : (int) $this->getState($this->getName() . '.id'); - $isNew = true; - - // Include the content plugins for the on save events. - JPluginHelper::importPlugin('content'); - - // Allow an exception to be thrown. - try - { - // Load the row if saving an existing record. - if ($pk > 0) - { - $table->load($pk); - $isNew = false; - } - - // Bind the data. - if (!$table->bind($data)) - { - $this->setError($table->getError()); - return false; - } - - // Prepare the row for saving - $this->prepareTable($table); - - // Check the data. - if (!$table->check()) - { - $this->setError($table->getError()); - return false; - } - - // Trigger the onContentBeforeSave event. - $result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, &$table, $isNew)); - if (in_array(false, $result, true)) - { - $this->setError($table->getError()); - return false; - } - - // Store the data. - if (!$table->store()) - { - $this->setError($table->getError()); - return false; - } - - // Clean the cache. - $this->cleanCache(); - - // Trigger the onContentAfterSave event. - $dispatcher->trigger($this->event_after_save, array($this->option . '.' . $this->name, &$table, $isNew)); - } - catch (Exception $e) - { - $this->setError($e->getMessage()); - - return false; - } - - $pkName = $table->getKeyName(); - - if (isset($table->$pkName)) - { - $this->setState($this->getName() . '.id', $table->$pkName); - } - $this->setState($this->getName() . '.new', $isNew); - - return true; - } - - /** - * Saves the manually set order of records. - * - * @param array $pks An array of primary key ids. - * @param integer $order +1 or -1 - * - * @return mixed - * - * @since 11.1 - */ - function saveorder($pks = null, $order = null) - { - // Initialise variables. - $table = $this->getTable(); - $conditions = array(); - $user = JFactory::getUser(); - - if (empty($pks)) - { - return JError::raiseWarning(500, JText::_($this->text_prefix . '_ERROR_NO_ITEMS_SELECTED')); - } - - // update ordering values - foreach ($pks as $i => $pk) - { - $table->load((int) $pk); - - // Access checks. - if (!$this->canEditState($table)) - { - // Prune items that you can't change. - unset($pks[$i]); - JError::raiseWarning(403, JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED')); - } - elseif ($table->ordering != $order[$i]) - { - $table->ordering = $order[$i]; - - if (!$table->store()) - { - $this->setError($table->getError()); - return false; - } - - // Remember to reorder within position and client_id - $condition = $this->getReorderConditions($table); - $found = false; - - foreach ($conditions as $cond) - { - if ($cond[1] == $condition) - { - $found = true; - break; - } - } - - if (!$found) - { - $key = $table->getKeyName(); - $conditions[] = array($table->$key, $condition); - } - } - } - - // Execute reorder for each category. - foreach ($conditions as $cond) - { - $table->load($cond[0]); - $table->reorder($cond[1]); - } - - // Clear the component's cache - $this->cleanCache(); - - return true; - } -} diff --git a/platform/libraries/joomla/application/component/modelform.php b/platform/libraries/joomla/application/component/modelform.php deleted file mode 100644 index 2895fd5..0000000 --- a/platform/libraries/joomla/application/component/modelform.php +++ /dev/null @@ -1,287 +0,0 @@ -getTable(); - if (!$table->load($pk)) - { - $this->setError($table->getError()); - return false; - } - - // Check if this is the user having previously checked out the row. - if ($table->checked_out > 0 && $table->checked_out != $user->get('id') && !$user->authorise('core.admin', 'com_checkin')) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_CHECKIN_USER_MISMATCH')); - return false; - } - - // Attempt to check the row in. - if (!$table->checkin($pk)) - { - $this->setError($table->getError()); - return false; - } - } - - return true; - } - - /** - * Method to check-out a row for editing. - * - * @param integer $pk The numeric id of the primary key. - * - * @return boolean False on failure or error, true otherwise. - * - * @since 11.1 - */ - public function checkout($pk = null) - { - // Only attempt to check the row in if it exists. - if ($pk) - { - $user = JFactory::getUser(); - - // Get an instance of the row to checkout. - $table = $this->getTable(); - if (!$table->load($pk)) - { - $this->setError($table->getError()); - return false; - } - - // Check if this is the user having previously checked out the row. - if ($table->checked_out > 0 && $table->checked_out != $user->get('id')) - { - $this->setError(JText::_('JLIB_APPLICATION_ERROR_CHECKOUT_USER_MISMATCH')); - return false; - } - - // Attempt to check the row out. - if (!$table->checkout($user->get('id'), $pk)) - { - $this->setError($table->getError()); - return false; - } - } - - return true; - } - - /** - * Abstract method for getting the form from the model. - * - * @param array $data Data for the form. - * @param boolean $loadData True if the form is to load its own data (default case), false if not. - * - * @return mixed A JForm object on success, false on failure - * - * @since 11.1 - */ - abstract public function getForm($data = array(), $loadData = true); - - /** - * Method to get a form object. - * - * @param string $name The name of the form. - * @param string $source The form source. Can be XML string if file flag is set to false. - * @param array $options Optional array of options for the form creation. - * @param boolean $clear Optional argument to force load a new form. - * @param string $xpath An optional xpath to search for the fields. - * - * @return mixed JForm object on success, False on error. - * - * @see JForm - * @since 11.1 - */ - protected function loadForm($name, $source = null, $options = array(), $clear = false, $xpath = false) - { - // Handle the optional arguments. - $options['control'] = JArrayHelper::getValue($options, 'control', false); - - // Create a signature hash. - $hash = md5($source . serialize($options)); - - // Check if we can use a previously loaded form. - if (isset($this->_forms[$hash]) && !$clear) - { - return $this->_forms[$hash]; - } - - // Get the form. - JForm::addFormPath(JPATH_COMPONENT . '/models/forms'); - JForm::addFieldPath(JPATH_COMPONENT . '/models/fields'); - - try - { - $form = JForm::getInstance($name, $source, $options, false, $xpath); - - if (isset($options['load_data']) && $options['load_data']) - { - // Get the data for the form. - $data = $this->loadFormData(); - } - else - { - $data = array(); - } - - // Allow for additional modification of the form, and events to be triggered. - // We pass the data because plugins may require it. - $this->preprocessForm($form, $data); - - // Load the data into the form after the plugins have operated. - $form->bind($data); - - } - catch (Exception $e) - { - $this->setError($e->getMessage()); - return false; - } - - // Store the form for later. - $this->_forms[$hash] = $form; - - return $form; - } - - /** - * Method to get the data that should be injected in the form. - * - * @return array The default data is an empty array. - * - * @since 11.1 - */ - protected function loadFormData() - { - return array(); - } - - /** - * Method to allow derived classes to preprocess the form. - * - * @param object $form A form object. - * @param mixed $data The data expected for the form. - * @param string $group The name of the plugin group to import (defaults to "content"). - * - * @return void - * - * @see JFormField - * @since 11.1 - * @throws Exception if there is an error in the form event. - */ - protected function preprocessForm(JForm $form, $data, $group = 'content') - { - // Import the approriate plugin group. - JPluginHelper::importPlugin($group); - - // Get the dispatcher. - $dispatcher = JDispatcher::getInstance(); - - // Trigger the form preparation event. - $results = $dispatcher->trigger('onContentPrepareForm', array($form, $data)); - - // Check for errors encountered while preparing the form. - if (count($results) && in_array(false, $results, true)) - { - // Get the last error. - $error = $dispatcher->getError(); - - // Convert to a JException if necessary. - if (!JError::isError($error)) - { - throw new Exception($error); - } - } - } - - /** - * Method to validate the form data. - * - * @param object $form The form to validate against. - * @param array $data The data to validate. - * @param string $group The name of the field group to validate. - * - * @return mixed Array of filtered data if valid, false otherwise. - * - * @see JFormRule - * @see JFilterInput - * @since 11.1 - */ - function validate($form, $data, $group = null) - { - // Filter and validate the form data. - $data = $form->filter($data); - $return = $form->validate($data, $group); - - // Check for an error. - if (JError::isError($return)) - { - $this->setError($return->getMessage()); - return false; - } - - // Check the validation results. - if ($return === false) - { - // Get the validation messages from the form. - foreach ($form->getErrors() as $message) - { - $this->setError(JText::_($message)); - } - - return false; - } - - return $data; - } -} diff --git a/platform/libraries/joomla/application/component/modelitem.php b/platform/libraries/joomla/application/component/modelitem.php deleted file mode 100644 index 341510d..0000000 --- a/platform/libraries/joomla/application/component/modelitem.php +++ /dev/null @@ -1,57 +0,0 @@ -filter_fields = $config['filter_fields']; - } - - // Guess the context as Option.ModelName. - if (empty($this->context)) - { - $this->context = strtolower($this->option . '.' . $this->getName()); - } - } - - /** - * Method to cache the last query constructed. - * - * This method ensures that the query is contructed only once for a given state of the model. - * - * @return JDatabaseQuery A JDatabaseQuery object - * - * @since 11.1 - */ - protected function _getListQuery() - { - // Capture the last store id used. - static $lastStoreId; - - // Compute the current store id. - $currentStoreId = $this->getStoreId(); - - // If the last store id is different from the current, refresh the query. - if ($lastStoreId != $currentStoreId || empty($this->query)) - { - $lastStoreId = $currentStoreId; - $this->query = $this->getListQuery(); - } - - return $this->query; - } - - /** - * Method to get an array of data items. - * - * @return mixed An array of data items on success, false on failure. - * - * @since 11.1 - */ - public function getItems() - { - // Get a storage key. - $store = $this->getStoreId(); - - // Try to load the data from internal storage. - if (!empty($this->cache[$store])) - { - return $this->cache[$store]; - } - - // Load the list items. - $query = $this->_getListQuery(); - $items = $this->_getList($query, $this->getStart(), $this->getState('list.limit')); - - // Check for a database error. - if ($this->_db->getErrorNum()) - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - // Add the items to the internal cache. - $this->cache[$store] = $items; - - return $this->cache[$store]; - } - - /** - * Method to get a JDatabaseQuery object for retrieving the data set from a database. - * - * @return JDatabaseQuery A JDatabaseQuery object to retrieve the data set. - * - * @since 11.1 - */ - protected function getListQuery() - { - $db = $this->getDbo(); - $query = $db->getQuery(true); - - return $query; - } - - /** - * Method to get a JPagination object for the data set. - * - * @return JPagination A JPagination object for the data set. - * - * @since 11.1 - */ - public function getPagination() - { - // Get a storage key. - $store = $this->getStoreId('getPagination'); - - // Try to load the data from internal storage. - if (!empty($this->cache[$store])) - { - return $this->cache[$store]; - } - - // Create the pagination object. - jimport('joomla.html.pagination'); - $limit = (int) $this->getState('list.limit') - (int) $this->getState('list.links'); - $page = new JPagination($this->getTotal(), $this->getStart(), $limit); - - // Add the object to the internal cache. - $this->cache[$store] = $page; - - return $this->cache[$store]; - } - - /** - * Method to get a store id based on the model configuration state. - * - * This is necessary because the model is used by the component and - * different modules that might need different sets of data or different - * ordering requirements. - * - * @param string $id An identifier string to generate the store id. - * - * @return string A store id. - * - * @since 11.1 - */ - protected function getStoreId($id = '') - { - // Add the list state to the store id. - $id .= ':' . $this->getState('list.start'); - $id .= ':' . $this->getState('list.limit'); - $id .= ':' . $this->getState('list.ordering'); - $id .= ':' . $this->getState('list.direction'); - - return md5($this->context . ':' . $id); - } - - /** - * Method to get the total number of items for the data set. - * - * @return integer The total number of items available in the data set. - * - * @since 11.1 - */ - public function getTotal() - { - // Get a storage key. - $store = $this->getStoreId('getTotal'); - - // Try to load the data from internal storage. - if (!empty($this->cache[$store])) - { - return $this->cache[$store]; - } - - // Load the total. - $query = $this->_getListQuery(); - $total = (int) $this->_getListCount($query); - - // Check for a database error. - if ($this->_db->getErrorNum()) - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - // Add the total to the internal cache. - $this->cache[$store] = $total; - - return $this->cache[$store]; - } - - /** - * Method to get the starting number of items for the data set. - * - * @return integer The starting number of items available in the data set. - * - * @since 11.1 - */ - public function getStart() - { - $store = $this->getStoreId('getstart'); - - // Try to load the data from internal storage. - if (!empty($this->cache[$store])) - { - return $this->cache[$store]; - } - - $start = $this->getState('list.start'); - $limit = $this->getState('list.limit'); - $total = $this->getTotal(); - if ($start > $total - $limit) - { - $start = max(0, (int) (ceil($total / $limit) - 1) * $limit); - } - - // Add the total to the internal cache. - $this->cache[$store] = $start; - - return $this->cache[$store]; - } - - /** - * Method to auto-populate the model state. - * - * This method should only be called once per instantiation and is designed - * to be called on the first call to the getState() method unless the model - * configuration flag to ignore the request is set. - * - * Note. Calling getState in this method will result in recursion. - * - * @param string $ordering An optional ordering field. - * @param string $direction An optional direction (asc|desc). - * - * @return void - * - * @since 11.1 - */ - protected function populateState($ordering = null, $direction = null) - { - // If the context is set, assume that stateful lists are used. - if ($this->context) - { - $app = JFactory::getApplication(); - - $value = $app->getUserStateFromRequest('global.list.limit', 'limit', $app->getCfg('list_limit')); - $limit = $value; - $this->setState('list.limit', $limit); - - $value = $app->getUserStateFromRequest($this->context . '.limitstart', 'limitstart', 0); - $limitstart = ($limit != 0 ? (floor($value / $limit) * $limit) : 0); - $this->setState('list.start', $limitstart); - - // Check if the ordering field is in the white list, otherwise use the incoming value. - $value = $app->getUserStateFromRequest($this->context . '.ordercol', 'filter_order', $ordering); - if (!in_array($value, $this->filter_fields)) - { - $value = $ordering; - $app->setUserState($this->context . '.ordercol', $value); - } - $this->setState('list.ordering', $value); - - // Check if the ordering direction is valid, otherwise use the incoming value. - $value = $app->getUserStateFromRequest($this->context . '.orderdirn', 'filter_order_Dir', $direction); - if (!in_array(strtoupper($value), array('ASC', 'DESC', ''))) - { - $value = $direction; - $app->setUserState($this->context . '.orderdirn', $value); - } - $this->setState('list.direction', $value); - } - else - { - $this->setState('list.start', 0); - $this->state->set('list.limit', 0); - } - } - - /** - * Gets the value of a user state variable and sets it in the session - * - * This is the same as the method in JApplication except that this also can optionally - * force you back to the first page when a filter has changed - * - * @param string $key The key of the user state variable. - * @param string $request The name of the variable passed in a request. - * @param string $default The default value for the variable if not found. Optional. - * @param string $type Filter for the variable, for valid values see {@link JFilterInput::clean()}. Optional. - * @param boolean $resetPage If true, the limitstart in request is set to zero - * - * @return The request user state. - * - * @since 11.1 - */ - public function getUserStateFromRequest($key, $request, $default = null, $type = 'none', $resetPage = true) - { - $app = JFactory::getApplication(); - $old_state = $app->getUserState($key); - $cur_state = (!is_null($old_state)) ? $old_state : $default; - $new_state = JRequest::getVar($request, null, 'default', $type); - - if (($cur_state != $new_state) && ($resetPage)) - { - JRequest::setVar('limitstart', 0); - } - - // Save the new value only if it is set in this request. - if ($new_state !== null) - { - $app->setUserState($key, $new_state); - } - else - { - $new_state = $cur_state; - } - - return $new_state; - } -} diff --git a/platform/libraries/joomla/application/component/view.php b/platform/libraries/joomla/application/component/view.php deleted file mode 100644 index 70ea943..0000000 --- a/platform/libraries/joomla/application/component/view.php +++ /dev/null @@ -1,786 +0,0 @@ - array(), 'helper' => array()); - - /** - * The name of the default template source file. - * - * @var string - */ - protected $_template = null; - - /** - * The output of the template script. - * - * @var string - */ - protected $_output = null; - - /** - * Callback for escaping. - * - * @var string - */ - protected $_escape = 'htmlspecialchars'; - - /** - * Charset to use in escaping mechanisms; defaults to urf8 (UTF-8) - * - * @var string - */ - protected $_charset = 'UTF-8'; - - /** - * Constructor - * - * @param array $config A named configuration array for object contruction.
    - * name: the name (optional) of the view (defaults to the view class name suffix).
    - * charset: the characterset to use for display
    - * escape: the name (optional) of the function to use for escaping strings
    - * base_path: the parent path (optional) of the views directory (defaults to the component folder)
    - * template_plath: the path (optional) of the layout directory (defaults to base_path + /views/ + view name
    - * helper_path: the path (optional) of the helper files (defaults to base_path + /helpers/)
    - * layout: the layout (optional) to use to display the view
    - * - * @return JView - * - * @since 11.1 - */ - public function __construct($config = array()) - { - // Set the view name - if (empty($this->_name)) - { - if (array_key_exists('name', $config)) - { - $this->_name = $config['name']; - } - else - { - $this->_name = $this->getName(); - } - } - - // Set the charset (used by the variable escaping functions) - if (array_key_exists('charset', $config)) - { - $this->_charset = $config['charset']; - } - - // User-defined escaping callback - if (array_key_exists('escape', $config)) - { - $this->setEscape($config['escape']); - } - - // Set a base path for use by the view - if (array_key_exists('base_path', $config)) - { - $this->_basePath = $config['base_path']; - } - else - { - $this->_basePath = JPATH_COMPONENT; - } - - // Set the default template search path - if (array_key_exists('template_path', $config)) - { - // User-defined dirs - $this->_setPath('template', $config['template_path']); - } - else - { - $this->_setPath('template', $this->_basePath . '/views/' . $this->getName() . '/tmpl'); - } - - // Set the default helper search path - if (array_key_exists('helper_path', $config)) - { - // User-defined dirs - $this->_setPath('helper', $config['helper_path']); - } - else - { - $this->_setPath('helper', $this->_basePath . '/helpers'); - } - - // Set the layout - if (array_key_exists('layout', $config)) - { - $this->setLayout($config['layout']); - } - else - { - $this->setLayout('default'); - } - - $this->baseurl = JURI::base(true); - } - - /** - * Execute and display a template script. - * - * @param string $tpl The name of the template file to parse; automatically searches through the template paths. - * - * @return mixed A string if successful, otherwise a JError object. - * - * @see fetch() - * @since 11.1 - */ - function display($tpl = null) - { - $result = $this->loadTemplate($tpl); - if (JError::isError($result)) - { - return $result; - } - - echo $result; - } - - /** - * Assigns variables to the view script via differing strategies. - * - * This method is overloaded; you can assign all the properties of - * an object, an associative array, or a single value by name. - * - * You are not allowed to set variables that begin with an underscore; - * these are either private properties for JView or private variables - * within the template script itself. - * - * - * $view = new JView; - * - * // Assign directly - * $view->var1 = 'something'; - * $view->var2 = 'else'; - * - * // Assign by name and value - * $view->assign('var1', 'something'); - * $view->assign('var2', 'else'); - * - * // Assign by assoc-array - * $ary = array('var1' => 'something', 'var2' => 'else'); - * $view->assign($obj); - * - * // Assign by object - * $obj = new stdClass; - * $obj->var1 = 'something'; - * $obj->var2 = 'else'; - * $view->assign($obj); - * - * - * - * @return boolean True on success, false on failure. - */ - public function assign() - { - // Get the arguments; there may be 1 or 2. - $arg0 = @func_get_arg(0); - $arg1 = @func_get_arg(1); - - // Assign by object - if (is_object($arg0)) - { - // Assign public properties - foreach (get_object_vars($arg0) as $key => $val) - { - if (substr($key, 0, 1) != '_') - { - $this->$key = $val; - } - } - return true; - } - - // Assign by associative array - if (is_array($arg0)) - { - foreach ($arg0 as $key => $val) - { - if (substr($key, 0, 1) != '_') - { - $this->$key = $val; - } - } - return true; - } - - // Assign by string name and mixed value. - - // We use array_key_exists() instead of isset() becuase isset() - // fails if the value is set to null. - if (is_string($arg0) && substr($arg0, 0, 1) != '_' && func_num_args() > 1) - { - $this->$arg0 = $arg1; - return true; - } - - // $arg0 was not object, array, or string. - return false; - } - - /** - * Assign variable for the view (by reference). - * - * You are not allowed to set variables that begin with an underscore; - * these are either private properties for JView or private variables - * within the template script itself. - * - * - * $view = new JView; - * - * // Assign by name and value - * $view->assignRef('var1', $ref); - * - * // Assign directly - * $view->ref = &$var1; - * - * - * @param string $key The name for the reference in the view. - * @param mixed &$val The referenced variable. - * - * @return boolean True on success, false on failure. - * - * @since 11.1 - */ - public function assignRef($key, &$val) - { - if (is_string($key) && substr($key, 0, 1) != '_') - { - $this->$key = &$val; - return true; - } - - return false; - } - - /** - * Escapes a value for output in a view script. - * - * If escaping mechanism is either htmlspecialchars or htmlentities, uses - * {@link $_encoding} setting. - * - * @param mixed $var The output to escape. - * - * @return mixed The escaped value. - * - * @since 11.1 - */ - function escape($var) - { - if (in_array($this->_escape, array('htmlspecialchars', 'htmlentities'))) - { - return call_user_func($this->_escape, $var, ENT_COMPAT, $this->_charset); - } - - return call_user_func($this->_escape, $var); - } - - /** - * Method to get data from a registered model or a property of the view - * - * @param string $property The name of the method to call on the model or the property to get - * @param string $default The name of the model to reference or the default value [optional] - * - * @return mixed The return value of the method - * - * @since 11.1 - */ - public function get($property, $default = null) - { - - // If $model is null we use the default model - if (is_null($default)) - { - $model = $this->_defaultModel; - } - else - { - $model = strtolower($default); - } - - // First check to make sure the model requested exists - if (isset($this->_models[$model])) - { - // Model exists, let's build the method name - $method = 'get' . ucfirst($property); - - // Does the method exist? - if (method_exists($this->_models[$model], $method)) - { - // The method exists, let's call it and return what we get - $result = $this->_models[$model]->$method(); - return $result; - } - - } - - // Degrade to JObject::get - $result = parent::get($property, $default); - - return $result; - } - - /** - * Method to get the model object - * - * @param string $name The name of the model (optional) - * - * @return mixed JModel object - * - * @since 11.1 - */ - public function getModel($name = null) - { - if ($name === null) - { - $name = $this->_defaultModel; - } - return $this->_models[strtolower($name)]; - } - - /** - * Get the layout. - * - * @return string The layout name - */ - public function getLayout() - { - return $this->_layout; - } - - /** - * Get the layout template. - * - * @return string The layout template name - */ - public function getLayoutTemplate() - { - return $this->_layoutTemplate; - } - - /** - * Method to get the view name - * - * The model name by default parsed using the classname, or it can be set - * by passing a $config['name'] in the class constructor - * - * @return string The name of the model - * - * @since 11.1 - */ - public function getName() - { - $name = $this->_name; - - if (empty($name)) - { - $r = null; - if (!preg_match('/View((view)*(.*(view)?.*))$/i', get_class($this), $r)) - { - JError::raiseError(500, JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME')); - } - if (strpos($r[3], "view")) - { - JError::raiseWarning('SOME_ERROR_CODE', JText::_('JLIB_APPLICATION_ERROR_VIEW_GET_NAME_SUBSTRING')); - } - $name = strtolower($r[3]); - } - - return $name; - } - - /** - * Method to add a model to the view. We support a multiple model single - * view system by which models are referenced by classname. A caveat to the - * classname referencing is that any classname prepended by JModel will be - * referenced by the name without JModel, eg. JModelCategory is just - * Category. - * - * @param object &$model The model to add to the view. - * @param boolean $default Is this the default model? - * - * @return object The added model. - * - * @since 11.1 - */ - public function setModel(&$model, $default = false) - { - $name = strtolower($model->getName()); - $this->_models[$name] = &$model; - - if ($default) - { - $this->_defaultModel = $name; - } - return $model; - } - - /** - * Sets the layout name to use - * - * @param string $layout The layout name or a string in format