/html/AppCode/expressionengine/modules/wiki/mod.wiki.php
PHP | 6074 lines | 5015 code | 575 blank | 484 comment | 387 complexity | 7f10bbf7bb9ad73c18dd5b361923102e MD5 | raw file
Possible License(s): AGPL-3.0
Large files files are truncated, but you can click here to view the full file
- <?php
- /*
- =====================================================
- ExpressionEngine - by EllisLab
- -----------------------------------------------------
- http://expressionengine.com/
- -----------------------------------------------------
- Copyright (c) 2003 - 2010, EllisLab, Inc.
- =====================================================
- THIS IS COPYRIGHTED SOFTWARE
- PLEASE READ THE LICENSE AGREEMENT
- http://expressionengine.com/user_guide/license.html
- =====================================================
- File: mod.wiki.php
- -----------------------------------------------------
- Purpose: Wiki class
- =====================================================
- */
- if ( ! defined('EXT'))
- {
- exit('Invalid file request');
- }
- class Wiki {
- var $version = '1.2';
-
- var $base_path = '';
- var $profile_path = '';
- var $base_url = '';
- var $seg_parts = array();
- var $admins = array('1');
- var $users = array('1', '5');
- var $conditionals = array();
- var $title = '';
- var $topic = '';
- var $revision_id = '';
- var $theme_path = '';
- var $theme_url = '';
- var $image_url = '';
-
- // Namespaces
- var $main_ns = 'Main';
- var $special_ns = 'Special'; // Deutsch: Spezial
- var $file_ns = 'File';
- var $category_ns = 'Category'; // Deutsch: Kategorie
- var $image_ns = 'Image';
- var $current_namespace = '';
- var $namespaces = array();
-
- // Settings
- var $wiki_id = 1;
- var $label_name = 'EE Wiki';
- var $use_captchas = 'n';
- var $text_format = 'xhtml';
- var $html_format = 'safe';
- var $auto_links = "n";
- var $upload_dir = '';
- var $valid_upload_dir = 'n';
- var $can_upload = 'n';
- var $moderation_emails = '';
- var $revision_limit = 100;
- var $author_limit = 75;
- var $min_length_keywords = 3;
- var $cats_separator = '::';
- var $cats_display_separator = ' -> ';
- var $cats_use_namespaces = 'n';
- var $cats_assign_parents = 'y';
-
- // Category Retrieval
- var $temp_array = array();
- var $cat_array = array();
- var $show_these = FALSE;
- var $cat_depth = 0;
- var $parent_cats = array();
-
- // Pagination variables
- var $paginate = FALSE;
- var $pagination_links = '';
- var $page_next = '';
- var $page_previous = '';
- var $current_page = 1;
- var $total_pages = 1;
- var $total_rows = 0;
- var $p_limit = '';
- var $p_page = '';
- var $pagination_sql = '';
-
- var $return_data = '';
-
- /** ----------------------------------------
- /** Constructor
- /** ----------------------------------------*/
-
- function Wiki($return = FALSE)
- {
- // Make a local reference to the ExpressionEngine super object
- $this->EE =& get_instance();
- if ($return === TRUE)
- {
- return;
- }
- $this->EE->lang->loadfile('wiki');
-
- /** ----------------------------------------
- /** Update Module Code
- /** ----------------------------------------*/
-
- if (isset($this->EE->TMPL->module_data['Wiki']['version']) && $this->version > $this->EE->TMPL->module_data['Wiki']['version'])
- {
- $this->update_module($this->EE->TMPL->module_data['Wiki']['version']);
- }
-
- /* ----------------------------------------
- /*
- /* There are five main kinds of pages in the ExpressionEngine Wiki:
- /*
- /* - Main/Index
- /* - Article Page (Including Namespaces)
- /* - Edit Topic Page
- /* - History Topic Page
- /* - Special Page (ex: Uploads, Search Results, Recent Changes)
- /*
- /* Now, the {exp:wiki} tag will be put into a template group
- /* and a template, which is set in base_path="" so that
- /* we can discover the structure of the URLs and what segments
- /* to read for what.
- /* ----------------------------------------*/
-
- if (($this->base_path = $this->EE->TMPL->fetch_param('base_path')) === FALSE)
- {
- return $this->return_data = $this->EE->lang->line('basepath_unset');
- }
-
- $this->base_path = rtrim($this->base_path, '/').'/';
- $this->base_url = $this->EE->functions->create_url($this->base_path).'/';
-
- /* ----------------------------------------
- Creating this array once is very useful and since I do my sanitization
- again here as well as in the Input class, I am sure that the
- segments are clean and ready to use on a page.
- /* ----------------------------------------*/
-
- $x = explode('/', $this->base_path);
-
- $this->seg_parts = explode('/', $this->EE->security->xss_clean(strip_tags(stripslashes($this->EE->uri->query_string))));
-
- /* ----------------------------------------
- Fixes a minor bug in ExpressionEngine where the QSTR variable
- has the template name included when there is no third segment
- on a non-index template - Paul
- /* ----------------------------------------*/
-
- if (isset($x['1']))
- {
- if ($this->seg_parts['0'] == $x['1'])
- {
- array_shift($this->seg_parts);
- }
- }
-
-
- /** ----------------------------------------
- /** Preferences and Language
- /** ----------------------------------------*/
-
- if ($this->EE->TMPL->fetch_param('wiki') !== FALSE)
- {
- $query = $this->EE->db->query("SELECT * FROM exp_wikis WHERE wiki_short_name = '".$this->EE->db->escape_str($this->EE->TMPL->fetch_param('wiki'))."'");
- }
- else
- {
- $query = $this->EE->db->query("SELECT * FROM exp_wikis WHERE wiki_short_name = 'default_wiki'");
- }
-
- if ($query->num_rows() == 0)
- {
- return $this->return_data = 'No Valid Wiki Specified';
- }
-
- foreach($query->row_array() as $field => $value)
- {
- if ($field != 'wiki_id')
- {
- $field = substr($field, 5);
- }
-
- if ($field == 'users' OR $field == 'admins')
- {
- $value = explode('|', $value);
- }
-
- $this->{$field} = $value;
- }
-
- /** ------------------------------------
- /** Retrieve Our Namespaces
- /** ------------------------------------*/
- $namespace_query = $this->EE->db->query("SELECT * FROM exp_wiki_namespaces WHERE wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."' ORDER BY namespace_name");
-
- if ($namespace_query->num_rows() > 0)
- {
- foreach($namespace_query->result_array() as $row)
- {
- $this->namespaces[strtolower($row['namespace_name'])] = array($row['namespace_name'], $row['namespace_label']);
-
- if (isset($this->seg_parts['0']) && strcasecmp($this->prep_title(substr($this->seg_parts['0'], 0, strlen($row['namespace_label'].':'))), $row['namespace_label'].':') == 0)
- {
- $this->admins = explode('|', $row['namespace_admins']);
- $this->users = explode('|', $row['namespace_users']);
- }
- }
- }
-
- if ($this->EE->TMPL->fetch_param('profile_path') !== FALSE)
- {
- $this->profile_path = $this->EE->functions->remove_double_slashes('/'.$this->EE->TMPL->fetch_param('profile_path').'/'.$this->EE->config->item('profile_trigger').'/');
- }
- else
- {
- $this->profile_path = $this->EE->functions->remove_double_slashes('/'.$this->EE->config->item('profile_trigger').'/');
- }
-
- /** ----------------------------------------
- /** Namespaces Localization
- /** ----------------------------------------*/
-
- $this->main_ns = (isset($this->EE->lang->language['main_ns'])) ? $this->EE->lang->line('main_ns') : $this->main_ns;
- $this->file_ns = (isset($this->EE->lang->language['file_ns'])) ? $this->EE->lang->line('file_ns') : $this->file_ns;
- $this->image_ns = (isset($this->EE->lang->language['image_ns'])) ? $this->EE->lang->line('image_ns') : $this->image_ns;
- $this->special_ns = (isset($this->EE->lang->language['special_ns'])) ? $this->EE->lang->line('special_ns') : $this->special_ns;
- $this->category_ns = (isset($this->EE->lang->language['category_ns'])) ? $this->EE->lang->line('category_ns') : $this->category_ns;
-
- /* ----------------------------------------
- /* Category namespace actually has articles so it is put into the
- /* namespaces array. However, instead of the localized name we use
- /* the relatively simple 'category' in the page_namespace field.
- /* ---------------------------------------*/
-
- $this->namespaces['category'] = array('category', $this->category_ns);
-
- /** ----------------------------------------
- /** Tag Settings
- /** ----------------------------------------*/
-
- if ( ! in_array('1', $this->admins)) $this->admins[] = "1";
-
- if ( ! in_array('1', $this->users)) $this->users[] = "1";
-
- foreach($this->admins as $key => $value)
- {
- if (in_array($value, array('2', '3', '4')))
- {
- unset($this->admins[$key]);
- }
- }
-
- foreach($this->users as $key => $value)
- {
- if (in_array($value, array('2', '3', '4')))
- {
- unset($this->users[$key]);
- }
- }
-
- /** ----------------------------------------
- /** Valid Upload Directory?
- /** ----------------------------------------*/
-
- if ( ! empty($this->upload_dir) && is_numeric($this->upload_dir))
- {
- $query = $this->EE->db->query("SELECT COUNT(*) AS count FROM exp_upload_prefs
- WHERE id = '".$this->EE->db->escape_str($this->upload_dir)."'");
-
- if ($query->row('count') > 0)
- {
- $this->valid_upload_dir = 'y';
- $this->can_upload = 'y';
-
- if (in_array($this->EE->session->userdata['group_id'], array(2, 3, 4)))
- {
- $this->can_upload = 'n';
- }
- elseif ($this->EE->session->userdata['group_id'] != 1)
- {
- $query = $this->EE->db->query("SELECT upload_id FROM exp_upload_no_access WHERE member_group = '".$this->EE->session->userdata['group_id']."'");
-
- if ($query->num_rows() > 0)
- {
- foreach($query->result_array() as $row)
- {
- if ($query->row('upload_id') == $this->upload_dir)
- {
- $this->can_upload = 'n';
- break;
- }
- }
- }
- }
- }
- }
-
-
- /** ----------------------------------------
- /** Set theme, load file helper
- /** ----------------------------------------*/
- $this->EE->load->helper('file');
- $this->theme_path = PATH_THEMES.'wiki_themes/default/';
- $this->image_url = $this->EE->config->slash_item('theme_folder_url').'wiki_themes/default/images/';
- $this->theme_url = $this->EE->config->slash_item('theme_folder_url').'wiki_themes/default/';
-
- if ($this->EE->TMPL->fetch_param('theme') !== FALSE && $this->EE->TMPL->fetch_param('theme') != '' && $this->EE->TMPL->fetch_param('theme') != 'default')
- {
- $theme = $this->EE->security->sanitize_filename($this->EE->TMPL->fetch_param('theme'));
- if (is_dir(PATH_THEMES.'/wiki_themes/'.$theme))
- {
- $this->theme_path = PATH_THEMES.'wiki_themes/'.$theme.'/';
- $this->image_url = $this->EE->config->slash_item('theme_folder_url').'wiki_themes/'.$theme.'/images/';
- $this->theme_url = $this->EE->config->slash_item('theme_folder_url').'wiki_themes/'.$theme.'/';
- }
- else
- {
- $this->EE->TMPL->log_item('Wiki module: theme not found - "'.htmlentities($theme).'"');
- }
- }
-
- /** ----------------------------------------
- /** Editing Article
- /** ----------------------------------------*/
-
- if ($this->EE->input->post('editing') == 'y' && $this->EE->input->post('preview') === FALSE)
- {
- return $this->edit_article();
- }
-
- /** ----------------------------------------
- /** Displaying Page
- /** ----------------------------------------*/
-
- $this->return_data = str_replace(array('{module_version}'), array($this->version), $this->_fetch_template('wiki_page.html'));
- $this->return_data = $this->active_members($this->return_data);
- /* -------------------------------------
- /* 'wiki_start' hook.
- /* - Allows page template to be modified prior to article processing
- /* - Added 1.6.0
- */
- if ($this->EE->extensions->active_hook('wiki_start') === TRUE)
- {
- $this->return_data = $this->EE->extensions->universal_call('wiki_start', $this);
- if ($this->EE->extensions->end_script === TRUE) return;
- }
- /*
- /* -------------------------------------*/
-
- /** ----------------------------------------
- /** Determine Page to Show
- /** ----------------------------------------*/
-
- // Index Page
- if (count($this->seg_parts) == 0 OR $this->EE->uri->query_string == '' OR $this->EE->uri->query_string == 'index')
- {
- $this->title = 'index';
- $this->article('index');
- }
-
- // File Page
- elseif (substr($this->seg_parts['0'], 0, strlen($this->file_ns.':')) == $this->file_ns.':')
- {
- $this->title = $this->seg_parts['0'];
- $this->current_namespace = $this->file_ns;
- $this->file(substr($this->seg_parts['0'], strlen($this->file_ns.':')));
- }
-
- // Image
- elseif (substr($this->seg_parts['0'], 0, strlen($this->image_ns.':')) == $this->image_ns.':')
- {
- $this->title = $this->seg_parts['0'];
- $this->current_namespace = $this->image_ns;
- $this->image(substr($this->seg_parts['0'], strlen($this->image_ns.':')));
- }
-
- // Special Page
- elseif (substr($this->seg_parts['0'], 0, strlen($this->special_ns.':')) == $this->special_ns.':')
- {
- $this->title = $this->seg_parts['0'];
- $this->current_namespace = $this->special_ns;
- $this->special(substr($this->seg_parts['0'], strlen($this->special_ns.':')));
- }
-
- // Download!
-
- elseif (isset($this->seg_parts['0']) && strlen($this->seg_parts['0']) == 32 && preg_match("/^[a-z0-9]+$/i", $this->seg_parts['0']))
- {
- $this->display_attachment();
- exit;
- }
-
- // Typical Boring Article. Yawn!
- else
- {
- if (in_array($this->seg_parts['0'], array('edit', 'history', 'revision', 'noredirect')))
- {
- $this->title = 'index';
-
- if ($this->seg_parts['0'] == 'noredirect')
- {
- $this->article('index');
- }
- else
- {
- $this->{$this->seg_parts['0']}('index');
- }
- }
- else
- {
- $this->title = $this->seg_parts['0'];
-
- if ($this->valid_title($this->title) != $this->title)
- {
- $this->redirect('', $this->title);
- }
-
- if (isset($this->seg_parts['1']) && $this->seg_parts['1'] == 'edit')
- {
- $this->edit($this->title);
- }
- elseif (isset($this->seg_parts['1']) && $this->seg_parts['1'] == 'history')
- {
- $this->history($this->title);
- }
- elseif (isset($this->seg_parts['1']) && $this->seg_parts['1'] == 'revision')
- {
- $this->revision($this->title);
- }
- else
- {
- $this->article($this->title);
- }
- }
- }
-
- if ($this->can_upload == 'y')
- {
- $this->return_data = $this->_allow_if('uploads', $this->return_data);
- }
- else
- {
- $this->return_data = $this->_deny_if('uploads', $this->return_data);
- }
- /** ----------------------------------------
- /** Global Tags
- /** ----------------------------------------*/
-
- if (preg_match_all("/\{wiki:custom_namespaces_list(.*?)\}(.*?)\{\/wiki:custom_namespaces_list\}/s", $this->return_data, $matches))
- {
- for($i = 0, $s = count($matches[0]); $i < $s; ++$i)
- {
- $output = '';
-
- if (count($this->namespaces) > 0)
- {
- foreach($this->namespaces as $name => $label)
- {
- $selected = (isset($this->seg_parts['1']) && strtolower($this->seg_parts['1']) == $name) ? 'selected="selected"' : '';
- $output .= str_replace(array('{namespace_short_name}', '{namespace_label}', '{namespace_selected}'), array($label['0'], $label['1'], $selected), $matches['2'][$i]);
- }
- }
-
- $this->return_data = str_replace($matches['0'][$i], $output, $this->return_data);
- }
- }
-
- if (preg_match("/\{wiki:categories_list(.*?)\}(.*?)\{\/wiki:categories_list\}/s", $this->return_data))
- {
- $this->categories_list();
- }
-
- /** ----------------------------------------
- /** Global Conditionals
- /** ----------------------------------------*/
-
- if ($this->EE->session->userdata('member_id') == 0)
- {
- $this->return_data = $this->_deny_if('logged_in', $this->return_data);
- $this->return_data = $this->_allow_if('logged_out', $this->return_data);
- }
- else
- {
- $this->return_data = $this->_allow_if('logged_in', $this->return_data);
- $this->return_data = $this->_deny_if('logged_out', $this->return_data);
- }
-
- if (in_array($this->EE->session->userdata['group_id'], $this->admins))
- {
- $this->return_data = $this->_deny_if('cannot_admin', $this->return_data);
- $this->return_data = $this->_allow_if('can_admin', $this->return_data);
- }
- else
- {
- $this->return_data = $this->_allow_if('cannot_admin', $this->return_data);
- $this->return_data = $this->_deny_if('can_admin', $this->return_data);
- }
-
- /** ----------------------------------------
- /** Global Variables
- /** ----------------------------------------*/
-
-
- $link = $this->create_url($this->current_namespace, $this->topic);
- // Load the XML Helper
- $this->EE->load->helper('xml');
-
- $data = array( '{charset}' => $this->EE->config->item('output_charset'),
- '{wiki_name}' => $this->label_name,
- '{title}' => xml_convert($this->prep_title($this->title)),
- '{url_title}' => xml_convert($this->valid_title($this->title)),
- '{topic}' => xml_convert($this->prep_title($this->topic)),
- '{namespace}' => xml_convert($this->current_namespace),
- '{special_namespace}' => xml_convert($this->special_ns),
- '{main_namespace}' => xml_convert($this->main_ns),
- '{file_namespace}' => xml_convert($this->file_ns),
- '{category_namespace}' => xml_convert($this->category_ns),
- '{image_namespace}' => xml_convert($this->image_ns),
-
- '{revision_id}' => $this->revision_id,
- '{screen_name}' => $this->prep_screen_name($this->EE->session->userdata('screen_name')),
-
- '{path:wiki_home}' => $this->EE->functions->create_url($this->base_path),
- '{path:wiki_base_url}' => $this->base_url,
- '{path:article_history}' => $link.'/history',
- '{path:view_article}' => $link,
- '{path:edit_article}' => $link.'/edit',
-
- '{path:logout}' => $this->EE->functions->fetch_site_index(0, 0).QUERY_MARKER.'ACT='.$this->EE->functions->fetch_action_id('Member', 'member_logout'),
- '{path:your_control_panel}' => $this->EE->functions->create_url($this->profile_path.'profile'),
- '{path:your_profile}' => $this->EE->functions->create_url($this->profile_path.$this->EE->session->userdata('member_id')),
- '{path:login}' => $this->EE->functions->create_url($this->profile_path.'login'),
- '{path:register}' => $this->EE->functions->create_url($this->profile_path.'register'),
- '{path:memberlist}' => $this->EE->functions->create_url($this->profile_path.'memberlist'),
- '{path:forgot}' => $this->EE->functions->create_url($this->profile_path.'forgot_password'),
- '{path:private_messages}' => $this->EE->functions->create_url($this->profile_path.'messages/view_folder/1'),
-
- '{path:image_url}' => $this->image_url,
- '{path:theme_url}' => $this->theme_url,
- '{text_format}' => ucwords(str_replace('_', ' ', $this->text_format))
- );
-
- /** -------------------------------------
- /** Parse URI segments
- /** -------------------------------------*/
-
- // This code lets admins fetch URI segments which become
- // available as: {segment_1} {segment_2}
-
- for ($i = 1; $i < 9; $i++)
- {
- $data[LD.'segment_'.$i.RD] = $this->EE->uri->segment($i);
- }
- /** -------------------------------------
- /** Parse Snippets
- /** -------------------------------------*/
-
- foreach ($this->EE->config->_global_vars as $key => $val)
- {
- $data[LD.$key.RD] = $val;
- }
-
- /** -------------------------------------
- /** Parse manual variables
- /** -------------------------------------*/
-
- if (count($this->EE->TMPL->global_vars) > 0)
- {
- foreach ($this->EE->TMPL->global_vars as $key => $val)
- {
- $data[LD.$key.RD] = $val;
- }
- }
-
- /* -------------------------------------
- /* We reset some of these because in $data we are converting them
- /* for display purposes and we would rather have the conditionals
- /* use the unmodified versions
- /* -------------------------------------*/
-
- $this->conditionals['title'] = $this->title;
- $this->conditionals['topic'] = $this->topic;
- $this->conditionals['namespace'] = $this->current_namespace;
-
- $this->return_data = $this->prep_conditionals($this->return_data, array_merge($data, $this->conditionals));
- $this->return_data = str_replace(array_keys($data), array_values($data), $this->return_data);
-
- /** ----------------------------------------
- /** Cleanup
- /** ----------------------------------------*/
-
- $this->return_data = $this->_deny_if('redirected', $this->return_data);
- $this->return_data = $this->_deny_if('redirect_page', $this->return_data);
-
- }
- // --------------------------------------------------------------------
-
- /**
- * Fetch Template
- *
- * Fetches a template fragment
- *
- * @access public
- * @param string
- * @return string
- */
- function _fetch_template($which)
- {
- return read_file($this->theme_path.$which);
- }
- // --------------------------------------------------------------------
-
- /** ----------------------------------------
- /** Redirect for the Wiki
- /** ----------------------------------------*/
-
- function redirect($namespace='', $title)
- {
- $this->EE->functions->redirect($this->create_url($namespace, $title));
- exit;
- }
-
-
- /** ----------------------------------------
- /** Creat URL for the Wiki
- /** ----------------------------------------*/
-
- function create_url($namespace='', $title)
- {
- if ($namespace == '' && stristr($title, ':') && count($this->namespaces) > 0)
- {
- foreach($this->namespaces as $possible)
- {
- if (substr($title, 0, strlen($possible['1'].':')) == $possible['1'].':')
- {
- $namespace = $possible['1'];
- $title = substr($title, strlen($possible['1'].':'));
- break;
- }
- }
- }
-
- if ($namespace != '')
- {
- /*
- Convert any colons back because of Category articles
- */
-
- $link = $this->EE->functions->create_url($this->base_path.
- urlencode($this->valid_title($namespace)).
- ':'.
- str_replace('%3A', ':', urlencode($this->valid_title($title))));
- }
- else
- {
- $link = $this->EE->functions->create_url($this->base_path.
- urlencode($this->valid_title($title)));
- }
-
- return $link;
- }
-
-
- /** ----------------------------------------
- /** Prep Screen Name for Display
- /** ----------------------------------------*/
-
- function prep_screen_name($str)
- {
- return str_replace(array('<', '>', '{', '}', '\'', '"', '?'), array('<', '>', '{', '}', '’', '"', '?'), $str);
- }
-
- /** ----------------------------------------
- /** Prep Title Display
- /** ----------------------------------------*/
-
- function prep_title($str)
- {
- if ($this->EE->config->item('word_separator') == 'dash')
- {
- return str_replace(array('-', $this->cats_separator), array(' ', $this->cats_display_separator), $str);
- }
- else
- {
- return str_replace(array('_', $this->cats_separator), array(' ', $this->cats_display_separator), $str);
- }
- }
-
-
- /** ----------------------------------------
- /** Create Valid Topic Name
- /** ----------------------------------------*/
-
- function valid_title($str)
- {
- // Remove all numeric entities
- $str = preg_replace('/&#x([0-9a-f]{2,5});{0,1}|&#([0-9]{2,4});{0,1}/', '', $str);
-
- /*
- The PCRE_UTF8 ('u') modifier is not available until PHP 4.2.3 for Windows, so if it is not
- available, then for the time being we are not allowing those higher end characters. We
- will change this once the character library is finished and ready for prime time.
-
- UPDATE: Well, while the PHP documentation says the flag is "available", this does not seem
- to denote that it will actually "work". Seems with the myriad of problems with servers
- having the correct PCRE library *and* compiling PHP with it correctly (RedHat Enterprise 3, for example),
- we cannot realistically do this until a version of PHP greater than PHP 4.3.2. Sheesh...
- */
-
- $trans = array();
-
- if (is_php('4.3.2') === TRUE)
- {
- $trans["#[^a-z0-9\-\_@&\'\"!\.:\+\x{A1}-\x{44F}\s]#iu"] = '';
- }
- else
- {
- $trans["#[^a-z0-9\-\_@&\'\"!\.:\+\xA1-\xFF\s]#i"] = '';
- }
-
- // Use dash or underscore as separator
- $replace = ($this->EE->config->item('word_separator') == 'dash') ? '-' : '_';
-
- $trans = array_merge($trans, array(
- '/\s+/' => $replace,
- "/{$replace}+/" => $replace,
- "/{$replace}$/" => $replace,
- "/^{$replace}/" => $replace
- ));
-
-
- return preg_replace(array_keys($trans), array_values($trans), urldecode($str));
- }
-
- /** ----------------------------------------
- /** Take Namespace's Short Name and Convert to Label
- /** ----------------------------------------*/
-
- function namespace_label($short_name)
- {
- if ($short_name != '')
- {
- $short_name = strtolower($short_name);
- $short_name = (isset($this->namespaces[$short_name])) ? $this->namespaces[$short_name]['1'] : '';
- }
-
- return $short_name;
- }
-
-
- /** ----------------------------------------
- /** Encode EE Tags
- /** ----------------------------------------*/
-
- function encode_ee_tags($str)
- {
- return str_replace(array('{','}'), array('{','}'), $str);
- }
-
-
- /* ----------------------------------------
- /* Topic Request!
- /*
- /* - Title = Namespace:Topic
- /* - If no namespace, then Title and Topic are
- /* the same thing
- /* ----------------------------------------*/
-
- function topic_request($title)
- {
- $title = $this->valid_title($title);
-
- $xsql = " AND page_namespace = '' ";
-
- // In the beginning, these are the same thing
- $this->topic = $title;
- $this->title = $title;
-
- if (stristr($title, ':') && count($this->namespaces) > 0)
- {
- $parts = explode(':', $title, 2);
-
- /* In PHP 5.1 this loop was consistently faster than array_search() */
-
- foreach($this->namespaces as $name => $label)
- {
- if (strcasecmp($label['1'], $this->prep_title($parts['0'])) == 0)
- {
- $xsql = " AND LOWER(page_namespace) = '".$this->EE->db->escape_str($name)."' ";
- $this->topic = substr($this->topic, strlen($label['1'].':'));
- $this->current_namespace = $label['1'];
-
- $this->title = $this->current_namespace.':'.$this->topic;
-
- break;
- }
- }
- }
-
- return $this->EE->db->query("SELECT * FROM exp_wiki_page
- WHERE wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."'
- AND LOWER(page_name) = '".strtolower($this->EE->db->escape_str($this->topic))."'
- {$xsql}");
- }
-
- /** ----------------------------------------
- /** Load Image
- /** ----------------------------------------*/
-
- function image($topic, $return=FALSE)
- {
- if ($return === FALSE)
- {
- $this->title = $this->image_ns.':'.$topic;
- }
-
- /*
- No way to show the image if we do not have a valid upload directory
- because we need the URL for that directory.
- */
-
- if ($this->valid_upload_dir != 'y')
- {
- if ($return === TRUE) return FALSE;
-
- $this->redirect($this->file_ns, $topic);
- }
-
- /** ----------------------------------------
- /** Does File Exist? Is It An Image?
- /** ----------------------------------------*/
-
- $query = $this->EE->db->query("SELECT * FROM exp_wiki_uploads
- WHERE file_name = '".$this->EE->db->escape_str($topic)."'");
-
- if ($query->num_rows() == 0)
- {
- if ($return === TRUE) return FALSE;
-
- $this->redirect($this->file_ns, $topic);
- }
-
- $x = explode('/',$query->row('file_type') );
-
- if ($x['0'] != 'image')
- {
- if ($return === TRUE) return FALSE;
-
- $this->redirect($this->file_ns, $topic);
- }
-
- /** ----------------------------------------
- /** Create Our URL
- /** ----------------------------------------*/
-
- if ($return === TRUE)
- {
- $file_url = $this->base_url.$query->row('file_hash');
- }
- else
- {
- $results = $this->EE->db->query("SELECT url FROM exp_upload_prefs
- WHERE id = '".$this->EE->db->escape_str($this->upload_dir)."'");
-
- $file_url = (substr($results->row('url') , -1) == '/') ? $results->row('url') : $results->row('url') .'/';
- $file_url .= $query->row('file_name') ;
- }
-
- /* ----------------------------------------
- /* Display Our Image
- /* - Now in the future we might be clever and obfuscate the location
- /* - of images, if it is requested, by using fopen to get the image
- /* - data and displaying it instead of doing a redirect to the URL
- /* ----------------------------------------*/
-
- if ($return === TRUE)
- {
- return array('url' => $file_url,
- 'width' => $query->row('image_width') ,
- 'height' => $query->row('image_height') ,
- 'name' => $query->row('file_name') );
- }
-
- $this->EE->functions->redirect($file_url);
- exit;
- }
- /** ----------------------------------------
- /** File
- /** ----------------------------------------*/
-
- function file($topic)
- {
- $this->title = $this->file_ns.':'.$topic;
- $this->topic = $topic;
-
- /** ----------------------------------------
- /** Delete File? Admins Only!
- /** ----------------------------------------*/
-
- if (isset($this->seg_parts['1']) && strtolower($this->seg_parts['1']) == 'delete')
- {
- if ($this->can_upload == 'y' && in_array($this->EE->session->userdata['group_id'], $this->admins))
- {
- $query = $this->EE->db->query("SELECT COUNT(*) AS count FROM exp_wiki_uploads
- WHERE file_name = '".$this->EE->db->escape_str($topic)."'");
-
- if ($query->row('count') > 0)
- {
- $query = $this->EE->db->query("SELECT * FROM exp_upload_prefs
- WHERE id = '".$this->EE->db->escape_str($this->upload_dir)."'");
-
- $server_path = $query->row('server_path');
-
- if (substr($server_path , -1) != '/')
- {
- $server_path .= '/';
- }
-
- @unlink($server_path.$topic);
-
- $query = $this->EE->db->query("DELETE FROM exp_wiki_uploads
- WHERE file_name = '".$this->EE->db->escape_str($topic)."'");
-
- // Clear wiki cache
- $this->EE->functions->clear_caching('db');
- $this->redirect($this->special_ns, 'Files');
- }
- }
- }
-
- $this->return_data = $this->_deny_if('new_article', $this->return_data);
- $this->return_data = $this->_deny_if('article', $this->return_data);
- $this->return_data = $this->_deny_if('revision', $this->return_data);
- $this->return_data = $this->_deny_if('edit_article', $this->return_data);
- $this->return_data = $this->_deny_if('article_history', $this->return_data);
- $this->return_data = $this->_deny_if('special_page', $this->return_data);
- $this->return_data = $this->_allow_if('file_page', $this->return_data);
-
- $this->return_data = str_replace('{wiki:page}', $this->_fetch_template('wiki_file.html'), $this->return_data);
-
- $query = $this->EE->db->query("SELECT u.*, m.member_id, m.screen_name, m.email, m.url
- FROM exp_wiki_uploads u, exp_members m
- WHERE u.file_name = '".$this->EE->db->escape_str($topic)."'
- AND u.wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."'
- AND u.upload_author = m.member_id");
-
- /** ----------------------------------------
- /** Does File Exist? What Kind?
- /** ----------------------------------------*/
-
- if ($query->num_rows() == 0)
- {
- $this->return_data = $this->_deny_if('file_exists', $this->return_data);
- return;
- }
- else
- {
- $this->return_data = $this->_allow_if('file_exists', $this->return_data);
- }
-
- $x = explode('/',$query->row('file_type') );
-
- if ($x['0'] == 'image')
- {
- $this->return_data = $this->_allow_if('is_image', $this->return_data);
- }
- else
- {
- $this->return_data = $this->_deny_if('is_image', $this->return_data);
- }
-
- /** ----------------------------------------
- /** Date Formats
- /** ----------------------------------------*/
-
- if (preg_match_all("/".LD."(upload_date)\s+format=[\"'](.*?)[\"']".RD."/s", $this->return_data, $matches))
- {
- for ($j = 0; $j < count($matches['0']); $j++)
- {
- switch ($matches['1'][$j])
- {
- case 'upload_date' : $upload_date[$matches['0'][$j]] = array($matches['2'][$j], $this->EE->localize->fetch_date_params($matches['2'][$j]));
- break;
- }
- }
-
- foreach($upload_date as $key => $value)
- {
- $temp_date = $value['0'];
-
- foreach ($value['1'] as $dvar)
- {
- $temp_date = str_replace($dvar, $this->EE->localize->convert_timestamp($dvar, $row['upload_date'], FALSE), $temp_date);
- }
-
- $this->return_data = str_replace($key, $temp_date, $this->return_data);
- }
- }
-
- /** ----------------------------------------
- /** Parse Variables
- /** ----------------------------------------*/
-
- $this->EE->load->library('typography');
- $this->EE->typography->initialize();
- $this->EE->typography->parse_images = FALSE;
- $this->EE->typography->parse_smileys = FALSE;
-
- $summary = $this->convert_curly_brackets($this->EE->typography->parse_type( $this->wiki_syntax($query->row('upload_summary') ),
- array(
- 'text_format' => $this->text_format,
- 'html_format' => $this->html_format,
- 'auto_links' => $this->auto_links,
- 'allow_img_url' => 'y'
- )
- ));
-
- $delete_url = '';
-
- if ($this->valid_upload_dir != 'y')
- {
- $file_url = $query->row('file_name') ;
- }
- else
- {
- $file_url = $this->base_url.$query->row('file_hash');
-
- if (in_array($this->EE->session->userdata['group_id'], $this->admins))
- {
- $delete_url = $this->base_url.$this->file_ns.':'.$query->row('file_name').'/delete';
- }
- }
-
- $this->conditionals['summary'] = $summary;
- $this->conditionals['delete_url'] = $delete_url;
- $this->conditionals = array_merge($this->conditionals, $query->row_array());
-
-
- /** ----------------------------------------
- /** Can User Edit File?
- /** ----------------------------------------*/
-
- if(in_array($this->EE->session->userdata['group_id'], $this->users) OR in_array($this->EE->session->userdata['group_id'], $this->admins))
- {
- $this->return_data = $this->_allow_if('can_edit', $this->return_data);
- $this->return_data = $this->_deny_if('cannot_edit', $this->return_data);
- }
- else
- {
- $this->return_data = $this->_deny_if('can_edit', $this->return_data);
- $this->return_data = $this->_allow_if('cannot_edit', $this->return_data);
- }
-
- $this->return_data = str_replace(array('{file_url}','{delete_url}','{file_name}','{summary}', '{image_width}', '{image_height}', '{file_type}'),
- array($file_url, $delete_url, $query->row('file_name') , $summary, $query->row('image_width') , $query->row('image_height') , $query->row('file_type') ),
- $this->return_data);
-
- }
-
- /** ----------------------------------------
- /** Special
- /** ----------------------------------------*/
-
- function special($topic)
- {
- $this->topic = $topic;
- $this->title = $this->special_ns.':'.$topic;
-
- $this->return_data = $this->_deny_if('new_article', $this->return_data);
- $this->return_data = $this->_deny_if('article', $this->return_data);
- $this->return_data = $this->_deny_if('revision', $this->return_data);
- $this->return_data = $this->_deny_if('edit_article', $this->return_data);
- $this->return_data = $this->_deny_if('article_history', $this->return_data);
- $this->return_data = $this->_allow_if('special_page', $this->return_data);
-
- /* -------------------------------------
- /* 'wiki_special_page' hook.
- /* - Allows complete takeover of special pages
- /* - Added 1.6.0
- */
- $edata = $this->EE->extensions->universal_call('wiki_special_page', $this, $topic);
- if ($this->EE->extensions->end_script === TRUE) return;
- /*
- /* -------------------------------------*/
-
- switch(strtolower($topic))
- {
- case 'recentchanges' :
- $this->recent_changes();
- break;
-
- case 'search_results' :
- $this->search_results();
- break;
-
- case 'random_page' :
- $this->random_page();
- break;
-
- case 'categories' :
- $this->categories();
- break;
-
- case 'files' :
- $this->files();
- break;
-
- case 'find_page' :
- $this->find_page();
- break;
-
- case 'uploads' :
- $this->upload_form();
- break;
-
- case 'recentchanges_rss' :
- $this->EE->output->out_type = 'feed';
- $this->EE->TMPL->template_type = 'feed';
- $this->return_data = $this->_fetch_template('wiki_special_rss.html');
- $this->recent_changes('rss');
- break;
-
- case 'recentchanges_atom' :
- $this->EE->output->out_type = 'feed';
- $this->EE->TMPL->template_type = 'feed';
- $this->return_data = $this->_fetch_template('wiki_special_atom.html');
- $this->recent_changes('atom');
- break;
-
- case 'titles' :
- $this->title_list();
- break;
-
- case 'associated_pages' :
- $this->associated_pages();
- break;
-
- case 'uncategorized' :
- $this->uncategorized_pages();
- break;
-
- case 'css' :
- $this->wiki_css();
- break;
-
- default:
- $this->return_data = str_replace('{wiki:page}', '', $this->return_data);
- break;
- }
-
- $this->return_data = $this->_deny_if('can_edit', $this->return_data);
- $this->return_data = $this->_allow_if('cannot_edit', $this->return_data);
- }
- // --------------------------------------------------------------------
-
- /**
- * Wiki CSS
- *
- * Outputs the default Wiki CSS theme file with proper headers
- *
- * @access public
- * @return void
- */
- function wiki_css()
- {
- // reset! We just want the CSS
- $this->return_data = $this->_fetch_template('wiki_style.css');
- if ($this->return_data === FALSE)
- {
- // no point
- exit;
- }
- // replace image paths
- $this->return_data = str_replace('{path:image_url}', $this->image_url, $this->return_data);
- $last_modified = filemtime($this->theme_path.'wiki_style.css');
- $this->EE->load->library('stylesheet');
- $this->EE->stylesheet->_send_css($this->return_data, $last_modified);
- }
- // --------------------------------------------------------------------
-
-
-
- /** ---------------------------------------
- /** Uncategorized Pages
- /** ---------------------------------------*/
-
- function uncategorized_pages()
- {
- return $this->title_list('uncategorized_pages');
- }
- /* END */
-
-
- /** ----------------------------------------
- /** Recent Changes Processing
- /** ----------------------------------------*/
-
- function title_list($type = '')
- {
- /** ---------------------------------------
- /** Initialize the correct template and do any
- /** prep work needed prior to our title query
- /** ---------------------------------------*/
-
- switch ($type)
- {
- case 'uncategorized_pages' :
- $this->return_data = str_replace('{wiki:page}', $this->_fetch_template('wiki_special_uncategorized_pages.html'), $this->return_data);
-
- /** ---------------------------------------
- /** Get categorized page ids
- /** ---------------------------------------*/
- $query = $this->EE->db->query("SELECT DISTINCT(exp_wiki_category_articles.page_id)
- FROM exp_wiki_category_articles
- LEFT JOIN exp_wiki_page ON exp_wiki_page.page_id = exp_wiki_category_articles.page_id
- WHERE exp_wiki_page.wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."'");
- if ($query->num_rows() > 0)
- {
- $page_ids = array();
- foreach ($query->result() as $row)
- {
- $page_ids[] = $row->page_id;
- }
-
- $xsql = " AND p.page_id NOT IN (".implode(',', $page_ids).")
- AND p.page_redirect = '' ";
- }
- break;
-
- default :
- $this->return_data = str_replace('{wiki:page}', $this->_fetch_template('wiki_special_titles.html'), $this->return_data);
- break;
-
- }
-
- if ( ! preg_match("/\{wiki:title_list(.*?)\}(.*?)\{\/wiki:title_list\}/s", $this->return_data, $match))
- {
- return $this->return_data = '';
- }
-
- if ( ! preg_match("/\{articles\}(.*?)\{\/articles\}/s", $match['2'], $topics))
- {
- return $this->return_data = '';
- }
-
- /** ----------------------------------------
- /** Parameters
- /** ----------------------------------------*/
-
- $columns = 3;
-
- if (trim($match['1']) != '' && ($params = $this->EE->functions->assign_parameters($match['1'])) !== FALSE)
- {
- $columns = (isset($params['columns']) && is_numeric($params['columns'])) ? $params['columns'] : $limit;
- }
-
- /** ----------------------------------------
- /** Date Formats
- /** ----------------------------------------*/
-
- $dates = $this->parse_dates($this->return_data);
-
- /** ----------------------------------------
- /** Our Query
- /** ----------------------------------------*/
- if ( ! isset($xsql))
- {
- $xsql = '';
- }
-
- if (isset($this->seg_parts['1']) && isset($this->namespaces[strtolower($this->seg_parts['1'])]))
- {
- $xsql = "AND LOWER(p.page_namespace) = '".$this->EE->db->escape_str(strtolower($this->seg_parts['1']))."'";
- }
- else
- {
- $xsql = "AND p.page_namespace = ''";
- }
-
- $results = $this->EE->db->query("SELECT r.*,
- m.member_id, m.screen_name, m.email, m.url,
- p.page_namespace, p.page_name AS topic
- FROM exp_wiki_revisions r, exp_members m, exp_wiki_page p
- WHERE p.last_updated = r.revision_date
- {$xsql}
- AND m.member_id = r.revision_author
- AND r.page_id = p.page_id
- AND r.revision_status = 'open'
- AND r.wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."'
- ORDER BY p.page_name");
-
- if ($results->num_rows() == 0)
- {
- if (preg_match("|".LD."if\s+no_results".RD."(.*?)".LD."\/if".RD."|s",$match['2'], $block))
- {
- $this->return_data = str_replace($match['0'], $block['1'], $this->return_data);
- }
- else
- {
- $this->return_data = str_replace($match['0'], str_replace($topics['0'], '', $match['2']), $this->return_data);
- }
-
- return;
- }
-
- /** ----------------------------------------
- /** Template Parts
- /** ----------------------------------------*/
-
- $our_template = $topics['1'];
- $row_start = '';
- $row_end = '';
- $row_blank = '';
- $row_column = '';
-
- foreach(array('row_start', 'row_end', 'row_blank', 'row_column') as $val)
- {
- if (preg_match("/\{".preg_quote($val)."\}(.*?)\{\/".preg_quote($val)."\}/s", $our_template, $matching))
- {
- $$val = $matching['1'];
- }
- }
-
- $template = $row_column;
-
- /** ----------------------------------------
- /** Parsing of the Recent Changes Tag Pair
- /** ----------------------------------------*/
-
- $parse_article = stristr($template, '{article}');
-
- $this->EE->load->library('typography');
- $this->EE->typography->initialize();
- $this->EE->typography->parse_images = FALSE;
- $this->EE->typography->parse_smileys = FALSE;
-
- $titles = $row_start;
- $i = 0;
- $count = 0;
-
- // added in 1.6 for {switch} variable and for future use
- $vars = $this->EE->functions->assign_variables($template);
- $this->EE->load->helper('url');
-
- foreach($results->result_array() as $row)
- {
- $count++;
-
- $titles .= ($i % $columns != 0) ? '' : $row_end.$row_start; ++$i;
-
- $temp = $template;
-
- if (isset($this->seg_parts['1']) && isset($this->namespaces[strtolower($this->seg_parts['1'])]))
- {
- $title = $row['topic'];
- }
- else
- {
- $title = ($row['page_namespace'] != '') ? $this->namespace_label($row['page_namespace']).':'.$row['topic'] : $row['topic'];
- }
-
- $link = $this->create_url($this->namespace_label($row['page_namespace']), $row['topic']);
- $data = array( '{title}' => $this->prep_title($title),
- '{revision_id}' => $row['revision_id'],
- '{page_id}' => $row['page_id'],
- '{author}' => $row['screen_name'],
- '{path:author_profile}' => $this->EE->functions->create_url($this->profile_path.$row['member_id']),
- '{path:member_profile}' => $this->EE->functions->create_url($this->profile_path.$row['member_id']),
- '{email}' => $this->EE->typography->encode_email($row['email']),
- '{url}' => prep_url($row['url']),
- '{revision_notes}' => $row['revision_notes'],
- '{path:view_article}' => $link,
- '{content}' => $row['page_content'],
- '{count}' => $count);
-
- if ($parse_article !== FALSE)
- {
- $data['{article}'] = $this->convert_curly_brackets($this->EE->typography->parse_type( $this->wiki_syntax($row['page_content'], FALSE),
- array(
- 'text_format' => $this->text_format,
- 'html_format' => $this->html_format,
- 'auto_links' => $this->auto_links,
- 'allow_img_url' => 'y'
- )
- ));
- }
-
- $temp = $this->prep_conditionals($temp, array_merge($data, $this->conditionals));
- if (isset($dates['last_updated']))
- {
- foreach($dates['last_updated'] as $key => $value)
- {
- $temp_date = $value['0'];
-
- // Do this once here, to save energy
- $row['revision_date'] = $this->EE->localize->set_localized_time($row['revision_date']);
-
- foreach ($value['1'] as $dvar)
- {
- $temp_date = str_replace($dvar, $this->EE->localize->convert_timestamp($dvar, $row['revision_date'], FALSE), $temp_date);
- }
-
- $data[$key] = $temp_date;
- }
- }
- foreach ($vars['var_single'] as $key => $val)
- {
- /** ----------------------------------------
- /** parse {switch} variable
- /** ----------------------------------------*/
- if (preg_match("/^switch\s*=.+/i", $key))
- {
- $sparam = $this->EE->functions->assign_parameters($key);
- $sw = '';
- if (isset($sparam['switch']))
- {
- $sopt = explode("|", $sparam['switch']);
- $sw = $sopt[($count-1 + count($sopt)) % count($sopt)];
- }
- $temp = $this->EE->TMPL->swap_var_single($key, $sw, $temp);
- }
- }
-
- $titles .= str_replace(array_keys($data), array_values($data), $temp);
- }
-
- while($i % $columns != 0)
- {
- $titles .= $row_blank; ++$i;
- }
-
- $titles .= $row_end;
-
- $this->return_data = str_replace($match['0'], str_replace($topics['0'], $titles, $match['2']), $this->return_data);
-
- }
-
-
- /** ----------------------------------------
- /** Recent Changes Processing
- /** ----------------------------------------*/
-
- function recent_changes($type='')
- {
- /** ----------------------------------------
- /** Load Template, Check for Valid Tag
- /** ----------------------------------------*/
-
- $this->return_data = str_replace('{wiki:page}', $this->_fetch_template('wiki_special_recent_changes.html'), $this->return_data);
-
- if ( ! preg_match("/\{wiki:recent_changes(.*?)\}(.*?)\{\/wiki:recent_changes\}/s", $this->return_data, $match))
- {
- return $this->return_data = '';
- }
-
- /** ----------------------------------------
- /** Parameters
- /** ----------------------------------------*/
-
- $parameters['limit'] = 10;
- $parameters['paginate'] = 'bottom';
-
- if (trim($match['1']) != '' && ($params = $this->EE->functions->assign_parameters($match['1'])) !== FALSE)
- {
- $parameters['limit'] = (isset($params['limit']) && is_numeric($params['limit'])) ? $params['limit'] : $parameters['limit'];
- $parameters['paginate'] = (isset($params['paginate']) && is_numeric($params['paginate'])) ? $params['paginate'] : $parameters['paginate'];
- }
-
- /** ----------------------------------------
- /** Date Formats
- /** ----------------------------------------*/
-
- $dates = $this->parse_dates($this->return_data);
-
- /** ----------------------------------------
- /** Our Query
- /** ----------------------------------------*/
-
- if (isset($this->seg_parts['1']) && $this->seg_parts['1'] != '' && ! preg_match("/^P[0-9]+$/", $this->seg_parts['1']))
- {
- $query = $this->topic_request($this->seg_parts['1']);
-
- $sql = "FROM exp_wiki_revisions r, exp_members m, exp_wiki_page p
- WHERE p.page_id = '".(($query->num_rows() > 0) ? $query->row('page_id') : '0')."'
- AND r.page_id = p.page_id
- AND r.revision_status = 'open'
- AND r.wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."'
- AND m.member_id = r.revision_author
- ORDER BY r.revision_date DESC";
- }
- else
- {
- $sql = "FROM exp_wiki_revisions r, exp_members m, exp_wiki_page p
- WHERE p.last_updated = r.revision_date
- AND m.member_id = r.revision_author
- AND r.page_id = p.page_id
- AND r.revision_status = 'open'
- AND r.wiki_id = '".$this->EE->db->escape_str($this->wiki_id)."'
- ORDER BY p.last_updated DESC";
- }
-
- $results = $this->EE->db->query("SELECT COUNT(*) AS count ".$sql);
-
- if ($results->row('count') == 0)
- {
- return $this->return_data = '';
- }
-
- $this->pagination($results->row('count') , $parameters['limit'], $this->base_url.$this->special_ns.':Recentchanges/');
-
- // Pagination code removed, rerun template preg_match()
- if ($this->paginate === TRUE)
- {
- preg_match("/\{wiki:recent_changes(.*?)\}(.*?)\{\/wiki:recent_changes\}/s", $this->return_data, $match);
- }
- else
- {
- $this->pagination_sql .= " LIMIT ".$parameters['limit'];
- }
-
- $results = $this->EE->db->query("SELECT r.*,
- m.member_id, m.screen_name, m.email, m.url,
- p.page_namespace, p.page_name AS topic ".
- $sql.
- $this->pagination_sql);
-
- /** ----------------------------------------
- /** Global Last Updated
- /** ----------------------------------------*/
-
- if (isset($dates['last_updated']))
- {
- foreach($dates['last_updated'] as $key => $value)
- {
- $temp_date = $value['0'];
-
- foreach ($value['1'] as $dvar)
- {
- $temp_date = str_replace($dvar, $this->EE->localize->convert_timestamp($dvar, $results->row('revision_date') , TRUE), $temp_date);
- }
-
- $this->return_data = str_replace($key, $temp_date, $this->return_data);
- }
- }
-
- if (isset($dates['gmt_last_updated']))
- {
- foreach($dates['gmt_last_updated'] as $key => $value)
- {
- $temp_date = $value['0'];
-
- foreach ($value['1'] as $dvar)
- {
- $temp_date = str_replace($dvar, $this->EE->localize->convert_timestamp($dvar, $results->row('revision_date') , FALSE), $temp_date);
- }
-
- $this->return_data = str_replace($key, $temp_date, $this->return_data);
- }
- }
-
- /** -----------------------------------…
Large files files are truncated, but you can click here to view the full file