Posted by Philip Sturgeon on Mon 18 Jun 12:17 (modification of post by view diff)
report abuse | download | new post
- /**
- * CodeIgniter
- *
- * An open source application development framework for PHP 4.3.2 or newer
- *
- * @package CodeIgniter
- * @author Rick Ellis
- * @copyright Copyright (c) 2006, EllisLab, Inc.
- * @license http://www.codeignitor.com/user_guide/license.html
- * @link http://www.codeigniter.com
- * @since Version 1.0
- * @filesource
- */
- // ------------------------------------------------------------------------
- /**
- * CodeIgniter Admin Output Class
- *
- * Permits admin pages to be constructed easier.
- *
- * @package CodeIgniter
- * @subpackage Libraries
- * @category Libraries
- * @author Philip Sturgeon
- * @link
- */
- class Admin_output extends CI_Parser {
- var $filename = '';
- var $title = '';
- var $mode = 'html';
- var $header = 'header.html';
- var $footer = 'footer.html';
- var $wrap = true;
- var $pdf_filename = ''; // What will the PDF be stored as?
- /**
- * Constructor - Calls the CI instance and sets a debug message
- *
- * The constructor can be passed an array of config values
- */
- function Admin_output()
- {
- $CI =& get_instance();
- log_message('debug', "Admin Output Class Initialized");
- }
- // --------------------------------------------------------------------
- /**
- * Set the title of the page
- *
- * @access public
- * @param string
- * @return void
- */
- function title($title = '')
- {
- if($title != '') $this->title = $title;
- }
- /**
- * Set the mode of the creation
- *
- * @access public
- * @param string
- * @return void
- */
- {
- $CI =& get_instance();
- if($filename != '') $this->filename = $filename;
- // Work out the basics the template will need
- $this->_set_defaults();
- // Want header and footer file included, or just the main file?
- if($this->wrap === true):
- $output = $this->parse('admincp/'.$this->header, $this->data, true);
- $output .= $this->parse('admincp/'.$this->filename, $this->data, true);
- $output .= $this->parse('admincp/'.$this->footer, $this->data, true);
- else:
- $output = $this->parse('admincp/'.$this->filename, $this->data, true);
- endif;
- // Want it returned or output to browser?
- if($return):
- return $output;
- else:
- if($this->mode == 'pdf'):
- /*
- * Using the code from PDF library for Code Igniter applications
- * Author: Phil Went, May 2007
- * uses HTMLDOC http://www.htmldoc.org/ to create the pdfs
- * modelled on the specialpdf mediawiki plugin by Thomas Hempel
- */
- $page = $this->pdf_filename;
- # Write the content type to the client...
- # if the page is on a HTTPS server and contains images that are on the HTTPS server AND also reachable with HTTP
- # uncomment the next line
- #system("perl -pi -e 's/img src=\"https:\/\//img src=\"http:\/\//g' '$mytemp'");
- # Run HTMLDOC to provide the PDF file to the user...
- else:
- // Send it to output
- $CI->output->set_output($output);
- endif;
- endif;
- }
- /**
- * Should we include headers and footers?
- *
- * @access public
- * @param string
- * @return void
- */
- function wrap($wrap = true)
- {
- $this->wrap = $wrap;
- }
- /**
- * Turn off wrap mode
- *
- * @access public
- * @param string
- * @return void
- */
- function mode($mode = '')
- {
- if($mode != '') $this->mode = $mode;
- }
- function _set_defaults()
- {
- $CI =& get_instance();
- $CI->load->library('session');
- $CI->load->model('employee_model');
- // Get worker ID and worker Name
- if($this->data['workerID'] = $CI->session->userdata('workerID')):
- $employee = $CI->employee_model->get($this->data['workerID']);
- $this->data['workerName'] = $employee['employeeFirstName'].' '.$employee['employeeLastName'];
- endif;
- // Replace all underscores with spaces, then capitalise first letters of words
- $defaultTitle = ucwords(str_replace('_', ' ', $CI->uri->router->class .' > '.$CI->uri->router->method));
- // Set the basic defaults
- $this->data['pageTitle'] = ($this->title != '') ? $this->title : $defaultTitle;
- $this->data['sideBars'] = $this->_build_sidebars();
- if($this->mode == 'print' or $this->mode == 'pdf'):
- $this->header = 'print_header.html';
- $this->footer = 'print_footer.html';
- endif;
- endif;
- endif;
- }
- /**
- * Set the mode of the creation
- *
- * @access public
- * @param array
- * @return array
- */
- function _build_sidebars()
- {
- foreach($this->sidebars as $sidebarName):
- include(APPPATH.'views/admincp/sidebars/'.$sidebarName.'_code.php');
- $sidebarContent = $this->parse('admincp/sidebars/'.$sidebarName.'.html', $this->data, true);
- endforeach;
- return $sidebarArray;
- }
- }
- // END Admin_output class
- ?>
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.