/** * Constructor */ function FiletypeCache() { // Call parent constructor: parent::DataObjectCache('Filetype', true, 'T_filetypes', 'ftyp_', 'ftyp_ID', 'ftyp_extensions'); }
/** * Display list/table body. * * This includes groups and data rows. * * @access protected */ function display_body() { // BODY START: $this->display_body_start(); // Prepare data for grouping: $group_by_all = array(); if (!empty($this->group_by)) { $group_by_all['row'] = is_array($this->group_by) ? $this->group_by : array($this->group_by); } if (!empty($this->group_by_obj_prop)) { $group_by_all['obj_prop'] = is_array($this->group_by_obj_prop) ? $this->group_by_obj_prop : array($this->group_by_obj_prop); } $this->current_group_count = array(); // useful in parse_col_content() foreach ($this->rows as $row) { // For each row/line: /* * GROUP ROW stuff: */ if (!empty($group_by_all)) { // We are grouping (by SQL and/or object property)... $group_depth = 0; $group_changed = false; foreach ($group_by_all as $type => $names) { foreach ($names as $name) { if ($type == 'row') { $value = $row->{$name}; } elseif ($type == 'obj_prop') { $this->current_Obj = $this->Cache->instantiate($row); // useful also for parse_col_content() below $value = $this->current_Obj->{$name}; } else { debug_die('Invalid Results-group_by-type: ' . var_export($type, true)); } if ($this->current_group_ID[$group_depth] != $value) { // Group changed here: $this->current_group_ID[$group_depth] = $value; if (!isset($this->current_group_count[$group_depth])) { $this->current_group_count[$group_depth] = 0; } else { $this->current_group_count[$group_depth]++; } // unset sub-group identifiers: for ($i = $group_depth + 1, $n = count($this->current_group_ID); $i < $n; $i++) { unset($this->current_group_ID[$i]); } $group_changed = true; break 2; } $group_depth++; } } if ($group_changed) { // We have just entered a new group! echo $this->params['grp_line_start']; // TODO: dh> support grp_line_start_odd, grp_line_start_last, grp_line_start_odd_last - as defined in _adminUI_general.class.php $col_count = 0; foreach ($this->grp_cols as $grp_col) { // For each column: if (isset($grp_col['td_class'])) { // We have a class for the total column $class = $grp_col['td_class']; } else { // We have no class for the total column $class = ''; } if ($col_count == 0 && isset($this->params['grp_col_start_first'])) { // Display first column column start: $output = $this->params['grp_col_start_first']; // Add the total column class in the grp col start first param class: $output = str_replace('$class$', $class, $output); } elseif ($col_count == count($this->grp_cols) - 1 && isset($this->params['grp_col_start_last'])) { // Last column can get special formatting: $output = $this->params['grp_col_start_last']; // Add the total column class in the grp col start end param class: $output = str_replace('$class$', $class, $output); } else { // Display regular column start: $output = $this->params['grp_col_start']; // Replace the "class_attrib" in the grp col start param by the td column class $output = str_replace('$class_attrib$', 'class="' . $class . '"', $output); } if (isset($grp_col['td_colspan'])) { $colspan = $grp_col['td_colspan']; if ($colspan < 0) { // We want to substract columns from the total count $colspan = $this->nb_cols + $colspan; } elseif ($colspan == 0) { // use $nb_cols $colspan = $this->nb_cols; } $output = str_replace('$colspan_attrib$', 'colspan="' . $colspan . '"', $output); } else { // remove non-HTML attrib: $output = str_replace('$colspan_attrib$', '', $output); } // Contents to output: $output .= $this->parse_col_content($grp_col['td']); //echo $output; eval("echo '{$output}';"); echo '</td>'; $col_count++; } echo $this->params['grp_line_end']; } } /* * DATA ROW stuff: */ if (!empty($this->ID_col) && empty($row->{$this->ID_col})) { // We have detected an empty data row which we want to ignore... (happens with empty groups) continue; } if (!is_null($this->Cache)) { // We want to instantiate an object for the row and cache it: // We also keep a local ref in case we want to use it for display: $this->current_Obj =& $this->Cache->instantiate($row); } // Check for fadeout $fadeout_line = false; if (!empty($this->fadeout_array)) { foreach ($this->fadeout_array as $key => $crit) { // echo 'fadeout '.$key.'='.$crit; if (isset($row->{$key}) && in_array($row->{$key}, $crit)) { // Col is in the fadeout list // TODO: CLEAN THIS UP! $fadeout_line = true; break; } } } // LINE START: $this->display_line_start($this->current_idx == count($this->rows) - 1, $fadeout_line); foreach ($this->cols as $col) { // For each column: // COL START: $this->display_col_start(); // Contents to output: $output = $this->parse_col_content($col['td']); #pre_dump( '{'.$output.'}' ); eval("echo '{$output}';"); // COL START: $this->display_col_end(); } // LINE END: $this->display_line_end(); $this->next_idx(); } // BODY END: $this->display_body_end(); }
/** * Constructor * * @param boolean Load enabled widgets only? */ function WidgetCache($enabled_only = false) { parent::DataObjectCache('ComponentWidget', false, 'T_widget', 'wi_', 'wi_ID', NULL, NULL, NULL); $this->load_enabled_only = $enabled_only; }
/** * Constructor */ function LinkCache() { parent::DataObjectCache('Link', false, 'T_links', 'link_', 'link_ID'); }
/** * Handle our login cache. */ function remove_by_ID($req_ID) { if (isset($this->cache[$req_ID])) { $Obj =& $this->cache[$req_ID]; unset($this->cache_login[evo_strtolower($Obj->login)]); } parent::remove_by_ID($req_ID); }
/** * Constructor */ function GenericCache($objtype, $load_all, $tablename, $prefix = '', $dbIDname = 'ID', $name_field = NULL, $order_by = '', $allow_none_text = NULL) { parent::DataObjectCache($objtype, $load_all, $tablename, $prefix, $dbIDname, $name_field, $order_by, $allow_none_text); }
/** * Add a dataobject to the cache */ function add(&$Obj) { if (parent::add($Obj)) { // Successfully added if (!empty($this->subset_property)) { // Also add to subset cache: $this->subset_cache[$Obj->{$this->subset_property}][$Obj->ID] =& $Obj; } return true; } return false; }
/** * Add object to cache, handling our own indices. * * @param Skin * @return boolean True on add, false if already existing. */ function add(&$Skin) { $this->cache_by_folder[$Skin->folder] =& $Skin; return parent::add($Skin); }
/** * Constructor */ function WidgetCache() { parent::DataObjectCache('ComponentWidget', false, 'T_widget', 'wi_', 'wi_ID', NULL, NULL, NULL); }
/** * Handle our login cache. */ function remove_by_ID($reg_ID) { if (isset($this->cache[$req_ID])) { unset($this->cache_login[$this->cache[$req_ID]]); } parent::remove_by_ID($req_ID); }
/** * Clear the cache **extensively** * * @param boolean Keep copy of cache in case we try to re instantiate previous object * @param string What to clear: 'all', 'user', 'item', 'comment', 'file' * @param integer ID of the clearing object */ function clear($keep_shadow = false, $object = 'all', $object_ID = 0) { parent::clear($keep_shadow); switch ($object) { case 'all': // Clear all cached objects $this->cache_item = array(); $this->loaded_cache_item = array(); $this->cache_comment = array(); $this->loaded_cache_comment = array(); $this->cache_user = array(); $this->loaded_cache_user = array(); $this->cache_file = array(); $this->loaded_cache_file = array(); break; case 'item': case 'comment': case 'user': case 'file': // Clear only the selected type of objects if (empty($object_ID)) { // Clear all cached objects of this type $this->{'cache_' . $object} = array(); $this->{'loaded_cache_' . $object} = array(); } else { // Clear a cache only one object unset($this->{'cache_' . $object}[$object_ID]); unset($this->{'loaded_cache_' . $object}[$object_ID]); } break; } }
/** * For use by Universal Item List widget */ function get_option_array() { global $posttypes_reserved_IDs; return parent::get_option_array('get_name', $posttypes_reserved_IDs); }
/** * Returns form option list with cache contents * * Loads the whole cache! * * @param integer selected ID * @param boolean provide a choice for "none" with ID 0 */ function get_option_list($default = 0, $allow_none = false, $method = 'get_name') { // We force a full load! $this->load_all(); return parent::get_option_list($default, $allow_none, $method); }
/** * Constructor */ function FileCache() { parent::DataObjectCache('File', false, 'T_files', 'file_', 'file_ID'); }
/** * Constructor * * @param table Database row */ function ItemTypeCache() { // Call parent constructor: parent::DataObjectCache('ItemType', true, 'T_items__type', 'ptyp_', 'ptyp_ID', 'ptyp_name', 'ptyp_ID'); }
/** * Returns form option list with cache contents * * @param integer selected ID * @param boolean provide a choice for "none" with ID 0 * @param string Callback method name * @return string HTML tags <option> */ function get_option_list_parent($default = 0, $allow_none = false, $method = 'get_name') { return parent::get_option_list($default, $allow_none, $method); }
/** * Callback to add filters on top of the result set * * @param Form */ function callback_filter_userlist(&$Form) { global $Settings, $current_User; $Form->hidden('filter', 'new'); $Form->text('keywords', get_param('keywords'), 20, T_('Name'), '', 50); echo '<span class="nowrap">'; $Form->checkbox('gender_men', get_param('gender_men'), T_('Men')); $Form->checkbox('gender_women', get_param('gender_women'), T_('Women')); echo '</span>'; if (!is_admin_page()) { echo '<br />'; } if (is_admin_page()) { // show this filters only on admin interface if ($current_User->check_perm('users', 'edit')) { // Show "Reported users" filter only for users with edit user permission $Form->checkbox('reported', get_param('reported'), T_('Reported users')); $Form->checkbox('custom_sender_email', get_param('custom_sender_email'), T_('Users with custom sender address')); $Form->checkbox('custom_sender_name', get_param('custom_sender_name'), T_('Users with custom sender name')); } $Form->select_input_array('account_status', get_param('account_status'), get_user_statuses(T_('All')), T_('Account status')); $GroupCache = new DataObjectCache('Group', true, 'T_groups', 'grp_', 'grp_ID', 'grp_name'); $group_options_array = array('-1' => T_('All (Ungrouped)'), '0' => T_('All (Grouped)')) + $GroupCache->get_option_array(); $Form->select_input_array('group', get_param('group'), $group_options_array, T_('User group'), '', array('force_keys_as_values' => true)); echo '<br />'; } if (user_country_visible()) { // Filter by country load_class('regional/model/_country.class.php', 'Country'); load_funcs('regional/model/_regional.funcs.php'); $CountryCache =& get_CountryCache(T_('All')); $Form->select_country('country', get_param('country'), $CountryCache, T_('Country'), array('allow_none' => true)); } if (user_region_visible()) { // Filter by region echo '<span id="region_filter"' . (!regions_exist(get_param('country'), true) ? ' style="display:none"' : '') . '>'; $Form->select_input_options('region', get_regions_option_list(get_param('country'), get_param('region')), T_('Region')); echo '</span>'; } if (user_subregion_visible()) { // Filter by subregion echo '<span id="subregion_filter"' . (!subregions_exist(get_param('region'), true) ? ' style="display:none"' : '') . '>'; $Form->select_input_options('subregion', get_subregions_option_list(get_param('region'), get_param('subregion')), T_('Sub-region')); echo '</span>'; } if (user_city_visible()) { // Filter by city echo '<span id="city_filter"' . (!cities_exist(get_param('country'), get_param('region'), get_param('subregion'), true) ? ' style="display:none"' : '') . '>'; $Form->select_input_options('city', get_cities_option_list(get_param('country'), get_param('region'), get_param('subregion'), get_param('city')), T_('City')); echo '</span>'; } echo '<br />'; $Form->interval('age_min', get_param('age_min'), 'age_max', get_param('age_max'), 3, T_('Age group')); echo '<br />'; $criteria_types = param('criteria_type', 'array/integer'); $criteria_values = param('criteria_value', 'array/string'); if (count($criteria_types) == 0) { // Init one criteria fieldset for first time $criteria_types[] = ''; $criteria_values[] = ''; } foreach ($criteria_types as $c => $type) { $value = trim(strip_tags($criteria_values[$c])); if ($value == '' && count($criteria_types) > 1 && $c > 0) { // Don't display empty field again after filter request continue; } if ($c > 0) { // Separator between criterias echo '<br />'; } $Form->output = false; $criteria_input = $Form->text('criteria_value[]', $value, 17, '', '', 50); $criteria_input .= get_icon('add', 'imgtag', array('rel' => 'add_criteria')); $Form->output = true; global $user_fields_empty_name; $user_fields_empty_name = T_('Select...'); $Form->select('criteria_type[]', $type, 'callback_options_user_new_fields', T_('Specific criteria'), $criteria_input); } if (user_region_visible()) { // JS functions for AJAX loading of regions, subregions & cities ?> <script type="text/javascript"> jQuery( '#country' ).change( function() { var this_obj = jQuery( this ); jQuery.ajax( { type: 'POST', url: '<?php echo get_samedomain_htsrv_url(); ?> anon_async.php', data: 'action=get_regions_option_list&ctry_id=' + jQuery( this ).val(), success: function( result ) { jQuery( '#region' ).html( ajax_debug_clear( result ) ); if( jQuery( '#region option' ).length > 1 ) { jQuery( '#region_filter' ).show(); } else { jQuery( '#region_filter' ).hide(); } load_subregions( 0 ); // Reset sub-regions } } ); } ); jQuery( '#region' ).change( function () { // Change option list with sub-regions load_subregions( jQuery( this ).val() ); } ); jQuery( '#subregion' ).change( function () { // Change option list with cities load_cities( jQuery( '#country' ).val(), jQuery( '#region' ).val(), jQuery( this ).val() ); } ); function load_subregions( region_ID ) { // Load option list with sub-regions for seleted region jQuery.ajax( { type: 'POST', url: '<?php echo get_samedomain_htsrv_url(); ?> anon_async.php', data: 'action=get_subregions_option_list&rgn_id=' + region_ID, success: function( result ) { jQuery( '#subregion' ).html( ajax_debug_clear( result ) ); if( jQuery( '#subregion option' ).length > 1 ) { jQuery( '#subregion_filter' ).show(); } else { jQuery( '#subregion_filter' ).hide(); } load_cities( jQuery( '#country' ).val(), region_ID, 0 ); } } ); } function load_cities( country_ID, region_ID, subregion_ID ) { // Load option list with cities for seleted region or sub-region jQuery.ajax( { type: 'POST', url: '<?php echo get_samedomain_htsrv_url(); ?> anon_async.php', data: 'action=get_cities_option_list&ctry_id=' + country_ID + '&rgn_id=' + region_ID + '&subrg_id=' + subregion_ID, success: function( result ) { jQuery( '#city' ).html( ajax_debug_clear( result ) ); if( jQuery( '#city option' ).length > 1 ) { jQuery( '#city_filter' ).show(); } else { jQuery( '#city_filter' ).hide(); } } } ); } </script> <?php } }
/** * Constructor * * @param string object type of elements in Cache * @param string Name of the DB table * @param string Prefix of fields in the table * @param string Name of the ID field (including prefix) */ function ItemCache($objType = 'Item', $dbtablename = 'T_items__item', $dbprefix = 'post_', $dbIDname = 'post_ID') { parent::DataObjectCache($objType, false, $dbtablename, $dbprefix, $dbIDname); }
/** * Constructor * * @param string object type of elements in Cache * @param string Name of the DB table * @param string Prefix of fields in the table * @param string Name of the ID field (including prefix) */ function IPRangeCache($objType = 'IPRange', $dbtablename = 'T_antispam__iprange', $dbprefix = 'aipr_', $dbIDname = 'aipr_ID') { parent::DataObjectCache($objType, false, $dbtablename, $dbprefix, $dbIDname); }
/** * Constructor * * @param string object type of elements in Cache * @param string Name of the DB table * @param string Prefix of fields in the table * @param string Name of the ID field (including prefix) */ function CommentCache($objType = 'Comment', $dbtablename = 'T_comments', $dbprefix = 'comment_', $dbIDname = 'comment_ID') { parent::DataObjectCache($objType, false, $dbtablename, $dbprefix, $dbIDname); }
function __construct() { parent::__construct('TestDataObject', false, 'T_foobar', '', 'ID'); }