Esempio n. 1
0
 private function build_xml_nav(&$obj, $dir_structure, $url, $depth, $index, $mod_string)
 {
     // Initialize basic variables
     $mod_depth = $depth / 2;
     $num_elements = count($dir_structure['mods']);
     // Start XML for this module
     $tmp = new gen_element('module', '', array('index' => $index, 'depth' => $depth));
     $tmp->display_tree();
     // Output all necessary data for this module
     $tmp->add_child(new gen_element('url', $url));
     $tmp->add_child(new gen_element('mod_string', $mod_string));
     $tmp->add_child(new gen_element('title', $dir_structure['title']));
     $tmp->add_child(new gen_element('dir', $dir_structure['dir']));
     $depth += 2;
     // Recursively build the module XML for all submodules of this module
     if ($num_elements > 0) {
         $tmp2 = new gen_element('sub_modules');
         $tmp2->display_tree();
         foreach ($dir_structure['mods'] as $key => $value) {
             $tmp_dir = $value['dir'];
             // Build URL
             if ($url == '/') {
                 if ($this->nav_type == 'rewrite') {
                     $new_url = $url . "{$tmp_dir}/";
                     $new_mod_string = $tmp_dir;
                 } else {
                     if ($this->nav_type == 'long_url') {
                         $new_url = $url . "index.php/{$tmp_dir}/";
                         $new_mod_string = $tmp_dir;
                     } else {
                         $new_url = $url . "?mod={$key}";
                         $new_mod_string = $key;
                     }
                 }
             } else {
                 if ($this->nav_type == 'rewrite' || $this->nav_type == 'long_url') {
                     $new_url = $url . "{$tmp_dir}/";
                     $new_mod_string = $mod_string . "/{$tmp_dir}";
                 } else {
                     if ($this->nav_type == 'long_url') {
                         $new_url = $url . "index.php/{$tmp_dir}/";
                         $new_mod_string = $tmp_dir;
                     } else {
                         $new_url = $url . "-{$key}";
                         $new_mod_string = $mod_string . "-{$key}";
                     }
                 }
             }
             $this->build_xml_nav($tmp2, $dir_structure['mods'][$key], $new_url, $depth, $key, $new_mod_string);
         }
         $tmp->add_child($tmp2);
     }
     // End the XML for this module
     $obj->add_child($tmp);
 }
Esempio n. 2
0
 public function render($buffer = false)
 {
     //============================================================
     // Form Label
     //============================================================
     if (isset($this->form_label)) {
         $this->add_child(xhe('form_label', $this->form_label));
     }
     //============================================================
     // Hidden Form Elements
     //============================================================
     $hid_elements = new gen_element('hidden_elements');
     $hid_elements->display_tree();
     foreach ($this->hidden_elements as $hid_element) {
         ob_start();
         $this->process_element($hid_element);
         $tmp_element = !empty($this->xsl_template) ? $this->xml_escape(ob_get_clean()) : ob_get_clean();
         $tmp_element = trim($tmp_element);
         $tmp_he = new gen_element('hid_element', $tmp_element);
         $tmp_he->display_tree();
         $hid_elements->add_child($tmp_he);
     }
     $this->add_child($hid_elements);
     //============================================================
     // Process Visible Form Elements
     //============================================================
     $elements = new gen_element('form_elements');
     $elements->display_tree();
     foreach ($this->form_elements as $element) {
         //-----------------------------------------------------
         // Validate Each Element
         //-----------------------------------------------------
         if (!is_array($element) || is_array($element) && count($element) < 2) {
             continue;
         }
         //-----------------------------------------------------
         // Process the element
         //-----------------------------------------------------
         ob_start();
         $this->process_element($element[0]);
         $tmp_element = ob_get_clean();
         //-----------------------------------------------------
         // Build Form Element into XML and add it to Tree
         //-----------------------------------------------------
         $fe_attrs = array();
         $fe_content = trim($tmp_element);
         $content_empty = $fe_content == '' ? true : false;
         if ($fe_content != '' && !empty($this->xsl_template)) {
             $fe_content = xml_escape($fe_content);
         }
         $fe_attrs = isset($element[2]) && is_array($element[2]) ? $element[2] : array();
         $tmp_fe = new gen_element($element[1], $fe_content, $fe_attrs);
         if (substr($element[1], 0, 4) != 'end_' && !$content_empty) {
             $tmp_fe->display_tree();
         }
         $elements->add_child($tmp_fe);
     }
     $this->add_child($elements);
     //============================================================
     // Call Parent Render Function
     //============================================================
     return parent::render($buffer);
 }
Esempio n. 3
0
 public function content_constructor()
 {
     $this->content_xml = array();
     //============================================================
     // Pre-module Include Script (pre_module.inc.php)
     //============================================================
     $pre_mod_inc = "{$this->file_path}/{$this->mods_dir}/pre_module.inc.php";
     if (file_exists($pre_mod_inc)) {
         require_once $pre_mod_inc;
     }
     //============================================================
     // Was the intended module controller found?
     //============================================================
     $this->content_xml[] = new gen_element('mod_controller_found', $this->mod_controller_found);
     //============================================================
     // Current Module Parameters
     //============================================================
     $this->content_xml[] = new gen_element('current_module', $this->mod);
     if ($this->mod == '-1') {
         $tmp_mod_args = array('-1');
     } else {
         $ex_chr = $this->nav_xml_format == 'rewrite' ? '/' : '-';
         $tmp_mod_args = explode($ex_chr, $this->mod);
     }
     //============================================================
     // Current Module Depth
     //============================================================
     $curr_mod_depth = count($tmp_mod_args);
     $this->content_xml[] = new gen_element('current_module_depth', $curr_mod_depth);
     //============================================================
     // Current Module Arguments
     //============================================================
     $tmp = new gen_element('current_module_args');
     $tmp->display_tree();
     foreach ($tmp_mod_args as $key => $arg) {
         $index_key = $key + 1;
         $tmp->add_child(new gen_element('module_arg', $arg, array('index' => $index_key)));
     }
     $this->content_xml[] = $tmp;
     //============================================================
     // Start Content Block
     //============================================================
     $content_node = new gen_element('content');
     $content_node->display_tree();
     //============================================================
     // Section Title
     //============================================================
     $local_inc = $this->local_file_path . 'local.inc.php';
     if (file_exists($local_inc)) {
         include $local_inc;
     }
     if (isset($mod_title)) {
         $tmp2 = new gen_element('section_title');
         $tmp2->display_tree();
         $tmp2->add_child(new gen_element('linkhref', $this->page_url));
         $tmp2->add_child(new gen_element('desc', $mod_title));
         $content_node->add_child($tmp2);
     }
     //============================================================
     // Controller Exists
     //============================================================
     if (file_exists($this->mod_controller)) {
         //--------------------------------------------------------
         // Module Exists
         //--------------------------------------------------------
         $content_node->add_child(new gen_element('controller_exists', 1));
         define('CONTROLLER_EXISTS', true);
         //--------------------------------------------------------
         // Set $_GET and $_POST arrays to local variables
         // GET first, then POST to prevent GET variables over writing POST variables
         //--------------------------------------------------------
         extract($_GET, EXTR_PREFIX_SAME, "GET_");
         extract($_POST, EXTR_PREFIX_SAME, "POST_");
         //--------------------------------------------------------
         // Include local controller
         //--------------------------------------------------------
         ob_start();
         if (!$this->skip_mod_controller) {
             require_once $this->mod_controller;
         }
         //--------------------------------------------------------
         // Perform an XML Transformation if necessary
         //--------------------------------------------------------
         if (isset($this->content_xsl) && !empty($this->content_xsl)) {
             $tmp_xml = ob_get_clean();
             ob_start();
             xml_transform($tmp_xml, $this->content_xsl);
         }
         $tmp_content = ob_get_clean();
         $content_node->add_child(new gen_element('content_data', xml_escape($tmp_content)));
         $this->content_xml[] = $content_node;
     } else {
         $content_node->add_child(new gen_element('controller_exists', 0));
         define('CONTROLLER_EXISTS', false);
     }
     //============================================================
     // Post-module Include Script (post_module.inc.php)
     //============================================================
     $post_mod_inc = "{$this->file_path}/{$this->mods_dir}/post_module.inc.php";
     if (file_exists($post_mod_inc)) {
         require_once $post_mod_inc;
     }
 }
Esempio n. 4
0
 protected function render()
 {
     //===========================================================
     // Skip the Render Process?
     //===========================================================
     if ($this->skip_render || defined('POFW_SKIP_RENDER') && POFW_SKIP_RENDER) {
         return false;
     }
     //===========================================================
     // Set Master XSL Template File
     //===========================================================
     if (!$this->xsl_template) {
         $xslt_stylesheet = "{$this->templates_dir}/{$this->page_type}.xsl";
         $this->set_xsl_template($xslt_stylesheet);
     }
     //===========================================================
     // Start Page
     //===========================================================
     $page = new gen_element('page');
     $page->display_tree();
     //===========================================================
     // Start Page and set basic values
     //===========================================================
     $page->add_child(new gen_element('html_path', $this->html_path));
     $page->add_child(new gen_element('page_type', $this->page_type));
     //===========================================================
     // CSS files
     //===========================================================
     $tmp = new gen_element('css_files');
     $tmp->display_tree();
     foreach ($this->css_files as $file_attrs) {
         $tmp2 = new gen_element('css_file');
         $tmp2->display_tree();
         foreach ($file_attrs as $attr_key => $attr_val) {
             $tmp3 = new gen_element($attr_key, $attr_val);
             $tmp2->add_child($tmp3);
         }
         $tmp->add_child($tmp2);
     }
     $page->add_child($tmp);
     //===========================================================
     // Theme CSS files
     //===========================================================
     if ($this->theme_css_files) {
         $tmp = new gen_element('theme_css_files');
         $tmp->display_tree();
         foreach ($this->theme_css_files as $file_attrs) {
             $tmp2 = new gen_element('theme_css_file');
             $tmp2->display_tree();
             foreach ($file_attrs as $attr_key => $attr_val) {
                 $tmp3 = new gen_element($attr_key, $attr_val);
                 $tmp2->add_child($tmp3);
             }
             $tmp->add_child($tmp2);
         }
         $page->add_child($tmp);
     }
     //===========================================================
     // Javascript files
     //===========================================================
     $tmp = new gen_element('js_files');
     $tmp->display_tree();
     foreach ($this->js_files as $js_file) {
         $tmp->add_child(new gen_element('js_file', $js_file));
     }
     $page->add_child($tmp);
     //===========================================================
     // Theme Javascript files
     //===========================================================
     if ($this->theme_js_files) {
         $tmp = new gen_element('theme_js_files');
         $tmp->display_tree();
         foreach ($this->theme_js_files as $js_file) {
             $tmp->add_child(new gen_element('theme_js_file', $js_file));
         }
         $page->add_child($tmp);
     }
     //===========================================================
     // Copyright
     //===========================================================
     $curr_year = date('Y');
     $page->add_child(new gen_element('copyright', "{$curr_year} {$this->creator}"));
     //===========================================================
     // Account Name
     //===========================================================
     if ($this->account_name) {
         $page->add_child(new gen_element('account_name', $this->account_name));
     }
     //===========================================================
     // Site XML
     //===========================================================
     if ($this->site_xml) {
         if (is_array($this->site_xml)) {
             $tmp_site_xml = array2xml('site_data', $this->site_xml);
             $page->add_child("{$tmp_site_xml}\n");
         } else {
             $page->add_child(new gen_element('site_data', $this->site_xml));
         }
     }
     //===========================================================
     // Application XML
     //===========================================================
     if (count($this->app_xml) > 0) {
         $tmp = new gen_element('application_data');
         $tmp->display_tree();
         foreach ($this->app_xml as $xml_line) {
             if (is_array($xml_line[1])) {
                 $new_xml_line = array2xml($xml_line[0], $xml_line[1]);
                 $tmp->add_child("{$new_xml_line}\n");
             } else {
                 $tmp->add_child(new gen_element($xml_line[0], $xml_line[1]));
             }
         }
         $page->add_child($tmp);
     }
     //===========================================================
     // If Logged in
     //===========================================================
     if (isset($_SESSION['userid'])) {
         // User Info
         $tmp = new gen_element('user');
         $tmp->display_tree();
         $tmp->add_child(new gen_element('userid', $_SESSION['userid']));
         if (!isset($_SESSION['name'])) {
             $_SESSION['name'] = '';
         }
         $tmp->add_child(new gen_element('name', xml_escape($_SESSION['name'])));
         $page->add_child($tmp);
         // Special links (logout)
         $exit_phrase = 'Logout';
         if ($_SESSION['auth_data_type'] == 'none') {
             $exit_phrase = 'Quit';
         }
         $tmp = new gen_element('userlinks');
         $tmp->display_tree();
         $tmp2 = new gen_element('link');
         $tmp2->display_tree();
         $tmp2->add_child(new gen_element('linkdesc', $exit_phrase));
         $tmp2->add_child(new gen_element('linkhref', "{$this->html_path}/?mod=logout"));
         $tmp->add_child($tmp2);
         $page->add_child($tmp);
     }
     //===========================================================
     // Menu
     //===========================================================
     if (isset($this->menu_xml)) {
         $page->add_child($this->menu_xml);
     }
     //===========================================================
     // Content
     //===========================================================
     if (isset($this->content_xml) && is_array($this->content_xml) && $this->content_xml) {
         foreach ($this->content_xml as $node) {
             $page->add_child($node);
         }
     }
     //===========================================================
     // Render Page
     //===========================================================
     $this->page_xml = $page;
     //===========================================================
     // Determine output type
     //===========================================================
     if ($this->output_type == 'xml') {
         $this->xsl_template = '';
     }
     //===========================================================
     // Transform the page content
     //===========================================================
     ob_start();
     $sxoe = isset($_SESSION['show_xml_on_error']) && $_SESSION['show_xml_on_error'] == 1 ? true : false;
     xml_transform($this->page_xml, $this->xsl_template, $sxoe);
     $page_content = ob_get_clean();
     //===========================================================
     // Finally!! Output the results!!
     //===========================================================
     echo $page_content;
     //===========================================================
     // Post-page Include Script (post_page.inc.php)
     //===========================================================
     $post_page_inc = "{$this->file_path}/{$this->mods_dir}/post_page.inc.php";
     if (file_exists($post_page_inc)) {
         require_once $post_page_inc;
     }
 }