本文整理汇总了PHP中Channel::fetch_categories方法的典型用法代码示例。如果您正苦于以下问题:PHP Channel::fetch_categories方法的具体用法?PHP Channel::fetch_categories怎么用?PHP Channel::fetch_categories使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Channel
的用法示例。
在下文中一共展示了Channel::fetch_categories方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rank
//.........这里部分代码省略.........
}
// ----------------------------------------
// Favorites date
// ----------------------------------------
if (stristr(ee()->TMPL->tagdata, LD . 'favorites_date ') or ee()->TMPL->fetch_param('orderby') == 'favorites_date') {
$channel->favorites_date = TRUE;
$channel->sql = preg_replace("/\\s+FROM\\s+/s", ", f.entry_date AS favorites_date FROM ", ltrim($channel->sql));
$channel->sql = preg_replace("/LEFT JOIN\\s+{$this->sc->db->channels}/is", "LEFT JOIN \texp_favorites AS f \r\n\t\t\t\t ON \t\t(t.entry_id = f.entry_id\r\n\t\t\t\t AND \t\tf.favorites_id \r\n\t\t\t\t IN \t\t(SELECT MAX(favorites_id) FROM exp_favorites GROUP BY entry_id))\r\n \t\t LEFT JOIN \t{$this->sc->db->channels}", $channel->sql);
}
$channel->query = ee()->db->query($channel->sql);
if (APP_VER < 2.0) {
$channel->query->result = $channel->query->result_array();
}
// ----------------------------------------
// Empty?
// ----------------------------------------
if (!isset($channel->query) or $channel->query->num_rows() == 0) {
return $this->no_results();
}
// ----------------------------------------
// typography
// ----------------------------------------
if (APP_VER < 2.0) {
if (!class_exists('Typography')) {
require PATH_CORE . 'core.typography' . EXT;
}
$channel->TYPE = new Typography();
$channel->TYPE->convert_curly = FALSE;
} else {
ee()->load->library('typography');
ee()->typography->initialize();
ee()->typography->convert_curly = FALSE;
}
$channel->fetch_categories();
// ----------------------------------------
// Parse and return entry data
// ----------------------------------------
if (APP_VER < 2.0) {
$channel->parse_weblog_entries();
} else {
$channel->parse_channel_entries();
}
// --------------------------------------------
// Render the Pagination Data
// --------------------------------------------
if (APP_VER >= '2.4.0') {
$channel->return_data = $channel->pagination->render($channel->return_data);
} else {
$channel->add_pagination_data();
}
// --------------------------------------------
// Reverse and Related Entries
// --------------------------------------------
if (count(ee()->TMPL->related_data) > 0 and count($channel->related_entries) > 0) {
$channel->parse_related_entries();
}
if (count(ee()->TMPL->reverse_related_data) > 0 and count($channel->reverse_related_entries) > 0) {
$channel->parse_reverse_related_entries();
}
// ----------------------------------------
// Handle problem with pagination segments
// in the url
// ----------------------------------------
if (preg_match("#(/P\\d+)#", ee()->uri->uri_string, $match)) {
$channel->return_data = str_replace($match['1'], "", $channel->return_data);
} elseif (preg_match("#(P\\d+)#", ee()->uri->uri_string, $match)) {
示例2: ee
/** ----------------------------------------
/** Show search results
/** ----------------------------------------*/
function search_results()
{
// Fetch the search language file
ee()->lang->loadfile('search');
// Load Pagination Object
ee()->load->library('pagination');
$pagination = ee()->pagination->create();
ee()->TMPL->tagdata = $pagination->prepare(ee()->TMPL->tagdata);
// Check search ID number
// If the QSTR variable is less than 32 characters long we
// don't have a valid search ID number
if (strlen(ee()->uri->query_string) < 32) {
return ee()->output->show_user_error('off', array(lang('search_no_result')));
}
// Clear old search results
ee()->db->delete('search', array('site_id' => ee()->config->item('site_id'), 'search_date <' => ee()->localize->now - $this->cache_expire * 3600));
// Retrieve the search_id
$qstring = explode('/', ee()->uri->query_string);
$search_id = trim($qstring[0]);
// Fetch the cached search query
$query = ee()->db->get_where('search', array('search_id' => $search_id));
if ($query->num_rows() == 0 or $query->row('total_results') == 0) {
// This should be impossible as we already know there are results
return ee()->output->show_user_error('general', array(lang('invalid_action')));
}
$fields = $query->row('custom_fields') == '' ? array() : unserialize(stripslashes($query->row('custom_fields')));
$sql = unserialize(stripslashes($query->row('query')));
$sql = str_replace('MDBMPREFIX', 'exp_', $sql);
$pagination->per_page = (int) $query->row('per_page');
$res_page = $query->row('result_page');
// -------------------------------------------
// 'channel_search_modify_result_query' hook.
// - Take the whole query string, do what you wish
// - added 2.8
//
if (ee()->extensions->active_hook('channel_search_modify_result_query') === TRUE) {
$modified_sql = ee()->extensions->call('channel_search_modify_result_query', $sql, $search_id);
// Make sure its valid
if (is_string($modified_sql) && $modified_sql != '') {
$sql = $modified_sql;
}
}
//
// -------------------------------------------
// Run the search query
$query = ee()->db->query(preg_replace("/SELECT(.*?)\\s+FROM\\s+/is", 'SELECT COUNT(*) AS count FROM ', $sql));
if ($query->row('count') == 0) {
// This should also be impossible
return ee()->output->show_user_error('general', array(lang('invalid_action')));
}
// Calculate total number of pages and add total rows
$pagination->total_items = $query->row('count');
// Build pagination if enabled
// If we're paginating limit the query and do it again
if ($pagination->paginate === TRUE) {
$pagination->build($pagination->total_items, $pagination->per_page);
$sql .= " LIMIT " . $pagination->offset . ", " . $pagination->per_page;
} else {
$sql .= " LIMIT 0, 100";
}
$query = ee()->db->query($sql);
$output = '';
if (!class_exists('Channel')) {
require PATH_ADDONS . 'channel/mod.channel.php';
}
unset(ee()->TMPL->var_single['auto_path']);
unset(ee()->TMPL->var_single['excerpt']);
unset(ee()->TMPL->var_single['id_auto_path']);
unset(ee()->TMPL->var_single['full_text']);
unset(ee()->TMPL->var_single['switch']);
foreach (ee()->TMPL->var_single as $key => $value) {
if (substr($key, 0, strlen('member_path')) == 'member_path') {
unset(ee()->TMPL->var_single[$key]);
}
}
$switch = ee()->TMPL->fetch_param('switch');
if (!empty($switch) && strpos(ee()->TMPL->tagdata, '{switch}') !== FALSE) {
ee()->TMPL->tagdata = str_replace("{switch}", "{switch='{$switch}'}", ee()->TMPL->tagdata);
ee()->load->library('logger');
ee()->logger->developer('The search module\'s {switch} variable has been deprecated, use standard {switch=} tags in your search results template.', TRUE, 604800);
}
$channel = new Channel();
// This allows the channel {absolute_count} variable to work
$channel->pagination->offset = $pagination->per_page * $pagination->current_page - $pagination->per_page;
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->query = $query;
if ($channel->query->num_rows() == 0) {
return ee()->TMPL->no_results();
}
ee()->load->library('typography');
ee()->typography->initialize(array('convert_curly' => FALSE, 'encode_email' => FALSE));
$channel->fetch_categories();
$channel->parse_channel_entries(array($this, 'callback_search_result_row'));
// Add new pagination
ee()->TMPL->tagdata = $pagination->render($channel->return_data);
// Parse lang variables
//.........这里部分代码省略.........
示例3: strpos
//.........这里部分代码省略.........
} else {
if ($pagination->per_page > 0) {
$sql .= " LIMIT 0, " . $pagination->per_page;
} else {
$sql .= " LIMIT 0, 100";
}
}
$query = $this->EE->db->query($sql);
$output = '';
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
unset($this->EE->TMPL->var_single['auto_path']);
unset($this->EE->TMPL->var_single['excerpt']);
unset($this->EE->TMPL->var_single['id_auto_path']);
unset($this->EE->TMPL->var_single['full_text']);
unset($this->EE->TMPL->var_single['switch']);
foreach ($this->EE->TMPL->var_single as $key => $value) {
if (substr($key, 0, strlen('member_path')) == 'member_path') {
unset($this->EE->TMPL->var_single[$key]);
}
}
$channel = new Channel();
// This allows the channel {absolute_count} variable to work
$channel->pagination->offset = $pagination->per_page * $pagination->current_page - $pagination->per_page;
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->query = $this->EE->db->query($sql);
if ($channel->query->num_rows() == 0) {
return $this->EE->TMPL->no_results();
}
$this->EE->load->library('typography');
$this->EE->typography->initialize(array('convert_curly' => FALSE, 'encode_email' => FALSE));
$channel->fetch_categories();
$channel->parse_channel_entries();
$tagdata = $this->EE->TMPL->tagdata;
// Does the tag contain "related entries" that we need to parse out?
if (count($this->EE->TMPL->related_data) > 0 and count($channel->related_entries) > 0) {
$channel->parse_related_entries();
}
if (count($this->EE->TMPL->reverse_related_data) > 0 and count($channel->reverse_related_entries) > 0) {
$channel->parse_reverse_related_entries();
}
$output = $channel->return_data;
$this->EE->TMPL->tagdata = $tagdata;
// Fetch member path variable
// We do it here in case it's used in multiple places.
$m_paths = array();
if (preg_match_all("/" . LD . "member_path(\\s*=.*?)" . RD . "/s", $this->EE->TMPL->tagdata, $matches)) {
for ($j = 0; $j < count($matches['0']); $j++) {
$m_paths[] = array($matches['0'][$j], $this->EE->functions->extract_path($matches['1'][$j]));
}
}
// Fetch switch param
$switch1 = '';
$switch2 = '';
if ($switch = $this->EE->TMPL->fetch_param('switch')) {
if (strpos($switch, '|') !== FALSE) {
$x = explode("|", $switch);
$switch1 = $x['0'];
$switch2 = $x['1'];
} else {
$switch1 = $switch;
}
}
/** -----------------------------
示例4: search
//.........这里部分代码省略.........
if (preg_match("#(^|\\/)C(\\d+)#", $channel->query_string, $match) or in_array($channel->reserved_cat_segment, explode("/", $channel->query_string))) {
$channel->cat_request = TRUE;
}
}
}
if (FALSE !== ($cache = $channel->fetch_cache('pagination_count'))) {
if (FALSE !== $channel->fetch_cache('field_pagination')) {
if (FALSE !== ($pg_query = $channel->fetch_cache('pagination_query'))) {
$channel->paginate = TRUE;
$channel->field_pagination = TRUE;
$channel->create_pagination(trim($cache), $channel->EE->db->query(trim($pg_query)));
}
} else {
$channel->create_pagination(trim($cache));
}
}
}
if ($channel->sql == '') {
$channel->build_sql_query();
}
if ($channel->sql == '') {
return $channel->EE->TMPL->no_results();
}
$sql = "";
//@start geocoding
//if don't have the Latitude and Longitude, do query to google.map; ($zipLongitude == "" OR $zipLatitude == "") AND
if ($address != "" and ($zipLongitude == "" or $zipLatitude == "")) {
$GetLatLong_result = $this->GetLatLong($address, 2);
if ($GetLatLong_result != false) {
list($zipLongitude, $zipLatitude) = $GetLatLong_result;
} else {
return $this->EE->TMPL->no_results();
}
}
if ($reverse_geocoding and $address == "") {
$GetLatLong_result = $this->GetLatLong($zipLatitude . ',' . $zipLongitude, $api_key, 1);
if ($GetLatLong_result != false) {
$address = $GetLatLong_result;
} else {
return $this->EE->TMPL->no_results();
}
}
//@END geocoding
$conds['radius'] = $radius;
$tagdata = $this->EE->functions->prep_conditionals($tagdata, $conds);
$tagdata = str_replace(array('{center:long}', '{center:lat}', '{radius}'), array($zipLongitude, $zipLatitude, $radius), $tagdata);
$where_strpos = strpos($channel->sql, "WHERE");
if ($where_strpos > 0) {
$sql_entry_id = substr($channel->sql, $where_strpos + 5, strpos($channel->sql, "ORDER BY") - $where_strpos - 5);
$limit_strpos = strpos($channel->sql, "LIMIT");
$order_by = substr($channel->sql, strpos($channel->sql, "ORDER BY"), $limit_strpos);
$limit = substr($channel->sql, strpos($channel->sql, "LIMIT"));
$sql = str_replace('FROM', ", gm.*, ROUND( {$earth_radius} * acos( cos( radians({$zipLatitude}) ) * cos( radians( gm.latitude ) ) * cos( radians( gm.longitude ) - radians({$zipLongitude}) ) + sin( radians({$zipLatitude}) ) * sin( radians( gm.latitude ) ) ) {$prec} ) AS distance FROM ", $channel->sql);
$sql = substr($sql, 0, strpos($sql, "WHERE")) . "RIGHT JOIN exp_mx_google_map AS gm ON t.entry_id = gm.entry_id HAVING distance < {$radius} AND " . $sql_entry_id;
if ($orderby) {
$sql = $sql . $order_by;
} else {
$sql = $sql . " ORDER BY distance " . $sort;
}
$channel->sql = $sql;
}
if ($save_cache == TRUE) {
$channel->save_cache($channel->sql);
}
$channel->query = $channel->EE->db->query($channel->sql);
if ($channel->query->num_rows() == 0) {
return $channel->EE->TMPL->no_results();
}
foreach ($channel->query->result_array() as $row) {
$points[$row['point_id']] = $row['distance'];
}
$channel->EE->TMPL->tagparams['points'] = $points;
if ($channel->EE->config->item('relaxed_track_views') === 'y' && $channel->query->num_rows() == 1) {
$channel->hit_tracking_id = $channel->query->row('entry_id');
}
$channel->track_views();
$channel->EE->load->library('typography');
$channel->EE->typography->initialize();
$channel->EE->typography->convert_curly = FALSE;
if ($channel->enable['categories'] == TRUE) {
$channel->fetch_categories();
}
$channel->parse_channel_entries();
if ($channel->enable['pagination'] == TRUE) {
if (version_compare(APP_VER, '2.4', '>=')) {
$channel->add_pagination_data();
} else {
$channel->fetch_pagination_data();
}
}
if (count($channel->EE->TMPL->related_data) > 0 && count($channel->related_entries) > 0) {
$channel->parse_related_entries();
}
if (count($channel->EE->TMPL->reverse_related_data) > 0 && count($channel->reverse_related_entries) > 0) {
$channel->parse_reverse_related_entries();
}
$return_data = str_replace($entries[0], $channel->return_data, $tagdata);
}
return $return_data;
}
示例5: implode
function tell_a_friend()
{
if ($this->EE->uri->query_string == '') {
return FALSE;
}
/** ----------------------------------------
/** Recipient Email Checking
/** ----------------------------------------*/
$user_recipients = true;
// By default
$recipients = !$this->EE->TMPL->fetch_param('recipients') ? '' : $this->EE->TMPL->fetch_param('recipients');
$charset = !$this->EE->TMPL->fetch_param('charset') ? '' : $this->EE->TMPL->fetch_param('charset');
$allow_html = !$this->EE->TMPL->fetch_param('allow_html') ? 'n' : $this->EE->TMPL->fetch_param('allow_html');
if (!$this->EE->TMPL->fetch_param('status')) {
$this->EE->TMPL->tagparams['status'] = 'open';
}
// Clean and check recipient emails, if any
if ($recipients != '') {
$array = $this->validate_recipients($recipients);
// Put together into string again
$recipients = implode(',', $array['approved']);
}
/** --------------------------------------
/** Parse page number
/** --------------------------------------*/
// We need to strip the page number from the URL for two reasons:
// 1. So we can create pagination links
// 2. So it won't confuse the query with an improper proper ID
$qstring = $this->EE->uri->query_string;
if (preg_match("#/P(\\d+)#", $qstring, $match)) {
$current_page = $match['1'];
$qstring = $this->EE->functions->remove_double_slashes(str_replace($match['0'], '', $qstring));
}
/** --------------------------------------
/** Remove "N"
/** --------------------------------------*/
// The recent comments feature uses "N" as the URL indicator
// It needs to be removed if presenst
if (preg_match("#/N(\\d+)#", $qstring, $match)) {
$qstring = $this->EE->functions->remove_double_slashes(str_replace($match['0'], '', $qstring));
}
/* -------------------------------------
/* 'email_module_tellafriend_override' hook.
/* - Allow use of Tell-A-Friend for things besides channel entries
/* - Added EE 1.5.1
*/
if ($this->EE->extensions->active_hook('email_module_tellafriend_override') === TRUE) {
$tagdata = $this->EE->extensions->call('email_module_tellafriend_override', $qstring, $this);
if ($this->EE->extensions->end_script === TRUE) {
return $tagdata;
}
} else {
$entry_id = trim($qstring);
// If there is a slash in the entry ID we'll kill everything after it.
$entry_id = preg_replace("#/.+#", "", $entry_id);
/** ----------------------------------------
/** Do we have a vaild channel and ID number?
/** ----------------------------------------*/
$timestamp = $this->EE->TMPL->cache_timestamp != '' ? $this->EE->localize->set_gmt($this->EE->TMPL->cache_timestamp) : $this->EE->localize->now;
$channel = !$this->EE->TMPL->fetch_param('channel') ? '' : $this->EE->TMPL->fetch_param('channel');
$sql = "SELECT entry_id FROM exp_channel_titles, exp_channels\n\t\t\t\t\t\tWHERE exp_channel_titles.channel_id = exp_channels.channel_id\n\t\t\t\t\t\tAND (expiration_date = 0 OR expiration_date > " . $timestamp . ")\n\t\t\t\t\t\tAND status != 'closed' AND ";
$sql .= !is_numeric($entry_id) ? " url_title = '" . $entry_id . "' " : " entry_id = '{$entry_id}' ";
if ($channel != '') {
$sql .= $this->EE->functions->sql_andor_string($channel, 'exp_channels.channel_name') . " ";
}
$query = $this->EE->db->query($sql);
// Bad ID? See ya!
if ($query->num_rows() == 0) {
return FALSE;
}
/** ----------------------------------------
/** Fetch the channel entry
/** ----------------------------------------*/
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel' . EXT;
}
$channel = new Channel();
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->build_sql_query();
if ($channel->sql == '') {
return FALSE;
}
$channel->query = $this->EE->db->query($channel->sql);
if ($channel->query->num_rows() == 0) {
return FALSE;
}
$this->EE->load->library('typography');
$this->EE->typography->initialize();
$this->EE->typography->encode_email = FALSE;
$this->EE->typography->convert_curly = FALSE;
$channel->fetch_categories();
$channel->parse_channel_entries();
$tagdata = $channel->return_data;
}
/*
/* -------------------------------------*/
/** ----------------------------------------
/** Parse conditionals
/** ----------------------------------------*/
//.........这里部分代码省略.........
示例6: prep_occurrences_output
//.........这里部分代码省略.........
} else {
$channel->query->result[$k]['occurrence_' . $key . '_' . $vkey] = $vval;
}
}
}
}
}
unset($CDT);
// ----------------------------------------
// Redeclare
// ----------------------------------------
// We will reassign the $channel->query->result with our
// reordered array of values. Thank you PHP for being so fast with array loops.
// ----------------------------------------
if (APP_VER < 2.0) {
$channel->query->result = $channel->query->result;
} else {
$channel->query->result_array = $channel->query->result;
}
// --------------------------------------------
// Typography
// --------------------------------------------
if (APP_VER < 2.0) {
if (!class_exists('Typography')) {
require PATH_CORE . 'core.typography' . EXT;
}
$channel->TYPE = new Typography();
$channel->TYPE->convert_curly = FALSE;
} else {
ee()->load->library('typography');
ee()->typography->initialize();
ee()->typography->convert_curly = FALSE;
}
$channel->fetch_categories();
// -------------------------------------
// Parse
// -------------------------------------
//ee()->TMPL->log_item('Calendar: Parsing, via channel module');
if (APP_VER < 2.0) {
$channel->parse_weblog_entries();
} else {
$channel->parse_channel_entries();
}
// -------------------------------------
// Paginate
// -------------------------------------
//$channel->add_pagination_data();
// -------------------------------------
// Related entries
// -------------------------------------
if (count(ee()->TMPL->related_data) > 0 and count($channel->related_entries) > 0) {
$channel->parse_related_entries();
}
if (count(ee()->TMPL->reverse_related_data) > 0 and count($channel->reverse_related_entries) > 0) {
$channel->parse_reverse_related_entries();
}
// -------------------------------------
// Send 'em home
// -------------------------------------
$tagdata = $channel->return_data;
// -------------------------------------
// Collect the tagdata
// -------------------------------------
preg_match_all("/" . LD . 'occurrences id="(\\d+)"' . RD . '(.*?)' . LD . preg_quote(T_SLASH, '/') . 'occurrences' . RD . '/s', $tagdata, $matches);
foreach ($matches[1] as $k => $id) {
$tagdatas[$id] = $matches[2][$k];
示例7: _entries
//.........这里部分代码省略.........
/** ----------------------------------------
/** Pass params
/** ----------------------------------------*/
ee()->TMPL->tagparams['entry_id'] = $this->entry_id;
ee()->TMPL->tagparams['inclusive'] = '';
if (isset($params['dynamic']) and $params['dynamic'] == "off") {
if (APP_VER < 2.0) {
ee()->TMPL->tagparams['dynamic'] = 'off';
} else {
ee()->TMPL->tagparams['dynamic'] = 'no';
}
}
/** ----------------------------------------
/** Pre-process related data
/** ----------------------------------------*/
ee()->TMPL->tagdata = ee()->TMPL->assign_relationship_data(ee()->TMPL->tagdata);
ee()->TMPL->var_single = array_merge(ee()->TMPL->var_single, ee()->TMPL->related_markers);
/** ----------------------------------------
/** Execute needed methods
/** ----------------------------------------*/
if (APP_VER < 2.0) {
$channel->fetch_custom_weblog_fields();
} else {
$channel->fetch_custom_channel_fields();
}
$channel->fetch_custom_member_fields();
// --------------------------------------------
// Pagination Tags Parsed Out
// --------------------------------------------
if (APP_VER >= '2.4.0') {
$channel->pagination->get_template();
} else {
$channel->fetch_pagination_data();
}
if (APP_VER >= '2.4.0') {
$channel->pagination->cfields = $channel->cfields;
$channel->pagination->build();
} else {
$channel->create_pagination();
}
/** ----------------------------------------
/** Grab entry data
/** ----------------------------------------*/
//$channel->create_pagination();
$channel->build_sql_query();
if ($channel->sql == '') {
return $this->no_results();
}
$channel->query = ee()->db->query($channel->sql);
if (APP_VER < 2.0) {
$channel->query->result = $channel->query->result_array();
}
if (!isset($channel->query) or $channel->query->num_rows() == 0) {
return $this->no_results();
}
if (APP_VER < 2.0) {
if (!class_exists('Typography')) {
require PATH_CORE . 'core.typography' . EXT;
}
$channel->TYPE = new Typography();
$channel->TYPE->convert_curly = FALSE;
} else {
ee()->load->library('typography');
ee()->typography->initialize();
ee()->typography->convert_curly = FALSE;
}
$channel->fetch_categories();
/** ----------------------------------------
/** Parse and return entry data
/** ----------------------------------------*/
if (APP_VER < 2.0) {
$channel->parse_weblog_entries();
} else {
$channel->parse_channel_entries();
}
if (APP_VER >= '2.4.0') {
$channel->return_data = $channel->pagination->render($channel->return_data);
} else {
$channel->add_pagination_data();
}
/** ----------------------------------------
/** Count tag
/** ----------------------------------------*/
if (count(ee()->TMPL->related_data) > 0 and count($channel->related_entries) > 0) {
$channel->parse_related_entries();
}
if (count(ee()->TMPL->reverse_related_data) > 0 and count($channel->reverse_related_entries) > 0) {
$channel->parse_reverse_related_entries();
}
// ----------------------------------------
// Handle problem with pagination segments in the url
// ----------------------------------------
if (preg_match("#(/P\\d+)#", ee()->uri->uri_string, $match)) {
$channel->return_data = str_replace($match['1'], "", $channel->return_data);
} elseif (preg_match("#(P\\d+)#", ee()->uri->uri_string, $match)) {
$channel->return_data = str_replace($match['1'], "", $channel->return_data);
}
$tagdata = $channel->return_data;
return $tagdata;
}
示例8: tell_a_friend
/**
* Tell a friend form
*
* {exp:email:tell_a_friend charset="utf-8" allow_html='n'}
* {exp:email:tell_a_friend charset="utf-8" allow_html='<p>,<a>' recipients='sales@ellislab.com'}
* {member_email}, {member_name}, {current_time format="%Y %d %m"}
*/
public function tell_a_friend()
{
if (ee()->uri->query_string == '') {
return FALSE;
}
// Recipient Email Checking
$this->_user_recipients = 'yes';
// By default
$recipients = ee()->TMPL->fetch_param('recipients', '');
$charset = ee()->TMPL->fetch_param('charset', '');
$allow_html = ee()->TMPL->fetch_param('allow_html');
// Equalize $allow_html value
$allow_html = (is_string($allow_html) and in_array($allow_html, array('yes', 'y', 'true'))) ? TRUE : $allow_html;
$allow_html = (is_string($allow_html) and in_array($allow_html, array('no', 'n', 'false'))) ? FALSE : $allow_html;
if (!ee()->TMPL->fetch_param('status')) {
ee()->TMPL->tagparams['status'] = 'open';
}
// Clean and check recipient emails, if any
if ($recipients != '') {
$array = $this->validate_recipients($recipients);
// Put together into string again
$recipients = implode(',', $array['approved']);
}
// Parse page number
// We need to strip the page number from the URL for two reasons:
// 1. So we can create pagination links
// 2. So it won't confuse the query with an improper proper ID
// Conditionally get query string based on whether or not the page
// was accessed through the Pages module
$qstring = empty(ee()->uri->page_query_string) ? ee()->uri->query_string : ee()->uri->page_query_string;
if (preg_match("#/P(\\d+)#", $qstring, $match)) {
$current_page = $match['1'];
$qstring = reduce_double_slashes(str_replace($match[0], '', $qstring));
}
// Remove "N"
// The recent comments feature uses "N" as the URL indicator
// It needs to be removed if presenst
if (preg_match("#/N(\\d+)#", $qstring, $match)) {
$qstring = reduce_double_slashes(str_replace($match[0], '', $qstring));
}
/* -------------------------------------
/* 'email_module_tellafriend_override' hook.
/* - Allow use of Tell-A-Friend for things besides channel entries
/* - Added EE 1.5.1
*/
if (ee()->extensions->active_hook('email_module_tellafriend_override') === TRUE) {
$tagdata = ee()->extensions->call('email_module_tellafriend_override', $qstring, $this);
if (ee()->extensions->end_script === TRUE) {
return $tagdata;
}
} else {
$entry_id = trim($qstring);
// If there is a slash in the entry ID we'll kill everything after it.
$entry_id = preg_replace("#/.+#", "", $entry_id);
// Do we have a vaild channel and ID number?
$timestamp = ee()->TMPL->cache_timestamp != '' ? ee()->TMPL->cache_timestamp : ee()->localize->now;
$channel = ee()->TMPL->fetch_param('channel', '');
ee()->db->select('entry_id')->from(array('channel_titles ct', 'channels c'))->where('ct.channel_id = c.channel_id', '', FALSE)->where('(ct.expiration_date = 0 OR expiration_date > ' . $timestamp . ')', '', FALSE)->where('ct.status !=', 'closed');
$table = !is_numeric($entry_id) ? 'ct.url_title' : 'ct.entry_id';
ee()->db->where($table, $entry_id);
if ($channel != '') {
ee()->functions->ar_andor_string($channel, 'c.channel_name');
}
$query = ee()->db->get();
// Bad ID? See ya!
if ($query->num_rows() === 0) {
return FALSE;
}
// Fetch the channel entry
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
$channel = new Channel();
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->build_sql_query();
if ($channel->sql == '') {
return FALSE;
}
$channel->query = ee()->db->query($channel->sql);
if ($channel->query->num_rows() === 0) {
return FALSE;
}
ee()->load->library('typography');
ee()->typography->initialize(array('encode_email' => FALSE, 'convert_curly' => FALSE));
$channel->fetch_categories();
$channel->parse_channel_entries();
$tagdata = $channel->return_data;
}
/*
/* -------------------------------------*/
// Parse conditionals
$cond = array();
//.........这里部分代码省略.........
示例9: ee
/** ----------------------------------------
/** Show search results
/** ----------------------------------------*/
function search_results()
{
// Fetch the search language file
ee()->lang->loadfile('search');
// Load Pagination Object
ee()->load->library('pagination');
$pagination = ee()->pagination->create();
ee()->TMPL->tagdata = $pagination->prepare(ee()->TMPL->tagdata);
// Check search ID number
// If the QSTR variable is less than 32 characters long we
// don't have a valid search ID number
if (strlen(ee()->uri->query_string) < 32) {
return ee()->output->show_user_error('off', array(lang('search_no_result')));
}
// Clear old search results
ee()->db->delete('search', array('site_id' => ee()->config->item('site_id'), 'search_date <' => ee()->localize->now - $this->cache_expire * 3600));
// Retrieve the search_id
$qstring = explode('/', ee()->uri->query_string);
$search_id = trim($qstring[0]);
// Fetch the cached search query
$query = ee()->db->get_where('search', array('search_id' => $search_id));
if ($query->num_rows() == 0 or $query->row('total_results') == 0) {
// This should be impossible as we already know there are results
return ee()->output->show_user_error('general', array(lang('invalid_action')));
}
$fields = $query->row('custom_fields') == '' ? array() : unserialize(stripslashes($query->row('custom_fields')));
$sql = unserialize(stripslashes($query->row('query')));
$sql = str_replace('MDBMPREFIX', 'exp_', $sql);
$pagination->per_page = (int) $query->row('per_page');
$res_page = $query->row('result_page');
// -------------------------------------------
// 'channel_search_modify_result_query' hook.
// - Take the whole query string, do what you wish
// - added 2.8
//
if (ee()->extensions->active_hook('channel_search_modify_result_query') === TRUE) {
$modified_sql = ee()->extensions->call('channel_search_modify_result_query', $sql, $search_id);
// Make sure its valid
if (is_string($modified_sql) && $modified_sql != '') {
$sql = $modified_sql;
}
}
//
// -------------------------------------------
// Run the search query
$query = ee()->db->query(preg_replace("/SELECT(.*?)\\s+FROM\\s+/is", 'SELECT COUNT(*) AS count FROM ', $sql));
if ($query->row('count') == 0) {
// This should also be impossible
return ee()->output->show_user_error('general', array(lang('invalid_action')));
}
// Calculate total number of pages and add total rows
$pagination->total_items = $query->row('count');
// Build pagination if enabled
// If we're paginating limit the query and do it again
if ($pagination->paginate === TRUE) {
$pagination->build($pagination->total_items, $pagination->per_page);
$sql .= " LIMIT " . $pagination->offset . ", " . $pagination->per_page;
} else {
$sql .= " LIMIT 0, 100";
}
$query = ee()->db->query($sql);
$output = '';
if (!class_exists('Channel')) {
require PATH_MOD . 'channel/mod.channel.php';
}
unset(ee()->TMPL->var_single['auto_path']);
unset(ee()->TMPL->var_single['excerpt']);
unset(ee()->TMPL->var_single['id_auto_path']);
unset(ee()->TMPL->var_single['full_text']);
unset(ee()->TMPL->var_single['switch']);
foreach (ee()->TMPL->var_single as $key => $value) {
if (substr($key, 0, strlen('member_path')) == 'member_path') {
unset(ee()->TMPL->var_single[$key]);
}
}
$channel = new Channel();
// This allows the channel {absolute_count} variable to work
$channel->pagination->offset = $pagination->per_page * $pagination->current_page - $pagination->per_page;
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->query = ee()->db->query($sql);
if ($channel->query->num_rows() == 0) {
return ee()->TMPL->no_results();
}
ee()->load->library('typography');
ee()->typography->initialize(array('convert_curly' => FALSE, 'encode_email' => FALSE));
$channel->fetch_categories();
$channel->parse_channel_entries();
$output = $channel->return_data;
// Fetch member path variable
// We do it here in case it's used in multiple places.
$m_paths = array();
if (preg_match_all("/" . LD . "member_path(\\s*=.*?)" . RD . "/s", ee()->TMPL->tagdata, $matches)) {
for ($j = 0; $j < count($matches['0']); $j++) {
$m_paths[] = array($matches['0'][$j], ee()->functions->extract_path($matches['1'][$j]));
}
}
//.........这里部分代码省略.........
示例10: array
//.........这里部分代码省略.........
unset($this->EE->TMPL->var_single['auto_path']);
unset($this->EE->TMPL->var_single['excerpt']);
unset($this->EE->TMPL->var_single['id_auto_path']);
unset($this->EE->TMPL->var_single['full_text']);
unset($this->EE->TMPL->var_single['switch']);
foreach($this->EE->TMPL->var_single as $key => $value)
{
if (substr($key, 0, strlen('member_path')) == 'member_path')
{
unset($this->EE->TMPL->var_single[$key]);
}
}
$channel = new Channel;
// This allows the channel {absolute_count} variable to work
$channel->p_page = ($per_page * $current_page) - $per_page;
$channel->fetch_custom_channel_fields();
$channel->fetch_custom_member_fields();
$channel->query = $this->EE->db->query($sql);
if ($channel->query->num_rows() == 0)
{
return $this->EE->TMPL->no_results();
}
$this->EE->load->library('typography');
$this->EE->typography->initialize();
$this->EE->typography->convert_curly = FALSE;
$this->EE->typography->encode_email = FALSE;
$channel->fetch_categories();
$channel->parse_channel_entries();
$tagdata = $this->EE->TMPL->tagdata;
// Does the tag contain "related entries" that we need to parse out?
if (count($this->EE->TMPL->related_data) > 0 AND count($channel->related_entries) > 0)
{
$channel->parse_related_entries();
}
if (count($this->EE->TMPL->reverse_related_data) > 0 AND count($channel->reverse_related_entries) > 0)
{
$channel->parse_reverse_related_entries();
}
$output = $channel->return_data;
$this->EE->TMPL->tagdata = $tagdata;
// Fetch member path variable
// We do it here in case it's used in multiple places.
$m_paths = array();
if (preg_match_all("/".LD."member_path(\s*=.*?)".RD."/s", $this->EE->TMPL->tagdata, $matches))
{
for ($j = 0; $j < count($matches['0']); $j++)
{
$m_paths[] = array($matches['0'][$j], $this->EE->functions->extract_path($matches['1'][$j]));
}
}
// Fetch switch param