function testPublisherIsAcceptedFromQueryString() { $factory = new FieldFactory(); $query_array = array('example_publisher' => 768); $field = $factory->newField('scope'); $field->setName('example'); $field->setValueFromArray($query_array); $scope = $field->getValue(); $publisher_id = $scope->getPublisherId(); $this->assertEqual($publisher_id, 768); }
function MAX_getDatesByPeriod($period, $period_start = 0, $period_end = 0) { require_once MAX_PATH . '/lib/max/Admin/UI/FieldFactory.php'; $oDaySpan =& FieldFactory::newField('day-span'); $oDaySpan->_name = 'period'; $oDaySpan->setValueFromArray(array('period_preset' => $period, 'period_start' => $period_start, 'period_end' => $period_end)); $dayBegin = $oDaySpan->getStartDate(); $dayEnd = $oDaySpan->getEndDate(); $aDates = array(); $aDates['day_begin'] = is_object($dayBegin) ? $dayBegin->format('%Y-%m-%d') : ''; $aDates['day_end'] = is_object($dayEnd) ? $dayEnd->format('%Y-%m-%d') : ''; return $aDates; }
/** * A private method to display the report generation screen for a * report plugin to the UI. * * @access private * @param Plugins_Reports $oPlugin The plugin to display. * @param string $reportIdentifier The string identifying the report. * @param int $errorCode error code given by last report generation */ function _groupReportPluginGeneration($oPlugin, $reportIdentifier, $errorCode = null) { $aInfo = $oPlugin->info(); if (!empty($errorCode)) { $errorMessage = $oPlugin->getErrorMessage($errorCode); } // Print the report introduction $this->_displayReportIntroduction($aInfo['plugin-export'], $aInfo['plugin-name'], $aInfo['plugin-description'], $errorMessage); // Get the plugins generation parameter details if ($aPluginInfo = $aInfo['plugin-import']) { // Print the start of the report execution submission form $this->_displayParameterListHeader(); foreach ($aPluginInfo as $key => $aParameters) { // Print the report generation parameter $oField =& $this->oFieldFactory->newField($aParameters['type']); $oField->_name = $key; if (!is_null($aParameters['default'])) { $oField->setValue($aParameters['default']); } $oField->setValueFromArray($aParameters); if (!is_null($aParameters['field_selection_names'])) { $oField->_fieldSelectionNames = $aParameters['field_selection_names']; } if (!is_null($aParameters['size'])) { $oField->_size = $aParameters['size']; } if (!is_null($aParameters['filter'])) { $oField->setFilter($aParameters['filter']); } $this->_displayParameterBreak(); echo "<tr><td width='30'> </td><td>{$aParameters['title']}</td><td>"; $oField->_tabIndex = $this->tabindex; $oField->display(); $this->tabindex = $oField->_tabIndex; echo "</td></tr>"; } // Print a parameter break line $this->_displayParameterBreak(); // Print the end of the report execution submission form $this->_displayParameterListFooter($reportIdentifier); } // Print the closing table info $this->_displayReportInformationFooter(); }
/** * A private method to obtain the variables required for generating * the report from the $_GET array. * * @access private * @param array $aImport An array of the required variables for * the report. * @return array An array of the required variables. */ function _getVariablesForReport($aImport) { $aVariables = array(); foreach (array_keys($aImport) as $key) { $oField =& FieldFactory::newField($aImport[$key]['type']); $oField->_name = $key; $oField->setValueFromArray($_GET); $aVariables[] = $oField->_value; } return $aVariables; }
function testGenerateTextField() { $factory = new FieldFactory(); $field =& $factory->newField('edit'); $this->assertIsA($field, 'Admin_UI_TextField'); }
function MAX_displayDateSelectionForm($period, $period_start, $period_end, $pageName, &$tabindex, $hiddenValues = null) { global $tabindex; require_once MAX_PATH . '/lib/max/Admin/UI/FieldFactory.php'; $oDaySpan =& FieldFactory::newField('day-span'); $oDaySpan->_name = 'period'; $oDaySpan->_autoSubmit = true; $oDaySpan->setValueFromArray(array('period_preset' => $period, 'period_start' => $period_start, 'period_end' => $period_end)); $oDaySpan->_tabIndex = $tabindex; echo "\n <form id='period_form' name='period_form' action='{$pageName}'>"; $oDaySpan->display(); $tabindex = $oDaySpan->_tabIndex; echo "\n <input type='button' value='Go' onclick='return periodFormSubmit()' style='margin-left: 1em' tabindex='" . $tabindex++ . "' />"; _displayHiddenValues($hiddenValues); echo "\n </form>"; }
/** * A private method to initialise the day span selector element. * * @access pivate */ function _initDaySpanSelector() { require_once MAX_PATH . '/lib/max/Admin/UI/FieldFactory.php'; $aPeriod = array(); $aPeriod['period_preset'] = MAX_getStoredValue('period_preset', 'today'); $aPeriod['period_start'] = MAX_getStoredValue('period_start', date('Y-m-d')); $aPeriod['period_end'] = MAX_getStoredValue('period_end', date('Y-m-d')); $this->oDaySpanSelector =& FieldFactory::newField('day-span'); $this->oDaySpanSelector->_name = 'period'; $this->oDaySpanSelector->enableAutoSubmit(); $this->oDaySpanSelector->setValueFromArray($aPeriod); $this->aDates = array('day_begin' => $this->oDaySpanSelector->getStartDate(), 'day_end' => $this->oDaySpanSelector->getEndDate()); if (!is_null($this->aDates['day_begin'])) { $this->aDates['day_begin'] = $this->aDates['day_begin']->format('%Y-%m-%d'); $this->aDates['day_end'] = $this->aDates['day_end']->format('%Y-%m-%d'); } else { $this->aDates = array(); } $this->aGlobalPrefs['period_preset'] = $this->oDaySpanSelector->_fieldSelectionValue; $this->aGlobalPrefs['period_start'] = $this->aDates['day_begin']; $this->aGlobalPrefs['period_end'] = $this->aDates['day_end']; }