$this->db->set('variable_name', $variable_name); $this->db->set('variable_data', $variable_data); $this->db->set('site_id', $this->config->item('site_id')); $this->db->insert('global_variables'); return $this->db->insert_id(); } /** * Delete Global Variable * * @access public * @param integer * @return integer */ function delete_global_variable($variable_id) { $this->db->where('variable_id', $variable_id); $this->db->delete('global_variables'); return $this->db->affected_rows(); } /** * Get Specialty Email Templates Summary * * Gets the ids and names of all specialty email templates * * @access public * @return array */ function get_specialty_email_templates_summary() { $this->db->select('template_id, template_name'); $this->db->from("specialty_templates"); $this->db->where('site_id', $this->config->item('site_id')); $this->db->where('template_name !=', "message_template"); $this->db->where('template_name !=', "offline_template"); $this->db->order_by('template_name'); $results = $this->db->get(); return $results; } /** * Get Specialty Template Data * * Returns a specialty template * * @access public * @param string * @return string */ function get_specialty_template($template_name) { $this->db->select('data_title, template_id, template_data, enable_template'); $this->db->from("specialty_templates"); $this->db->where('site_id', $this->config->item('site_id')); $this->db->where('template_name', $template_name); $results = $this->db->get(); return $results; } /** * Get Specialty Template Variables * * Returns available variables to a given specialty template * * @access public * @param string * @return array */ function get_specialty_template_vars($template_name) { $vars = array( 'admin_notify_reg' => array('name', 'username', 'email', 'site_name', 'control_panel_url'), 'admin_notify_entry' => array('channel_name', 'entry_title', 'entry_url', 'comment_url', 'cp_edit_entry_url', 'name', 'email'), 'admin_notify_comment' => array('channel_name', 'entry_title', 'entry_id', 'url_title', 'channel_id', 'comment_url_title_auto_path', 'comment_url', 'comment', 'comment_id', 'name', 'url', 'email', 'location', 'unwrap}{delete_link}{/unwrap', 'unwrap}{close_link}{/unwrap', 'unwrap}{approve_link}{/unwrap'), 'admin_notify_forum_post' => array('name_of_poster', 'forum_name', 'title', 'body', 'thread_url', 'post_url'), 'mbr_activation_instructions' => array('name', 'username', 'email', 'activation_url', 'site_name', 'site_url'), 'forgot_password_instructions' => array('name', 'username', 'reset_url', 'site_name', 'site_url'), 'decline_member_validation' => array('name', 'username', 'site_name', 'site_url'), 'validated_member_notify' => array('name', 'username', 'email', 'site_name', 'site_url'), 'comment_notification' => array('name_of_commenter', 'name_of_recipient', 'channel_name', 'entry_title', 'entry_id', 'url_title', 'channel_id', 'comment_url_title_auto_path', 'comment_url', 'comment', 'notification_removal_url', 'site_name', 'site_url', 'comment_id'), 'comments_opened_notification' => array('name_of_recipient', 'channel_name', 'entry_title', 'entry_id', 'url_title', 'channel_id', 'comment_url_title_auto_path', 'comment_url', 'notification_removal_url', 'site_name', 'site_url', 'total_comments_added', 'comments', 'name_of_commenter', 'comment_id', 'comment', '/comments'), 'forum_post_notification' => array('name_of_recipient', 'name_of_poster', 'forum_name', 'title', 'thread_url', 'body', 'post_url'), 'private_message_notification' => array('sender_name', 'recipient_name','message_subject', 'message_content', 'site_url', 'site_name'), 'pm_inbox_full' => array('sender_name', 'recipient_name', 'pm_storage_limit','site_url', 'site_name'), 'forum_moderation_notification' => array('name_of_recipient', 'forum_name', 'moderation_action', 'title', 'thread_url'), 'forum_report_notification' => array('forum_name', 'reporter_name', 'author', 'body', 'reasons', 'notes', 'post_url') ); return (isset($vars[$template_name])) ? $vars[$template_name] : array(); } /** * Update Specialty Template * * @access public * @param integer * @param string * @return string */ function update_specialty_template($template_id, $template_data, $enable_template = 'y', $template_title = NULL) { $this->db->set('template_data', $template_data); $this->db->set('enable_template', $enable_template); if ($template_title) { $this->db->set('data_title', $template_title); } $this->db->where('template_id', $template_id); $this->db->where('site_id', $this->config->item('site_id')); $this->db->update('specialty_templates'); return $this->db->affected_rows(); } } /** * A Prototype Database Entity * * A prototype database entity for use with the templates table. Properties * have a 1 to 1 correspondence with db table properties. In addition, the * template knows whether or not it has been loaded from a file. */ class Template_Entity { /** * */ protected $template_id; /** * */ protected $site_id; /** * */ protected $group_id; /** * */ protected $template_name; /** * */ protected $template_type; /** * */ protected $template_data; /** * */ protected $template_notes; /** * */ protected $edit_date; /** * */ protected $last_author_id; /** * */ protected $cache; /** * */ protected $refresh; /** * */ protected $no_auth_bounce; /** * */ protected $enable_http_auth; /** * */ protected $allow_php; /** * */ protected $php_parse_location; /** * */ protected $hits; protected $protect_javascript; // ---------------------------------------------------- // Non-Database Properties // ---------------------------------------------------- /** * An entity only property that indicates whether this * entity was loaded from a file or just the database. If * TRUE then this template was loaded from a file, otherwise * it was loaded from the database. */ protected $loaded_from_file = FALSE; // ---------------------------------------------------- // Associated Entities // ---------------------------------------------------- /** * An instance of Template_Group_Entity representing the associated * Template Group. */ protected $template_group; /** * */ public function __construct(array $templates_row = array()) { foreach ($templates_row as $property=>$value) { if ( property_exists($this, $property)) { $this->{$property} = $value; } } } /** * */ public function __get($name) { if ( strpos('_', $name) === 0 OR ! property_exists($this, $name)) { throw new RuntimeException('Attempt to access non-existent property "' . $name . '"'); } return $this->{$name}; } /** * */ public function __set($name, $value) { if ( strpos('_', $name) === 0 OR ! property_exists($this, $name)) { throw new RuntimeException('Attempt to access non-existent property "' . $name . '"'); } $this->{$name} = $value; } /** * Get Associated Template Group * * Gets an Entity representing this Template's Template Group. * * @returns Template_Group_Entity The associated Template Group. */ public function get_group() { return $this->template_group; } /** * Set this Template's Template Group * * Used to set the link to this Template's Template Group. * * @param Template_Group_Entity $group The group Entity to link to * this Template. * * @return $this */ public function set_group(Template_Group_Entity $group) { $this->template_group = $group; $this->group_id = $group->group_id; return $this; } } /** * */ class Template_Group_Entity { /** * */ private $group_id; /** * */ private $site_id; /** * */ private $group_name; /** * */ private $group_order; /** * */ private $is_site_default; /** * */ public function __construct(array $groups_row = array()) { foreach ($groups_row as $property=>$value) { if ( property_exists($this, $property)) { $this->{$property} = $value; } } } /** * */ public function __get($name) { if ( strpos('_', $name) === 0 OR ! property_exists($this, $name)) { throw new RuntimeException('Attempt to access non-existent property "' . $name . '"'); } return $this->{$name}; } /** * */ public function __set($name, $value) { if ( strpos('_', $name) === 0 OR ! property_exists($this, $name)) { throw new RuntimeException('Attempt to access non-existent property "' . $name . '"'); } $this->{$name} = $value; } } // EOF ($7ffffppears to be a Unix timestamp, prepend the // string with '@' so DateTime knows it's a timestamp; the // timezone parameter is ignored when a timestamp is passed, // so set it separately after instantiation if (is_numeric($date_string)) { $dt = new DateTime('@'.$date_string); $dt->setTimezone($timezone); } // Otherwise, we must instantiate the DateTime object with the // correct DateTimeZone so that the date string passed in is // immediately interpreted using the member's timezone and not // the server timezone; otherwise, using setTimezone to set // the timezone later will transform the date else { // Attempt to use their date (and time) format if ( ! is_null($date_format)) { $date_format = str_replace('%', '', $date_format); $dt = DateTime::createFromFormat($date_format, $date_string, $timezone); // In the case they just passed a date, we need to only use // their date format. if ( ! $dt) { $date_only_format = ee()->session->userdata( 'date_format', ee()->config->item('date_format') ); // The pipe makes sure all other time elements are // replaced by the unix epoch $date_only_format = str_replace('%', '', $date_only_format).'|'; $dt = DateTime::createFromFormat( $date_only_format, $date_string, $timezone ); } } // If there's no date format, or if the date format failed, toss // it back to PHP. // Using `date_create` instead of `new DateTime` to work around // a bug in php's usort (https://bugs.php.net/bug.php?id=50688). // Used by the table library to sort by date if (empty($dt)) { $dt = date_create($date_string, $timezone); if ($dt === FALSE) { return FALSE; } } $dt = ( ! empty($dt)) ? $dt : date_create($date_string, $timezone); } } catch (Exception $e) { return FALSE; } // Apply server offset only if (empty($date_string) && ($offset = ee()->config->item('server_offset')) && is_numeric($offset)) { $offset = ($offset > 0) ? '+'.$offset : $offset; $dt->modify($offset.' minutes'); } return $dt; } /** * Generates an HTML menu of timezones * * @param string Default timezone selection * @param string Name of dropdown form field element * @return string HTML for dropdown list */ public function timezone_menu($default = NULL, $name = 'default_site_timezone') { // For the installer ee()->load->helper('language'); // We only want timezones with these prefixes $continents = array('Africa', 'America', 'Antarctica', 'Arctic', 'Asia', 'Atlantic', 'Australia', 'Europe', 'Indian', 'Pacific'); $zones_by_country = $this->_get_timezones_by_country(); $countries = $this->_get_countries(); $timezones = array(); foreach ($countries as $code => $country) { // If country code does not match any timezones, skip the loop if ( ! isset($zones_by_country[$code])) { continue; } // We'll store timezones for the current country here $local_zones = array(); foreach ($zones_by_country[$code] as $zone) { // Explode ID by slashes while replacing underscores with spaces $zone_array = str_replace('_', ' ', explode('/', $zone)); // Exclude deprecated PHP timezones if ( ! in_array($zone_array[0], $continents)) { continue; } // Construct the localized zone name if (isset($zone_array[1])) { $zone_name = lang($zone_array[1]); if (isset($zone_array[2])) { $zone_name .= ' - ' . lang($zone_array[2]); } $local_zones[$zone] = $zone_name; } } // Sort timezones by their new names asort($local_zones); $timezones[$code] = $local_zones; } // Convert to JSON for fast switching of timezone dropdown $timezone_json = json_encode($timezones); $no_timezones_lang = lang('no_timezones'); // Start the output with some javascript to handle the timezone // dropdown population based on the country dropdown $output = << var timezones = $timezone_json function ee_tz_change(countryselect) { var timezoneselect = document.getElementById('timezone_select'); var countrycode = countryselect.options[countryselect.selectedIndex].value; timezoneselect.options.length = 0; if (timezones[countrycode] == '' || timezones[countrycode] == undefined) { timezoneselect.add(new Option('$no_timezones_lang', '')); return; } for (var key in timezones[countrycode]) { if (timezones[countrycode].hasOwnProperty(key)) { timezoneselect.add(new Option(timezones[countrycode][key], key)); } } } EOF; // Prepend to the top of countries dropdown with common country selections $countries = array_merge( array( lang('select_timezone'), '-------------', 'us' => $countries['us'], // United States 'gb' => $countries['gb'], // United Kingdom 'au' => $countries['au'], // Australia 'ca' => $countries['ca'], // Canada 'fr' => $countries['fr'], // France 'ie' => $countries['ie'], // Ireland 'nz' => $countries['nz'], // New Zealand '-------------' ), $countries ); // Get ready to load preselected values into the dropdowns if one exists $selected_country = NULL; $timezone_prepopulated = array('' => lang('no_timezones')); if ( ! empty($default)) { $timezone_ids = DateTimeZone::listIdentifiers(); // If default selection isn't valid, it may be our legacy timezone format if ( ! in_array($default, $timezone_ids)) { $default = $this->get_php_timezone($default); } $selected_country = $this->_get_country_for_php_timezone($default); // Preselect timezone if we got a valid country back if ($selected_country) { $timezone_prepopulated = $timezones[$selected_country]; } } // Construct the form ee()->load->helper('form'); $output .= form_dropdown('tz_country', $countries, $selected_country, 'onchange="ee_tz_change(this)"'); $output .= '  '; // NBS constant doesn't work in installer $output .= form_dropdown($name, $timezone_prepopulated, $default, 'id="timezone_select"'); return $output; } /** * Loads countries config file and creates localized array of country * codes corresponding to country names * * @access private * @param boolean Whether or not to return timezones mapped to * countries instead * @return string */ private function _get_countries($return_timezones = FALSE) { if ( ! empty($this->_countries) AND ! $return_timezones) { return $this->_countries; } $conf = ee()->config->loadFile('countries'); $countries = $conf['countries']; $timezones = $conf['timezones']; if ($return_timezones) { return $timezones; } foreach ($countries as $code => $country) { $countries[$code] = lang($country); } $this->_countries = $countries; return $this->_countries; } /** * Creates and returns a cached array of timezones by country. * * @access private * @return array Array of timezones by country code */ private function _get_timezones_by_country() { if ( ! empty($this->_timezones_by_country)) { return $this->_timezones_by_country; } // PHP 5.3+ if (defined('DateTimeZone::PER_COUNTRY')) { foreach ($this->_get_countries() as $code => $country) { $this->_timezones_by_country[$code] = DateTimeZone::listIdentifiers( DateTimeZone::PER_COUNTRY, strtoupper($code) ); } } // < PHP 5.3 else { $this->_timezones_by_country = $this->_get_countries(TRUE); } return $this->_timezones_by_country; } /** * Returns the country code for a given PHP timezone * * @access private * @param string PHP timezone * @return string Two-letter country code for timezone */ private function _get_country_for_php_timezone($timezone) { foreach ($this->_get_timezones_by_country() as $code => $timezones) { if (in_array($timezone, $timezones)) { return $code; } } return FALSE; } /** * Gets the PHP timezone for the legacy timezone format EE used to * store timezones with which was based on offsets; for example, given * "UM5", it returns "America/New_York" * * @access public * @param string * @return string */ public function get_php_timezone($zone = 'UTC') { $zones = array( 'UM12' => 'Kwajalein', // -12 'UM11' => 'Pacific/Midway', // -11 'UM10' => 'Pacific/Honolulu', // -10 'UM95' => 'Pacific/Marquesas', // -9.5 'UM9' => 'America/Anchorage', // -9 'UM8' => 'America/Los_Angeles', // -8 'UM7' => 'America/Denver', // -7 'UM6' => 'America/Chicago', // -6 'UM5' => 'America/New_York', // -5 'UM45' => 'America/Caracas', // -4.5 'UM4' => 'America/Halifax', // -4 'UM35' => 'America/St_Johns', // -3.5 'UM3' => 'America/Argentina/Buenos_Aires',// -3 'UM2' => 'Atlantic/South_Georgia', // -2 'UM1' => 'Atlantic/Azores', // -1 'UTC' => 'Europe/Dublin', // 0 'UP1' => 'Europe/Belgrade', // +1 'UP2' => 'Europe/Minsk', // +2 'UP3' => 'Asia/Kuwait', // +3 'UP35' => 'Asia/Tehran', // +3.5 'UP4' => 'Asia/Muscat', // +4 'UP45' => 'Asia/Kabul', // +4.5 'UP5' => 'Asia/Yekaterinburg', // +5 'UP55' => 'Asia/Kolkata', // +5.5 'UP575' => 'Asia/Katmandu', // +5.75 'UP6' => 'Asia/Dhaka', // +6 'UP65' => 'Asia/Rangoon', // +6.5 'UP7' => 'Asia/Krasnoyarsk', // +7 'UP8' => 'Asia/Brunei', // 8 'UP875' => 'Australia/Eucla', // +8.75 'UP9' => 'Asia/Seoul', // +9 'UP95' => 'Australia/Darwin', // +9.5 'UP10' => 'Australia/Canberra', // +10 'UP105' => 'Australia/Lord_Howe', // +10.5 'UP11' => 'Asia/Magadan', // +11 'UP115' => 'Pacific/Norfolk', // +11.5 'UP12' => 'Pacific/Fiji', // +12 'UP1275' => 'Pacific/Chatham', // +12.75 'UP13' => 'Pacific/Tongatapu', // +13 'UP14' => 'Pacific/Kiritimati' // +14 ); // Fall back to UTC if something went wrong if ( ! isset($zones[$zone])) { return 'UTC'; } return $zones[$zone]; } /** * Localize month name * * Helper function used to translate month names. * * @access public * @param string * @return string */ function localize_month($month = '') { $months = array( '01' => array('Jan', 'January'), '02' => array('Feb', 'February'), '03' => array('Mar', 'March'), '04' => array('Apr', 'April'), '05' => array('May', 'May_l'), '06' => array('Jun', 'June'), '07' => array('Jul', 'July'), '08' => array('Aug', 'August'), '09' => array('Sep', 'September'), '10' => array('Oct', 'October'), '11' => array('Nov', 'November'), '12' => array('Dec', 'December') ); if (isset($months[$month])) { return $months[$month]; } } /** * Reads the configured date format from either userdata or the site's * config and returns the string needed to format the JS datepicker * to match. * * @access public * @return string The string needed for the 'dateFormat:' argument for * the jQuery datepicker plugin. */ public function datepicker_format() { $date_format = ee()->session->userdata('date_format', ee()->config->item('date_format')); // Days $date_format = str_replace('%d', 'dd', $date_format); $date_format = str_replace('%j', 'd', $date_format); // Months $date_format = str_replace('%m', 'mm', $date_format); $date_format = str_replace('%n', 'm', $date_format); // Years $date_format = str_replace('%Y', 'yy', $date_format); $date_format = str_replace('%y', 'y', $date_format); return $date_format; } /** * Converts our build date constant into a timestamp so we can format it * for display * * @param string Build date in the format of yyyymmdd, uses APP_BUILD by default * @return int Timestamp representing the build date */ public function parse_build_date($build = NULL) { if (empty($build)) { $build = APP_BUILD; } $year = substr($build, 0, 4); $month = substr($build, 4, 2); $day = substr($build, 6, 2); $string = $year . '-' . $month . '-' . $day; return ee()->localize->string_to_timestamp($string, TRUE, '%Y-%m-%d'); } } // END CLASS // EOF Error - ExpressionEngine

Error: Non-existent class: Localize