/** * Returns a a table of contents for your documentation * * @access public * @param string Module folder name (optional) * @param boolean Whether to return an array of values or a view (optional) * @return mixed */ function generate_config_info($module = NULL, $return_array = FALSE) { if (empty($module)) { $module = $this->page_segment(2); } $config_path = MODULES_PATH . $module . '/config/' . $module . EXT; if (file_exists($config_path)) { $file = file_get_contents($config_path); } $config = array(); if (!empty($file)) { //preg_match_all("#^\s*//([^\-]+);#Ums", $file, $matches); //preg_match_all("#^\s*//(.+);#Ums", $file, $matches); preg_match_all("#^\\s*//(?!\\s-+)(.+);#Ums", $file, $matches); if (isset($matches[1])) { foreach ($matches[1] as $match) { // remove any extra comment slashes $match = str_replace('//', '', $match); $match = trim_multiline($match); // FUEL config doesn't use the prefix key $key1 = 3; $key2 = 4; if ($module == FUEL_FOLDER) { preg_match('#^\\$config\\[([\'|"])(.+)\\1\\]\\s*=\\s*([^\\]]+)#ms', $match, $key_arr); $key1 = 2; $key2 = 3; } else { preg_match('#\\$config\\[([\'|"])' . $module . '\\1\\]\\[([\'|"])([^\\]]+)\\2\\]\\s*=\\s*(.+)#ms', $match, $key_arr); } if (isset($key_arr[$key1]) and isset($key_arr[$key2])) { $key = $key_arr[$key1]; if (strpos($key, "']['") !== FALSE) { $key = "[" . str_replace(array("'", '"'), "", $key) . "]"; } $comment = current(explode('$config', $match)); $default = '<pre>' . htmlentities($key_arr[$key2]) . '</pre>'; $c = new stdClass(); $c->param = $key; $c->comment = htmlentities($comment); $c->default_value = $default; $config[$key] = $c; } } } } $vars['config'] = $config; $vars['module'] = $module; return $this->block('config', $vars); }
/** * Creates a text area that will automatically create unordered list items off of each new line * * @access public * @param array Fields parameters * @return string */ public function list_items($params) { $form_builder =& $params['instance']; // ugly... just strips the whitespace on multilines ... http://stackoverflow.com/questions/1655159/php-how-to-trim-each-line-in-a-heredoc-long-string $params['value'] = trim_multiline(strip_tags($params['value'])); $output_class = !empty($params['output_class']) ? 'class="' . $params['output_class'] . '"' : ''; $process_key = isset($params['subkey']) ? $params['subkey'] : $params['key']; $list_type = (!empty($params['list_type']) and $params['list_type'] == 'ol') ? 'ol' : 'ul'; $func_str = ' if (is_array($value)) { foreach($value as $key => $val) { if (isset($val["' . $process_key . '"])) { if (is_string($val["' . $process_key . '"])) { $z = $val["' . $process_key . '"]; } else if (is_array($val["' . $process_key . '"]) AND isset($val["' . $process_key . '"]["' . $params['name'] . '"])) { $z = $val["' . $process_key . '"]["' . $params['name'] . '"]; } $lis = explode("\\n", $z); $lis = array_map("trim", $lis); $newval = ' . $list_type . '($lis, "' . $output_class . '"); if (is_string($val["' . $process_key . '"])) { $value[$key]["' . $process_key . '"] = $newval; } else if (is_array($val["' . $process_key . '"]) AND isset($val["' . $process_key . '"]["' . $params['name'] . '"])) { $value[$key]["' . $process_key . '"]["' . $params['name'] . '"] = $newval; } } } return $value; } else { $lis = explode("\\n", $value); $lis = array_map("trim", $lis); return ' . $list_type . '($lis, "' . $output_class . '"); } '; $func = create_function('$value', $func_str); $form_builder->set_post_process($params['key'], $func); $params['class'] = 'no_editor'; return $form_builder->create_textarea($params); }