Пример #1
0
 * @subpackage DemoTrain
 * @access public
 * @author Carl Leitner <*****@*****.**>
 * @copyright Copyright &copy; 2007, 2008 IntraHealth International, Inc. 
 * @since Demo-v2.a
 * @version Demo-v2.a
 */
$i2ce_site_user_access_init = null;
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'config.values.php';
$local_config = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'local' . DIRECTORY_SEPARATOR . 'config.values.php';
if (file_exists($local_config)) {
    require_once $local_config;
}
if (!isset($i2ce_site_i2ce_path) || !is_dir($i2ce_site_i2ce_path)) {
    echo "Please set the \$i2ce_site_i2ce_path in {$local_config}";
    exit(55);
}
require_once $i2ce_site_i2ce_path . DIRECTORY_SEPARATOR . 'I2CE_config.inc.php';
@I2CE::initializeDSN($i2ce_site_dsn, $i2ce_site_user_access_init, $i2ce_site_module_config);
unset($i2ce_site_user_access_init);
unset($i2ce_site_dsn);
unset($i2ce_site_i2ce_path);
unset($i2ce_site_module_config);
@($page = new I2CE_Wrangler());
@$page->wrangle();
# Local Variables:
# mode: php
# c-default-style: "bsd"
# indent-tabs-mode: nil
# c-basic-offset: 4
# End:
Пример #2
0
 public function display($supress_output = false)
 {
     if (!array_key_exists('HTTP_HOST', $_SERVER)) {
         exit("No command line usage for this page");
     }
     foreach (array('request', 'content') as $key) {
         if (!$this->get_exists($key)) {
             I2CE::raiseError("Invalid Stub request:  {$key} is missing");
             return false;
         }
     }
     $value = $this->get('content');
     $req = array_pad(explode('?', $this->request('request')), 2, '');
     list($req, $query_str) = $req;
     $get = array();
     if ($query_str) {
         parse_str($query_str, $get);
     }
     $post = array();
     if ($this->isPost()) {
         I2CE_Util::flattenVariables($this->post, $post, false);
     }
     if (count($this->request_remainder) > 0) {
         $attribute = $this->request_remainder[0];
     } else {
         $attribute = 'id';
     }
     if (strpos($value, ',')) {
         $values = explode(',', $value);
         $value = array();
         foreach ($values as $val) {
             list($a, $v) = array_pad(explode('=', $val, 2), 2, '');
             if (!$v) {
                 $v = $a;
                 $a = $attribute;
             }
             if (!array_key_exists($a, $value) || !is_array($value[$a])) {
                 $value[$a] = array();
             }
             $value[$a][] = $v;
         }
     } else {
         $value = array($attribute => array($value));
     }
     $js = false;
     if ($this->get_exists('keep_javascripts')) {
         $js = $this->get('keep_javascripts');
     }
     $wrangler = new I2CE_Wrangler();
     $page = $wrangler->wrangle($req, false, $get, $post);
     if (!$page instanceof I2CE_Page) {
         $this->userMessage("Unable to find requested page", 'notice');
         I2CE::raiseError("Unable to create page");
         exit;
     }
     $page->setIsPost($this->isPost());
     $page->display(true);
     foreach ($value as $a => &$vals) {
         if (!is_array($vals) || count($vals) == 0) {
             unset($vals[$a]);
             continue;
         }
         $vals = array_map('addslashes', $vals);
         $vals = "(@{$a}='" . implode("' or @{$a}='", $vals) . "')";
     }
     if (count($value) == 0) {
         $this->userMessage("Nothing selected to return");
         I2CE::raiseError("Nothing selected to return");
         exit;
     }
     $qry = '//*[(' . implode(' or ', $value) . ")]";
     $list = $page->getTemplate()->query($qry);
     $nodes = 0;
     if ($list instanceof DOMNodeList) {
         $nodes += $list->length;
     }
     $scriptNodeList = null;
     if ($js) {
         $js_ids = explode(',', $js);
         $qry = '/html/head//script[@id="' . implode('" or @id="', $js_ids) . '"]';
         $scriptNodeList = $page->getTemplate()->query($qry);
         if ($scriptNodeList instanceof DOMNodeList) {
             $nodes += $scriptNodeList->length;
         }
     }
     if ($nodes == 0) {
         I2CE::raiseError("Requested page content not found: " . implode(' or ', $value) . " for request " . $this->module . '/' . $this->page . '/' . implode('/', $this->request_remainder));
         exit;
     }
     $doc = new DOMDocument();
     if ($scriptNodeList instanceof DOMNodeList) {
         for ($i = 0; $i < $scriptNodeList->length; $i++) {
             $scriptNode = $doc->importNode($scriptNodeList->item($i), true);
             $doc->appendChild($scriptNode);
         }
     }
     if ($list instanceof DOMNodeList) {
         for ($i = 0; $i < $list->length; $i++) {
             $doc->appendChild($doc->importNode($list->item($i), true));
         }
     }
     echo $doc->saveHTML();
 }