Beispiel #1
0
 /**
  * Handles creating hte I2CE_TemplateMeister templates and loading any default templates
  * @returns boolean true on success
  */
 protected function initializeTemplate()
 {
     if (array_key_exists('defaultHTMLFile', $this->args) && $this->args['defaultHTMLFile']) {
         $this->defaultHTMLFile = $this->args['defaultHTMLFile'];
     } else {
         $this->defaultHTMLFile = false;
     }
     if (!isset($this->args['templates'])) {
         $this->args['templates'] = array('');
     }
     if (is_scalar($this->args['templates'])) {
         $this->args['templates'] = array($this->args['templates']);
     }
     if (isset($this->args['template'])) {
         $template = $this->args['template'];
     } else {
         $template = 'I2CE_Template';
     }
     $this->template = new $template();
     if (!$this->template instanceof I2CE_TemplateMeister) {
         I2CE::raiseError("Could not make template {$template}");
         return false;
     }
     $this->template->setUser($this->user);
     if (array_key_exists(0, $this->args['templates']) && $this->args['templates'][0]) {
         $this->template->loadRootFile($this->args['templates'][0]);
     } else {
         $this->template->loadRootText('');
     }
     for ($i = 1; $i < count($this->args['templates']); $i++) {
         $this->template->addFile($this->args['templates'][$i]);
     }
     $this->template->processArgs($this->args);
     return true;
 }
 *
 *****************************************/
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'CLI.php';
require_once dirname(__FILE__) . '/../lib/I2CE.php';
require_once dirname(__FILE__) . '/../lib/I2CE_FileSearch.php';
require_once dirname(__FILE__) . '/../lib/I2CE_TemplateMeister.php';
require_once dirname(__FILE__) . '/../lib/I2CE_MagicDataTemplate.php';
require_once dirname(__FILE__) . '/../modules/Pages/lib/I2CE_Template.php';
require_once dirname(__FILE__) . '/../modules/MagicDataExport/I2CE_MagicDataExport_Template.php';
if (count($arg_files) != 1) {
    usage("Please specify list html");
}
$in_file = realpath($arg_files[0]);
$out_file = dirname($in_file) . '/' . basename($in_file, '.html') . '.xml';
$template = new I2CE_Template();
$template->loadRootFile($in_file);
$data = array();
foreach ($template->query('//li/a') as $a) {
    $li = $a->parentNode;
    $href = $a->getAttribute('href');
    $comp = parse_url($href);
    if (!is_array($comp) || !array_key_exists('query', $comp) || !$comp['query'] || $li->tagName != 'li') {
        echo "Skipping(0): " . $a->textContent . " : href=" . $href . "\n";
        continue;
    }
    $qry = array();
    parse_str($comp['query'], $qry);
    if (!is_array($qry) || !array_key_exists('type', $qry)) {
        echo "Skipping(1): " . $a->textContent . " : href=" . $href . "\n";
        continue;
    }