fault($app_strings['ERR_RSS_INVALID_RESPONSE']); } ob_clean(); $this->generateResponseHeader(count($input['entry_list'])); $this->generateItems($input); $this->generateResponseFooter(); } // fn protected function generateResponseHeader($count) { global $app_strings, $sugar_version, $sugar_flavor; $date = TimeDate::httpTime(); echo << {$app_strings['LBL_RSS_FEED']} » {$app_strings['LBL_BROWSER_TITLE']} {$GLOBALS['sugar_config']['site_url']} {$count} {$app_strings['LBL_RSS_RECORDS_FOUND']} {$date} SugarCRM $sugar_version $sugar_flavor EORSS; } protected function generateItems($input) { global $app_strings; if(!empty($input['entry_list'])){ foreach($input['entry_list'] as $item){ $this->generateItem($item); } } } protected function generateItem($item) { $name = !empty($item['name_value_list']['name']['value'])?htmlentities( $item['name_value_list']['name']['value']): ''; $url = $GLOBALS['sugar_config']['site_url'] . htmlentities('/index.php?module=' . $item['module_name']. '&action=DetailView&record=' . $item['id']); $date = TimeDate::httpTime(TimeDate::getInstance()->fromDb($item['name_value_list']['date_modified']['value'])->getTimestamp()); $description = ''; $displayFieldNames = true; if(count($item['name_value_list']) == 2 &&isset($item['name_value_list']['name']))$displayFieldNames = false; foreach($item['name_value_list'] as $k=>$v){ if ( $k == 'name' || $k == 'date_modified') { continue; } if($displayFieldNames) $description .= '' .htmlentities( $k) . ': '; $description .= htmlentities( $v['value']) . "
"; } echo << $name $url $date GMT {$item['id']} EORSS; } protected function generateResponseFooter() { echo <<
EORSS; } /** * Returns a fault since we cannot accept RSS as an input type * * @see SugarRest::serve() */ public function serve() { global $app_strings; $this->fault($app_strings['ERR_RSS_INVALID_INPUT']); } /** * @see SugarRest::fault() */ public function fault($faultObject) { ob_clean(); $this->generateResponseHeader(); echo ''; if(is_object($errorObject)){ $error = $errorObject->number . ': ' . $errorObject->name . '
' . $errorObject->description; $GLOBALS['log']->error($error); }else{ $GLOBALS['log']->error(var_export($errorObject, true)); $error = var_export($errorObject, true); } // else echo $error; echo '
'; $this->generateResponseFooter(); } }