public function __construct($tagdata = '') { $tagdata = empty($tagdata) ? ee()->TMPL->tagdata : $tagdata; $smartypants = ee()->TMPL->fetch_param('smartypants', 'yes'); $convert_curly = ee()->TMPL->fetch_param('convert_curly', 'yes'); ee()->load->library('typography'); ee()->typography->convert_curly = get_bool_from_string($convert_curly); $this->return_data = ee()->typography->markdown($tagdata, compact('smartypants')); return $this->return_data; }
/** * Returns the specified config item as a boolean. * * Defaults to FALSE for items that are not set. Intelligently converts 'y/n' * to booleans. * * @access public * @return mixed */ function bool_config_item($item) { if (function_exists('ee') && ee() !== NULL) { $value = ee()->config->item($item); } else { $value = config_item($item); } $setting = get_bool_from_string($value); return is_bool($setting) ? $setting : (bool) $value; }
function grid_save_settings($data) { return array('localize' => get_bool_from_string($data['localize'])); }
/** * Parse content to Markdown * @param string $str String to parse * @param array $options Associative array containing options * - smartypants (TRUE/FALSE) enable or disable * smartypants * - no_markup (TRUE/FALSE) set to TRUE to disable * the parsing of markup in Markdown * @return string Parsed Markdown content */ public function markdown($str, $options = array()) { // Ignore [code] $code_blocks = array(); preg_match_all('/\\<div class="codeblock">(.*?)\\<\\/div>/uis', $str, $matches); foreach ($matches[0] as $match) { $hash = random_string('md5'); $code_blocks[$hash] = $match; $str = str_replace($match, $hash, $str); } $parser = new MarkdownExtra(); // Disable other markup if this is set if (isset($options['no_markup']) && get_bool_from_string($options['no_markup'])) { $parser->no_markup = TRUE; } // Protect any quotes in EE tags from the Markdown and SmartyPants // processors. $str = $this->protect_quotes_in_tags($str); // Parse the Markdown $str = $parser->transform($str); // Run everything through SmartyPants if (!isset($options['smartypants']) or get_bool_from_string($options['smartypants']) == TRUE) { if (!class_exists('SmartyPants_Parser')) { require_once APPPATH . 'libraries/typography/SmartyPants/smartypants.php'; } // 2 -> "---" for em-dashes; "--" for en-dashes $str = SmartyPants($str, 2); } // Restore the quotes we protected earlier. $str = $this->restore_quotes_in_tags($str); // Replace <div class="codeblock"> ([code]) blocks. foreach ($code_blocks as $hash => $code_block) { $str = str_replace($hash, $code_block, $str); } return $str; }
/** * Update Database Config File * * Reads the existing DB config file as a string and swaps out * any values passed to the function. * * @param array $dbconfig Items to add to the database configuration * @return boolean TRUE if successful */ public function _update_dbconfig($dbconfig = array()) { $database_config = ee('Database')->getConfig(); // Prevent access to certain properties $allowed_properties = array('hostname' => 'string', 'username' => 'string', 'password' => 'string', 'database' => 'string', 'pconnect' => 'bool', 'dbprefix' => 'string', 'db_debug' => 'bool'); $dbconfig = array_intersect_key($dbconfig, $allowed_properties); foreach ($dbconfig as $property => $value) { if ($allowed_properties[$property] == 'bool') { $value = get_bool_from_string($value); } $database_config->set($property, $value); } // Update the database config $db_config = ee('Database')->getConfig(); $group_config = $db_config->getGroupConfig(); // Remove default properties $defaults = $db_config->getDefaults(); foreach ($defaults as $property => $value) { if (isset($group_config[$property]) && $group_config[$property] == $value) { unset($group_config[$property]); } } $this->_update_config(array('database' => array('expressionengine' => $group_config))); return TRUE; }
function _get_field_options($data) { $field_options = array(); $pre_populate = isset($this->settings['field_pre_populate']) ? get_bool_from_string($this->settings['field_pre_populate']) : FALSE; if (!$pre_populate) { if (!is_array($this->settings['field_list_items'])) { foreach (explode("\n", trim($this->settings['field_list_items'])) as $v) { $v = trim($v); $field_options[form_prep($v)] = form_prep($v); } } else { $field_options = $this->settings['field_list_items']; } } else { // We need to pre-populate this menu from an another channel custom field ee()->db->select('field_id_' . $this->settings['field_pre_field_id']); ee()->db->where('channel_id', $this->settings['field_pre_channel_id']); $pop_query = ee()->db->get('channel_data'); $field_options[''] = '--'; if ($pop_query->num_rows() > 0) { foreach ($pop_query->result_array() as $prow) { $selected = $prow['field_id_' . $this->settings['field_pre_field_id']] == $data ? 1 : ''; $pretitle = substr($prow['field_id_' . $this->settings['field_pre_field_id']], 0, 110); $pretitle = str_replace(array("\r\n", "\r", "\n", "\t"), " ", $pretitle); $pretitle = form_prep($pretitle); $field_options[form_prep($prow['field_id_' . $this->settings['field_pre_field_id']])] = $pretitle; } } } return $field_options; }