示例#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);
 }
示例#2
0
 public function render()
 {
     //----------------------------------------------------------
     // Pre-message Include Script (pre_message.inc.php)
     //----------------------------------------------------------
     $pre_msg_inc = "{$this->file_path}/{$this->mods_dir}/pre_message.inc.php";
     if (file_exists($pre_msg_inc)) {
         require_once $pre_msg_inc;
     }
     //----------------------------------------------------------
     // Start building message page
     //----------------------------------------------------------
     $tmp = new gen_element('message');
     $tmp->add_child(new gen_element('code', $this->msg_code));
     $tmp->add_child(new gen_element('login_link', $this->html_path . '/'));
     $tmp->add_child(new gen_element('back_link', 'javascript: history.go(-1)'));
     ob_start();
     include "{$this->templates_dir}/messages.xml";
     $tmp->add_child(ob_get_clean());
     $this->content_xml[] = $tmp;
     switch ($this->msg_code) {
         case 1:
         case 3:
         case 4:
         case 5:
         case 7:
         case 8:
         case 'login':
             if (isset($_SESSION['login_url'])) {
                 $tmp_login_url = $_SESSION['login_url'];
             }
             session_unset();
             session_destroy();
             // Login URL
             if (isset($tmp_login_url)) {
                 session_start();
                 $_SESSION['login_url'] = $tmp_login_url;
             }
             break;
     }
     //----------------------------------------------------------
     // Post-message Include Script (post_message.inc.php)
     //----------------------------------------------------------
     $post_msg_inc = $this->file_path . '/' . $this->mods_dir . '/post_message.inc.php';
     if (file_exists($post_msg_inc)) {
         require_once $post_msg_inc;
     }
 }
示例#3
0
 public function render($buffer = false)
 {
     $this->inset_val = '';
     ob_start();
     if (!is_array($this->select_value)) {
         settype($this->select_value, 'string');
     }
     //============================================
     // Added "Blank" Options
     //============================================
     foreach ($this->blank as $bv) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $bv[0]);
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$bv[0]])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($bv[0], 'string');
                 if ($this->select_value === $bv[0]) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $bv[1], $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$bv[0]])) {
             $o->attrs($this->elements_attrs[$bv[0]]);
         }
         $o->render();
     }
     //============================================
     // Options
     //============================================
     $opt_group = null;
     foreach ($this->select_vals as $key => $value) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $key);
         //-----------------------------------------
         // Option Group
         //-----------------------------------------
         if (is_array($value)) {
             $tmp_val_arr = $value;
             $value = isset($tmp_val_arr[0]) ? $tmp_val_arr[0] : '';
             if (isset($tmp_val_arr[1]) && $tmp_val_arr[1] !== $opt_group) {
                 $opt_group = $tmp_val_arr[1];
                 print new gen_element('optgroup', '', array('label' => $tmp_val_arr[1]));
             }
         }
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$key])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($key, 'string');
                 if ($this->select_value === $key) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $value, $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$key])) {
             $o->attrs($this->elements_attrs[$key]);
         }
         //-----------------------------------------
         // Output
         //-----------------------------------------
         $o->render();
     }
     $this->inset_val .= ob_get_clean();
     parent::render($buffer);
 }
示例#4
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);
 }
示例#5
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;
     }
 }
示例#6
0
function xhe($elm = false, $content = '', $attrs = array(), $escape = false)
{
    if ($elm) {
        ob_start();
        $c = new gen_element($elm, $content, $attrs);
        $c->render();
        return $escape ? xml_escape(ob_get_clean()) : ob_get_clean();
    }
    return false;
}
示例#7
0
 public function end_fieldset()
 {
     $fs_attrs = array('marker' => 'end');
     $fieldset = new gen_element('fieldset', '', $fs_attrs);
     array_push($this->form_elements, array($fieldset->render(1), 0, 'fieldset'));
 }
示例#8
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;
     }
 }
示例#9
0
 public function render($buffer = false)
 {
     //============================================
     // Pull items from database
     //============================================
     $data = new data_trans($this->data_src);
     $data->data_query($this->strsql);
     $result = $data->data_assoc_result();
     $this->inset_val = '';
     ob_start();
     if (!is_array($this->select_value)) {
         settype($this->select_value, 'string');
     }
     //============================================
     // Added "Blank" Options
     //============================================
     foreach ($this->blank as $bv) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $bv[0]);
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$bv[0]])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($bv[0], 'string');
                 if ($this->select_value === $bv[0]) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $bv[1], $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$bv[0]])) {
             $o->attrs($this->elements_attrs[$bv[0]]);
         }
         $o->render();
     }
     //============================================
     // Options
     //============================================
     $opt_group = null;
     foreach ($result as $row) {
         //-----------------------------------------
         // Option Attributes: Value
         //-----------------------------------------
         $o_attrs = array('value' => $row[$this->opt_key]);
         //-----------------------------------------
         // Option Group
         //-----------------------------------------
         if ($this->opt_group && isset($row[$this->opt_group]) && $row[$this->opt_group] !== $opt_group) {
             $opt_group = $row[$this->opt_group];
             print new gen_element('optgroup', '', array('label' => $row[$this->opt_group]));
         }
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             settype($row[$this->opt_key], 'string');
             if ($this->select_value === $row[$this->opt_key]) {
                 $o_attrs['selected'] = 'selected';
             }
         }
         //-----------------------------------------
         // Selected Value
         //-----------------------------------------
         if (isset($this->select_value)) {
             if (is_array($this->select_value) && isset($this->select_value[$row[$this->opt_key]])) {
                 $o_attrs['selected'] = 'selected';
             } else {
                 settype($row[$this->opt_key], 'string');
                 if ($this->select_value === $row[$this->opt_key]) {
                     $o_attrs['selected'] = 'selected';
                 }
             }
         }
         //-----------------------------------------
         // Create Option Element
         //-----------------------------------------
         $o = new gen_element('option', $row[$this->opt_val], $o_attrs);
         $o->force_endtag(1);
         //-----------------------------------------
         // Element Attributes
         //-----------------------------------------
         if (isset($this->elements_attrs[$row[$this->opt_key]])) {
             $o->attrs($this->elements_attrs[$row[$this->opt_key]]);
         }
         //-----------------------------------------
         // Output
         //-----------------------------------------
         $o->render();
     }
     $this->inset_val .= ob_get_clean();
     parent::render($buffer);
 }
示例#10
0
function gen_links($links, $extra_class = '')
{
    trigger_error('This function has been deprecated and will be removed in a future release.', E_USER_DEPRECATED);
    if (is_array($links)) {
        $ul_content = '';
        foreach ($links as $link) {
            $link_attrs = array();
            if (isset($link[2])) {
                $link_attrs['class'] = $link[2];
            } else {
                $link_attrs['class'] = 'gen_link';
            }
            $ul_content .= '<li>' . anchor($link[0], $link[1], $link_attrs) . '</li>';
        }
        $ul = new gen_element('ul', $ul_content);
        ob_start();
        $ul->render();
        $ul_str = ob_get_clean();
        $ob_class = $extra_class != '' ? 'outer_box $extra_class' : 'outer_box';
        print div($ul_str, array('class' => $ob_class));
    } else {
        trigger_error('[!] Error: Expecting array input for function: [gen_links]!');
    }
}