コード例 #1
0
ファイル: blocks.php プロジェクト: randombrad/FUEL-CMS
 function import_view()
 {
     $out = 'error';
     if ($this->input->post('id')) {
         $block_data = $this->model->find_by_key($this->input->post('id'), 'array');
         $this->load->helper('file');
         $view_twin = APPPATH . 'views/_blocks/' . $block_data['name'] . EXT;
         if (file_exists($view_twin)) {
             $view_twin_info = get_file_info($view_twin);
             $tz = date('T');
             if ($view_twin_info['date'] > strtotime($block_data['last_modified'] . ' ' . $tz) or $block_data['last_modified'] == $block_data['date_added']) {
                 // must have content in order to not return error
                 $out = file_get_contents($view_twin);
                 // replace PHP tags with template tags... comments are replaced because of xss_clean()
                 if ($this->sanitize_input) {
                     $out = php_to_template_syntax($out);
                 }
             }
         }
     }
     $this->output->set_output($out);
 }
コード例 #2
0
 /**
  * Imports a block view file into the database
  *
  * @access	public
  * @param	string	The name of the block file to import to the CMS
  * @param	boolean	Determines whether to sanitize the block by applying the php to template syntax function before uploading
  * @return	string
  */
 public function import($block, $sanitize = TRUE)
 {
     $this->CI->load->helper('file');
     $model = $this->model();
     if (!is_numeric($block)) {
         $block_data = $model->find_by_name($block, 'array');
     } else {
         $block_data = $model->find_by_key($block, 'array');
     }
     $view_twin = APPPATH . 'views/_blocks/' . $block_data['name'] . EXT;
     $output = '';
     if (file_exists($view_twin)) {
         $view_twin_info = get_file_info($view_twin);
         $tz = date('T');
         if ($view_twin_info['date'] > strtotime($block_data['last_modified'] . ' ' . $tz) or $block_data['last_modified'] == $block_data['date_added']) {
             // must have content in order to not return error
             $output = file_get_contents($view_twin);
             // replace PHP tags with template tags... comments are replaced because of xss_clean()
             if ($sanitize) {
                 $output = php_to_template_syntax($output);
             }
         }
     }
     return $output;
 }
コード例 #3
0
 /**
  * Helper method used for parsing out fuel_set_var
  *
  * @access	protected
  * @param	string	The regex to use for matches
  * @return	array
  */
 protected function _import_fuel_set_var_callback($regex, $output, $sanitize, $pagevars)
 {
     preg_match_all($regex, $output, $matches, PREG_SET_ORDER);
     foreach ($matches as $match) {
         if (!empty($match[2])) {
             $match[3] = trim($match[3]);
             // fix array issue with regex
             $eval_str = '$_var = ' . $match[3] . ';';
             eval($eval_str);
             $pagevars[$match[2]] = $_var;
             // replace PHP tags with template tags... comments are replaced because of xss_clean()
             if ($sanitize and is_string($pagevars[$match[2]])) {
                 $pagevars[$match[2]] = php_to_template_syntax($pagevars[$match[2]]);
             }
         }
     }
     return $pagevars;
 }