<?php if (!defined('BASEPATH')) exit('No direct script access allowed'); class Template extends codexForms { var $CI, $html, $func, $func_params; function Template($name,$params) { codexForms::initiate($name,$params); $this->CI =& get_instance(); $this->html = isset($params['template']) ? $params['template'] : ''; $this->func = (isset($params['func']) && method_exists($this->CI, $params['func'])) ? $params['func'] : ''; $this->func_params = (isset($params['func_params']) && is_array($params['func_params'])) ? $params['func_params'] : array(); } // Plugin doesn't need its own database value function getDbFields() { return NULL; } // Plugin is not to write anything into database function prepForDb($value) { return NULL; } // We search a simple string for values we'll need to change function prepForDisplay() { if ($this->func){ $params = array(); foreach ($this->func_params as $key => $param){ if (isset($this->CI->save_data[$param])) $params[$key] = $this->CI->save_data[$param]; else $params[$key] = $param; } if (empty($params)){ $func = $this->func; $template = $this->CI->$func(); } else $template = call_user_func_array(array($this->CI->controller_name, $this->func), $params); } else $template = FALSE; if ($template===FALSE) $template = $this->html; return preg_replace_callback('|{([^}]*)}|', array('Template', 'getRowData'), $template); } // We don't need it to show up in editing or adding views function getHTML() { return NULL; } function getRowData($key) { $CI =& get_instance(); return $CI->entry[$key[1]]; } } ?>