コード例 #1
0
ファイル: _template.php プロジェクト: nailsapp/module-cms
 /**
  * Renders the template with the provided data
  *
  * This method accepts a template data and renders the page appropriately
  *
  * @param stdClass $_tpl_data A normal template_data object, prefixed to avoid naming collisions
  * @return string
  *
  **/
 public function render($_tpl_widgets = array(), $_tpl_additional_fields = array())
 {
     //	If the template wishes to execute any custom pre/post code then this method
     //	should be extended and parent::render( $_data ) called at the appropriate
     //	point. But that's obvious, isn't it...?
     // --------------------------------------------------------------------------
     get_instance()->load->model('cms/cms_page_model');
     // --------------------------------------------------------------------------
     //	Process each widget area and render the HTML
     $_widget_areas = array();
     foreach ($this->_details->widget_areas as $key => $details) {
         $_widget_areas[$key] = '';
         //	Loop through all defined widgets and render each one
         if (!empty($_tpl_widgets[$key])) {
             foreach ($_tpl_widgets[$key] as $widget_data) {
                 try {
                     $_widget = get_instance()->cms_page_model->get_widget($widget_data->widget, 'RENDER');
                     if ($_widget) {
                         parse_str($widget_data->data, $_data);
                         $WIDGET = new $_widget->iam();
                         $_widget_areas[$key] .= $WIDGET->render($_data, $_tpl_additional_fields);
                     }
                 } catch (Exception $e) {
                     log_message('error', 'Failed to render widget');
                 }
             }
         }
     }
     // --------------------------------------------------------------------------
     if (is_file($this->_details->path . 'view.php')) {
         //	If passed, extract any view data
         $_NAILS_CONTROLLER_DATA =& get_controller_data();
         if ($_NAILS_CONTROLLER_DATA) {
             extract($_NAILS_CONTROLLER_DATA);
         }
         //	If passed, extract any additional_fields
         if ($_tpl_additional_fields) {
             extract($_tpl_additional_fields);
         }
         //	Extract the variables, so that the view can use them
         if ($_widget_areas) {
             extract($_widget_areas);
         }
         //	Start the buffer, basically copying how CI does it's view loading
         ob_start();
         include $this->_details->path . 'view.php';
         //	Flush buffer
         $_buffer = ob_get_contents();
         @ob_end_clean();
         //	Return the HTML
         return $_buffer;
     }
     return '';
 }
コード例 #2
0
 /**
  * Build the main framework. All autoloaded items have been loaded and
  * instantiated by this point and are safe to use.
  *
  * @access	public
  * @return	void
  *
  **/
 public function __construct()
 {
     parent::__construct();
     // --------------------------------------------------------------------------
     //	Set the level of error reporting
     $this->_set_error_reporting();
     // --------------------------------------------------------------------------
     //	Set the default content-type
     $this->output->set_content_type('text/html; charset=utf-8');
     // --------------------------------------------------------------------------
     //	Include the composer autoloader
     if (!file_exists(FCPATH . 'vendor/autoload.php')) {
         $_ERROR = 'Composer autoloader not found; run <code>composer install</code> to install dependencies.';
         include NAILS_PATH . 'errors/startup_error.php';
     }
     require_once FCPATH . 'vendor/autoload.php';
     // --------------------------------------------------------------------------
     //	Define data array (used extensively in views)
     $this->data =& get_controller_data();
     // --------------------------------------------------------------------------
     //	Is Nails in maintenance mode?
     $this->_maintenance_mode();
     // --------------------------------------------------------------------------
     //	If we're on a staging environment then prompt for a password;
     //	but only if a password has been defined in app.php
     $this->_staging();
     // --------------------------------------------------------------------------
     //	Load these items, everytime.
     $this->_autoload_items();
     // --------------------------------------------------------------------------
     //	Load, instantiate and apply the fatal error handler
     $this->_fatal_error_handler();
     // --------------------------------------------------------------------------
     //	Test that the cache is writeable
     $this->_test_cache();
     // --------------------------------------------------------------------------
     //	Do we need to instantiate the database?
     $this->_instantiate_db();
     // --------------------------------------------------------------------------
     //	Instanciate the user model
     $this->_instantiate_user();
     // --------------------------------------------------------------------------
     //	Instanciate languages
     $this->_instantiate_languages();
     // --------------------------------------------------------------------------
     //	Is the user suspended?
     //	Executed here so that both the user and language systems are initialised
     //	(so that any errors can be shown in the correct language).
     $this->_is_user_suspended();
     // --------------------------------------------------------------------------
     //	Instanciate DateTime
     $this->_instantiate_datetime();
     // --------------------------------------------------------------------------
     //	Profiling
     $this->_instantiate_profiler();
     // --------------------------------------------------------------------------
     //	Need to generate the routes_app.php file?
     if (defined('NAILS_STARTUP_GENERATE_APP_ROUTES') && NAILS_STARTUP_GENERATE_APP_ROUTES) {
         $this->load->model('system/routes_model');
         if (!$this->routes_model->update()) {
             //	Fall over, routes_app.php *must* be there
             show_fatal_error('Failed To generate routes_app.php', 'routes_app.php was not found and could not be generated. ' . $this->routes_model->last_error());
         } else {
             //	Routes exist now, instruct the browser to try again
             if ($this->input->post()) {
                 redirect($this->input->server('REQUEST_URI'), 'Location', 307);
             } else {
                 redirect($this->input->server('REQUEST_URI'));
             }
         }
     }
     // --------------------------------------------------------------------------
     //	Set alerts
     //	These are hooks for code to add feedback messages to the user.
     $this->data['notice'] = $this->session->flashdata('notice');
     $this->data['message'] = $this->session->flashdata('message');
     $this->data['error'] = $this->session->flashdata('error');
     $this->data['success'] = $this->session->flashdata('success');
     // --------------------------------------------------------------------------
     //	Other defaults
     $this->data['page'] = new stdClass();
     $this->data['page']->title = '';
     $this->data['page']->seo = new stdClass();
     $this->data['page']->seo->title = '';
     $this->data['page']->seo->description = '';
     $this->data['page']->seo->keywords = '';
 }
コード例 #3
0
ファイル: _widget.php プロジェクト: nailsapp/module-cms
 /**
  * Renders the HTML for a widget
  *
  * Called by the template, this method renders the widget's HTML using the
  * passed data.
  *
  * @param stdClass $_wgt_data A normal widget_data object, prefixed to avoid naming collisions
  * @return string
  *
  **/
 public function render($_wgt_data = array(), $_tpl_additional_data = array())
 {
     if (is_file($this->_details->path . 'views/render.php')) {
         //	If passed, extract any controller data
         $_NAILS_CONTROLLER_DATA =& get_controller_data();
         if ($_NAILS_CONTROLLER_DATA) {
             extract($_NAILS_CONTROLLER_DATA);
         }
         //	Extract the variables, so that the view can use them
         if ($_wgt_data) {
             extract($_wgt_data);
         }
         if ($_tpl_additional_data) {
             extract($_tpl_additional_data);
         }
         //	Start the buffer, basically copying how CI does it's view loading
         ob_start();
         include $this->_details->path . 'views/render.php';
         //	Flush buffer
         $_buffer = ob_get_contents();
         @ob_end_clean();
         //	Return the HTML
         return $_buffer;
     }
     return '';
 }
コード例 #4
0
ファイル: view.php プロジェクト: nailsapp/module-cms
<?php

echo $this->load->view('structure/header', get_controller_data());
// --------------------------------------------------------------------------
echo '<h1>Mainbody content</h1>';
echo $mainbody;
echo '<h1>Sidebar content</h1>';
echo $sidebar;
// --------------------------------------------------------------------------
echo $this->load->view('structure/footer', get_controller_data());
コード例 #5
0
ファイル: submit.php プロジェクト: sajedgit/MydataForCrud
function create_controller($arr, $table_name, $table_name_to_class)
{
    if (!file_exists('data/application/controllers')) {
        mkdir('data/application/controllers', 0755, true);
    }
    $file = fopen("data/application/controllers/" . $table_name_to_class . ".php", "w");
    $file_data = get_controller_data($arr, $table_name, $table_name_to_class);
    //	get_controller_data function are in include page
    fwrite($file, $file_data);
    fclose($file);
}