function adjustFields($fields) { if (!($id = $this->getIdValue())) { $id = null; } $fields['position_list']['default'] = $this->_getPositionList($id); if (isset($id)) { $fields['layout_anchor_description']['default'] = $this->_describeLayoutAnchor($id); return $fields; } $requested_selectors = array_combine_key($this->_selector_fields, $_GET); if (!empty($requested_selectors)) { foreach ($requested_selectors as $selector => $value) { $fields[$selector]['type'] = 'select'; } return $fields; } foreach ($fields as $key => $field_def) { if (array_search($key, $this->_selector_fields) === FALSE) { continue; } $fields[$key]['type'] = 'select'; } return $fields; }
function export(&$target_set, $args = null) { $sample = current($target_set); $keys = $sample->export_keys(); $dump = array(); foreach ($keys as $key) { $blank_set[$key] = null; } foreach ($target_set as $source) { $values = $source->getData(); $user_values = array(); if (isset($values['uid']) && $values['uid']) { $owner = new AMP_System_User_Profile(AMP_Registry::getDbcon(), $values['uid']); if ($owner->hasData()) { $owner_data = $owner->getData(); unset($owner_data['id']); $user_values = array_combine_key($keys, $owner_data); } } $safe_values = array_combine_key($keys, $values); $dump[$source->id] = array_merge($blank_set, $safe_values, $user_values); } require_once 'AMP/Renderer/CSV.php'; $renderer = new AMP_Renderer_CSV(); $file = $renderer->format(array($keys)); $file .= $renderer->format($dump); $renderer->header(date("Y_m_d__") . get_class($this)); print $file; exit; }
function __construct(&$source, $criteria = array()) { $criteria = $source->makeCriteria($criteria); $this->_source_array = array_combine_key(array_keys(AMPContent_Lookup::instance('galleryMap')), $source->search($criteria)); $this->_init_renderer($source); $this->_tree = new AMP_System_Data_Tree($source); }
function adjustFields($fields) { if (!($id = $this->getIdValue())) { $id = null; } $nav_blocks = AMP_lookup('navBlocks'); foreach ($nav_blocks as $block_name => $token) { $fields['order_tracker_' . $block_name] = array('type' => 'textarea', 'attr' => array('id' => 'order_tracker_amp_content_nav_location_values_' . $block_name)); } //$fields['position_list']['default'] = $this->_getPositionList( $id ); if (isset($id)) { $fields['layout_anchor_description']['default'] = $this->_describeLayoutAnchor($id); return $fields; } $requested_selectors = array_combine_key($this->_selector_fields, $_GET); if (!empty($requested_selectors)) { foreach ($requested_selectors as $selector => $value) { $fields[$selector]['type'] = 'select'; } return $fields; } foreach ($fields as $key => $field_def) { if (array_search($key, $this->_selector_fields) === FALSE) { continue; } $fields[$key]['type'] = 'select'; } return $fields; }
function getRequestedValues($action, &$value_set) { if (is_string($this->actions[$action])) { return $value_set[$this->actions[$action]]; } return array_combine_key($this->actions[$action], $value_set); }
function _setSortTree(&$source, $sort_direction = false) { $lookup = new AMPContentLookup_LinkTypeMap(); $lookup_data = $lookup->dataset; $order = array_keys($lookup_data); $source = array_combine_key($order, $source); }
function readPayment($payment_ID) { $this->payment->readData($payment_ID); $this->payment_method = $this->payment->paymentType->getData(); $this->item_record = array_combine_key($this->item_format, $this->payment->getData()); $this->readItem($this->item_record['payment_item_ID']); $this->readUser($this->payment->getData('user_ID')); }
function _adjustSetData($data) { $allowed_data = array_combine_key($this->adjust_fields, $data); if (empty($allowed_data)) { return false; } $this->itemdata = array_merge($this->itemdata, $allowed_data); }
function readData($id) { $sql = "Select * from payment_merchants where id = " . $this->dbcon->qstr($id); $merchant_record = $this->dbcon->GetRow($sql); if (!$merchant_record) { return false; } $this->merchant_info = array_combine_key($this->merchant_info_keys, $merchant_record); return $this->merchant_info; }
function render_galleries($source) { $galleries = AMP_lookup('galleries_by_image', $source->getName()); if (empty($galleries)) { return false; } $names = array_combine_key($galleries, AMP_lookup('galleries')); $links = array_map(array($this, 'render_gallery_link'), array_keys($galleries), $names); return join($this->_renderer->newline(), $links); }
function AMPSystemLookup_FormsWithEvents() { $owned_events = AMP_lookup('calendarEventOwner'); if (!$owned_events) { return; } $this->criteria = 'id in( ' . join(',', $owned_events) . ') GROUP BY modin '; $this->init(); $allowed_forms = array_keys($this->dataset); $this->dataset = array_combine_key($allowed_forms, AMP_lookup('forms')); }
function read_request_sizes($action) { if ($action == $this->_default_action) { return; } $tainted_values = array_combine_key($this->_action_values[$action], $_REQUEST); $clear_values = array(); foreach ($this->_action_values[$action] as $key) { $clear_values[$key] = isset($tainted_values[$key]) && intval($tainted_values[$key]) ? abs(intval($tainted_values[$key])) : 0; } if ($action == 'resize') { if ($this->_keep_proportions) { if ($clear_values['height'] && $clear_values['width']) { $requested_proportion = $clear_values['height'] / $clear_values['width']; if ($this->_image_ref->height / $clear_values['height'] > $this->_image_ref->width / $clear_values['width']) { $clear_values['width'] = false; } else { $clear_values['height'] = false; } } } if (!$clear_values['width'] && $clear_values['height']) { $clear_values['width'] = $this->_image_ref->width * ($clear_values['height'] / $this->_image_ref->height); } if (!$clear_values['height'] && $clear_values['width']) { $clear_values['height'] = $this->_image_ref->height * ($clear_values['width'] / $this->_image_ref->width); } } if (isset($clear_values['height']) && !$clear_values['height']) { $clear_values['height'] = $this->_image_ref->height; } if (isset($clear_values['width']) && !$clear_values['width']) { $clear_values['width'] = $this->_image_ref->width; } if ($action == 'crop') { if (!$clear_values['end_x']) { $clear_values['end_x'] = $clear_values['start_x'] + $clear_values['width']; } if (!$clear_values['end_y']) { $clear_values['end_y'] = $clear_values['start_y'] + $clear_values['height']; } if ($clear_values['end_x'] > $this->_image_ref->width || $clear_values['end_x'] < $clear_values['start_x']) { $clear_values['end_x'] = $this->_image_ref->width; } if ($clear_values['end_y'] > $this->_image_ref->height || $clear_values['end_y'] < $clear_values['start_y']) { $clear_values['end_y'] = $this->_image_ref->height; } if ($clear_values['start_x'] >= $this->_image_ref->width || $clear_values['start_y'] >= $this->_image_ref->height) { $this->_display->set_action($this->_default_action); } } $this->_image_sizes = $clear_values; $this->_display->set_sizes($clear_values); }
function scriptStyle($template) { if ($styleset = array_combine_key($this->css_template_vars, $this->getStyle())) { if (isset($styleset['id'])) { $styleset['id'] = $this->id; } $openheart = vsprintf($template, $styleset); return $openheart; } return false; }
function load_sections($live_only = 0) { $allowed_sections = AMP_lookup('sectionMap'); $lookup_name = $live_only ? 'sectionsLive' : 'sections'; $section_names = array_combine_key(array_keys($allowed_sections), AMP_lookup($lookup_name)); $article_locations = $this->_article->getAllSections(); $section_list = array_combine_key($article_locations, $section_names); asort($section_list); if (defined('AMP_CUSTOM_ITEM_BLOG_SECTION')) { unset($section_list[AMP_CUSTOM_ITEM_BLOG_SECTION]); } return $section_list; }
function _addSeparator($template, $separator) { if ($separator == 'endform') { return $template . $this->pattern_parts['endform']; } $separator_pattern = $this->pattern_parts[$separator]; $separator_template = $separator_pattern; if (!(strpos($separator_pattern, 'class=') === FALSE)) { $css_keys = array_combine_key($this->element_css_keys['separator'], $this->element_css_classes); $separator_template = vsprintf($separator_pattern, $css_keys); } return $separator_template . $template; }
function _register_fields_dynamic() { $header =& AMP_get_header(); $header->addJavascript('scripts/ajax/prototype.js', 'prototype'); $header->addJavascript('scripts/related.js', 'related_form'); $options = $this->getOptions(); if (!(isset($options['related_form_id']) && $options['related_form_id'])) { trigger_error(sprintf(AMP_TEXT_ERROR_NOT_DEFINED, get_class($this), 'related_form_id')); return; } //$related_udm = new UserData( $this->dbcon, $options['related_form_id'], $this->udm->admin ); $related_udm = new UserData($this->dbcon, $options['related_form_id']); $this->add_div['default'] = sprintf($this->add_div['default'], $options['related_form_id']); $this->fields['add_div'] = $this->add_div; $this->_included_fieldnames = isset($options['included_fields']) && $options['included_fields'] ? preg_split("/\\s{0,2},\\s{0,2}/", $options['included_fields']) : array_keys($related_udm->fields); $included_fields = array_combine_key($this->_included_fieldnames, $related_udm->fields); $this->fields = array_merge($this->fields, $included_fields); $dom_field_names = $this->convertFieldNamestoUDM($included_fields, $keys = true); # there must be a better way than this, but this field was causing problems # in the javascript, and since we ignore it's value on submit anyway... if (false !== ($owner_key = array_search($this->_field_prefix . '_' . $options['related_form_owner_field'], $dom_field_names))) { unset($dom_field_names[$owner_key]); } $add_button_targets = join("', '", $dom_field_names); $this->add_button['attr']['onClick'] = sprintf($this->_related_add_script_template, '\'' . $add_button_targets . '\'', $options['badge_description'], $options['related_form_id'], $this->_field_prefix); $this->fields['add_button'] = $this->add_button; #XXX: this appears to be trying to preserve values, why is it not working? $load_single_request_script = str_replace('this.form', 'document.forms["' . $this->udm->name . '"]', $this->_related_add_script_template); $request_keys = array(); foreach ($dom_field_names as $dom_field) { if (isset($_POST[$dom_field]) && is_array($_POST[$dom_field])) { foreach ($_POST[$dom_field] as $key => $value) { //$this->fields[str_replace( $this->_field_prefix .'_', '', $dom_field ).'['.$key.']'] = $this->_hidden_def; $field_key = str_replace($this->_field_prefix . '_', '', $dom_field) . '[' . $key . ']'; $this->fields[$field_key] = $this->_hidden_def; $request_keys[$key][] = $dom_field . '[' . $key . ']'; } } } $load_request_script = ''; foreach ($request_keys as $key => $request_item) { $load_request_targets = join("', '", $request_item); $load_request_script .= sprintf($load_single_request_script, '\'' . $load_request_targets . '\'', $options['badge_description'], $options['related_form_id'], $this->_field_prefix) . "\n"; } if ($load_request_script) { $header->addJavascriptOnLoad($load_request_script); } if (isset($this->udm->form)) { $this->udm->form->setAttribute('onSubmit', 'related_add( this, Array( \'' . $add_button_targets . '\'));'); } }
function _sort_source(&$source_items, $qty_set) { $sorted_order = array(); foreach ($source_items as $item_key => $item) { if (!isset($qty_set[$item->id])) { continue; } $sorted_order[$item_key] = $qty_set[$item->id]; } $tag_names = AMPSystem_Lookup::instance('tags'); arsort($sorted_order); if (count($sorted_order) > $this->_display_qty) { $display_order = array(); foreach ($sorted_order as $item_id => $item_qty) { $display_order[] = $item_id; if (count($display_order) >= $this->_display_qty) { break; } } } else { $display_order = array_keys($sorted_order); } $this->_items = array_combine_key($display_order, $source_items); $this->_item_qtys = array_combine_key($display_order, $qty_set); $this->max = $max_qty = max($this->_item_qtys); $this->min = $min_qty = min($this->_item_qtys); $this->step = $step_size = ($max_qty - $min_qty) / $this->_size_steps; /* foreach( $this->_items as $item_id => $item ) { if ( !isset( $this->_item_qtys[$item->id])){ unset( $this->_items[ $item->id ]); continue; } $this->_assign_class( $item->id, $this->_item_qtys[ $item->id ], $max_qty, $min_qty ); } */ $item_classes = array_map(array($this, '_map_class'), $this->_items); reset($this->_items); foreach ($item_classes as $key => $class) { $item_id = key($this->_items); if (!$class) { unset($this->_items[$item_id]); continue; } $this->_item_classes[$item_id] = $this->_css_class_base . $class; next($this->_items); } $item->sort($this->_items); }
function _setSortTagname(&$source) { $names_lookup =& AMPSystem_Lookup::instance('tags'); $order = array_keys($names_lookup); $translate_set = array(); foreach ($item_set as $item_id => $item) { $tag_id = $item->getTag(); if (!$tag_id) { continue; } $translate_set[$tag_id] = $item_id; } $ordered_set = array_combine_key($order, $translate_set); $item_set = array_combine_key($ordered_set, $item_set); }
function onInitForm(&$controller) { $form =& $controller->get_form(); if ($section_def = $form->getField('section') && !empty($this->public_permitted_sections)) { $section_values =& AMPContent_Lookup::instance('sectionMap'); $allowed_sections = array_combine_key($this->public_permitted_sections, $section_values); $allowed_ordered_sections = array_combine_key($section_values, $allowed_sections); $form->setFieldValueSet('section', $allowed_ordered_sections); } if ($class_def = $form->getField('class') && !empty($this->public_permitted_classes)) { $class_values =& AMPContent_Lookup::instance('classes'); $allowed_classes = array_combine_key($this->public_permitted_classes, $class_values); $form->setFieldValueSet('class', $allowed_classes); } }
function galleryLinks($source, $column_name) { $galleries =& AMPContentLookup_GalleriesByImage::instance($source->getName()); if (empty($galleries)) { return false; } $gallerynames = array_combine_key($galleries, AMPContent_Lookup::instance('galleries')); $output = ""; foreach ($galleries as $galleryImage_id => $gallery_id) { if (!isset($gallerynames[$gallery_id])) { continue; } $output .= $this->_HTML_link(AMP_Url_AddVars(AMP_SYSTEM_URL_GALLERY_IMAGE, 'id=' . $galleryImage_id), AMP_trimText($gallerynames[$gallery_id], 30)) . $this->_HTML_newline(); } return $output; }
function adjustFields($fields) { if (!isset($this->_modin)) { return $fields; } $udm =& new UserData(AMP_Registry::getDbcon(), $this->_modin); $end_field = array_pop($fields); $fields = array_merge($fields, $udm->fields); array_push($fields, $end_field); $target_array = $this->_action->getTargets(); if ($target_array) { $values = AMP_evalLookup($fields['target']['lookup']); $target_values = array_combine_key($target_array, $values); unset($fields['target']['lookup']); $fields['target']['values'] = $target_values; $fields['target']['default'] = join(",", $target_array); } return $fields; }
function _readRequest() { if (!($url_criteria = AMP_URL_Read())) { return false; } $crit_set = array_combine_key($this->_legacy_criteria, $url_criteria); if (empty($crit_set)) { return false; } foreach ($crit_set as $crit_name => $value) { if (!$value) { continue; } $sql_maker = '_makeLegacyCrit' . ucfirst($crit_name); if (!method_exists($this, $sql_maker)) { $sql_maker = '_makeSimpleCrit'; } $this->_sql_criteria[] = $this->{$sql_maker}($value, $crit_name); } }
function _outputComponents($options) { if ($this->udm->hasErrors()) { $options['component_order'] = $this->_getErrorOptions(); } $order = preg_split('/\\s?,\\s?/', $options['component_order']); $plugins_set = $this->udm->getPlugins(); $active_components = array_combine_key($order, $plugins_set); $output_html = ""; foreach ($order as $action) { $component_set =& $plugins_set[$action]; if (!is_array($component_set)) { continue; } foreach ($component_set as $namespace => $component) { $output_html .= $component->execute(); } } return $output_html; }
function _register_fields_dynamic() { $this->_register_event_setup(); $this->fields = $this->enable_all($this->_event_form->getFields()); $udm_fields = AMP_get_column_names('userdata'); $udm_overlap = $this->udm->admin ? array('id', 'publish', 'dia_key') : array('id', 'dia_key'); $udm_fields = array_diff($udm_fields, $udm_overlap); $allowed_fields = array_diff(array_keys($this->fields), $udm_fields); $this->fields = array_combine_key($allowed_fields, $this->fields); if (isset($this->fields['humanity_test'])) { $captcha_def = $this->fields['humanity_test']; } unset($this->fields['submit']); unset($this->fields['submitAction']); unset($this->fields['humanity_test']); $this->insertBeforeFieldOrder(array_keys($this->fields)); $this->insertAfterFieldOrder(array('humanity_test')); if (isset($captcha_def)) { $this->fields['humanity_test'] = $captcha_def; } }
function update() { $start_data = $this->getData(); foreach ($this->_data_segments as $type => $fields) { $segment = array_combine_key($fields, $start_data); $new_data = array(); $translations = $this->_target_fields[$type]; foreach ($segment as $key => $value) { if (!$value) { continue; } $new_data[$translations[$key]] = $value; } if (empty($new_data)) { continue; } $new_model_class = $this->_target_classes[$type]; if (!trim($new_model_class) || !class_exists($new_model_class)) { trigger_error('class ' . $new_model_class . ' for ' . $type . ' not found'); continue; } $new_model = new $new_model_class(AMP_Registry::getDbcon()); $new_model->setData($this->adjust($new_data, $new_model_class, $type)); $new_model->save(); $this->_result_ids[$type] = $new_model->id; } $base_target_class = $this->_target_classes['base']; $this->_base_target = new $base_target_class($this->dbcon, $this->id); foreach ($this->_result_ids as $key => $id_value) { $base_values[$key . '_id'] = $id_value; } $base_values['status'] = 1; $base_values['modin'] = AMP_FORM_ID_WEBACTION_DEFAULT; $base_values['target_method'] = 'all'; $this->_base_target->mergeData($base_values); return $this->_base_target->save(); }
function _populateUDM() { // $calendar_dummy = new Calendar( $this->_udm->dbcon ); #$dates = array('plugin_AMPCalendar_endtime', 'plugin_AMPCalendar_time', 'plugin_AMPCalendar_enddate', 'plugin_AMPCalendar_date'); $ignore = array('endtime', 'time', 'enddate', 'date', 'typeid'); $numbers = array('cost', 'lzip'); $field_defs = array_combine_key($this->_plugin->_calendar_plugin->getSaveFields(), $this->_plugin->_calendar_plugin->getFields()); foreach ($field_defs as $fieldName => $values) { if ($values['type'] == 'checkbox') { $dummy_data[$fieldName] = true; //dates } elseif (array_search($fieldName, $ignore) !== false) { //numbers } elseif (array_search($fieldName, $numbers) !== false) { $dummy_data[$fieldName] = 9; //default } else { $dummy_data[$fieldName] = $fieldName . "_DUMMY"; } } $dummy_data['date'] = '2006-01-20'; $dummy_data['time'] = '4 PM'; $dummy_data['endtime'] = '5 PM'; $dummy_data['enddate'] = '2006-01-21'; $dummy_data['lstate'] = 'CA'; $dummy_data['typeid'] = 39; #$this->_udm->setData( $dummy_data ); $this->_plugin->_calendar_plugin->setData($dummy_data); // AMP_varDump( $this->_plugin->_calendar_plugin->getData()); }
function _readSections() { $allowed_sections = AMP_lookup('sectionsByGroup', $this->id); if (!$allowed_sections) { return array(); } $section_list = AMP_lookup('sectionMap'); $result = array_combine_key(array_keys(AMP_lookup('sectionMap')), $allowed_sections); return $result; }
function AMPSystemLookup_PublicClasses() { $active_classes = AMP_lookup('active_classes'); $exclude = AMP_lookup('excluded_classes_for_display'); $allowed = array_diff(array_keys($active_classes), array_keys($exclude)); $this->dataset = array_combine_key($allowed, $active_classes); }
function _initComponents($component_type = null, $reset = false) { $init_classes = $this->component_class; if (!is_array($component_type) && !isset($init_classes[$component_type])) { return false; } $this->_requireComponents($component_type); if (isset($component_type)) { $comp = is_array($component_type) ? $component_type : array($component_type); $init_classes = array_combine_key($comp, $this->component_class); } foreach ($init_classes as $type => $component_def) { if (isset($this->{$type}) && !$reset) { continue; } $classname = $component_def; if (!class_exists($classname)) { continue; } $this->{$type} = new $classname($this->dbcon); $this->doCallbacks($type, AMP_PAGE_ACTION_COMPONENT_INIT); } return true; }
function _update_plugin_options($plugin_options) { foreach ($plugin_options as $namespace => $plugin_def) { foreach ($plugin_def as $action => $options) { $plugin =& $this->udm->getPlugin($namespace, $action); if (is_array($plugin)) { $this->error(sprintf(AMP_TEXT_ERROR_USERDATA_PLUGIN_UPDATE_FAILED_MULTIPLE_INSTANCES, $namespace, $action)); continue; } if (!$plugin) { $this->error(sprintf(AMP_TEXT_ERROR_USERDATA_PLUGIN_UPDATE_FAILED_NOT_REGISTERED, $namespace, $action)); continue; } $current_options = $plugin->getOptions(); $plugin_settings = array('plugin_id', 'plugin_active', 'plugin_priority'); foreach ($options as $option_name => $option_value) { if (isset($current_options[$option_name]) && $current_options[$option_name] == $option_value) { continue; } if (array_search($option_name, $plugin_settings) !== FALSE) { continue; } if ($current_options[$option_name] == null && $option_value == '') { continue; } $plugin->saveOption($option_name, $option_value); } if (!$this->_update_plugin_settings(array_combine_key($plugin_settings, $options))) { $this->error(sprintf(AMP_TEXT_ERROR_USERDATA_PLUGIN_UPDATE_FAILED, $namespace, $action)); } } } }