function &_getContentSource($listType) { $source_override_value = 'AMP_CONTENT_SOURCE_' . strtoupper($this->getDisplayType($listType)); if (defined($source_override_value)) { $contentSource_class = constant($source_override_value); } else { //standard parsing method to figure out source class $this->_contentSourceType = AMP_to_camelcase(strtolower($this->getDisplayType($listType))); $contentSource_class = 'SectionContentSource_' . $this->_contentSourceType; if (!class_exists($contentSource_class)) { trigger_error(sprintf(AMP_TEXT_ERROR_NOT_DEFINED, 'AMP', $contentSource_class)); $contentSource_class = 'SectionContentSource_Articles'; } } $result = new $contentSource_class($this->_section); return $result; }
function validate_sort_link($sort_request) { $local_method = '_setSort' . AMP_to_camelcase($sort_request); $valid_method = method_exists($this, $local_method); if (!$valid_method && !isset($this->_source_sample)) { return false; } if (!$valid_method && method_exists($this->_source_sample, 'isColumn')) { $valid_method = $this->_translate_sort_sql_request($sort_request, $this->_source_sample); } if (!$valid_method) { $source_method = 'get' . AMP_to_camelcase($sort_request); $valid_method = method_exists($this->_source_sample, $source_method); } return $valid_method; }
function render_value($source, $column_name) { $local_method = 'render_' . $column_name; if (method_exists($this, $local_method)) { return $this->{$local_method}($source); } $source_method = 'get' . AMP_to_camelcase($column_name); if (method_exists($source, $source_method)) { return $source->{$source_method}(); } return $source->getData($column_name); }
function filter($criteria, $data) { $result_data = $data; foreach ($criteria as $key => $test) { $crit_method = 'filterBy' . AMP_to_camelcase($key); if (!method_exists($this, $crit_method)) { continue; } $this->_filter_crit = $test; $result_data = array_filter($result_data, array($this, $crit_method)); } return $result_data; }
function AMP_lookup($lookup_type, $lookup_var = null) { $lookup_types = array('AMPSystem_Lookup' => 'AMPSystemLookup_', 'AMPContent_Lookup' => 'AMPContentLookup_', 'FormLookup' => 'FormLookup_'); //the whole class name is passed if (class_exists($lookup_type)) { foreach ($lookup_types as $base_type => $prefix) { if (strpos($lookup_type, $prefix) === 0) { $instance = str_replace($prefix, '', $lookup_type); return call_user_func_array(array($base_type, 'instance'), array($instance, $lookup_var)); } } return new $lookup_type($lookup_var); } //just the instance is passed $instance = AMP_to_camelcase($lookup_type); $value = false; foreach ($lookup_types as $base_type => $prefix) { if (!class_exists($prefix . ucfirst($instance))) { continue; } $values = call_user_func_array(array($base_type, 'instance'), array($instance, $lookup_var)); if ($values) { return $values; } } if (!isset($values)) { trigger_error(sprintf(AMP_TEXT_ERROR_LOOKUP_NOT_FOUND, $lookup_type . ' / ' . $instance . (isset($lookup_var) ? ' / ' . $lookup_var : ''))); return false; } return $values; }
/** * makeCriteria * * @param mixed $data * @access public * @return void */ function makeCriteria($data) { $return = array(); if (!(isset($data) && is_array($data))) { return false; } foreach ($data as $key => $value) { $crit_method1 = 'makeCriteria' . ucfirst($key); $crit_method2 = 'makeCriteria' . AMP_to_camelcase($key); $crit_method = method_exists($this, $crit_method1) ? $crit_method1 : $crit_method2; if (method_exists($this, $crit_method)) { $return[$key] = $this->{$crit_method}($value); continue; } if ($crit_method = $this->_getCriteriaMethod($key, $value)) { $return[$key] = $this->{$crit_method}($key, $value); } } return array_filter($return); }
function suppress($item) { $local_call = 'suppress' . AMP_to_camelcase($item); if (method_exists($this, $local_call)) { return $this->{$local_call}(); } }