public function preExecute() { afOutput::closeSessionWriteLock(); sfConfig::set('sf_web_debug', false); $this->setLayout(false); $max_age = sfConfig::get('app_sfCombinePlugin_client_cache_max_age', false); if ($max_age !== false) { $lifetime = $max_age * 86400000; // 24*60*60*1000 $this->getResponse()->addCacheControlHttpHeader('max-age', $lifetime); $this->getResponse()->setHttpHeader('Pragma', null, false); $this->getResponse()->setHttpHeader('Expires', null, false); } }
public static function renderEdit($request, $module, $action, afDomAccess $view) { $fields = $view->wrapAll('fields/field'); $submitUrl = self::getSubmitUrl($module, $action, $view); $validators = afEditView::getValidators($fields); $fileTypes = afEditView::getFileTypes($fields); $result = array(); $result['success'] = true; $result['af_submitUrl'] = $request->getUriPrefix() . $submitUrl; $instance = afEditShowRenderer::fetchDataInstance($view); foreach (self::getFieldValues($instance, $fields) as $name => $value) { $result[sprintf('edit[%s]', $name)] = $value; } $result['af_formcfg'] = self::buildFormcfg($submitUrl, $validators, $fileTypes); return afOutput::renderText(json_encode($result)); }
private static function renderCsv($actionName, $source) { HttpUtil::sendDownloadHeaders($actionName . '.csv', 'text/csv'); $rows = $source->getRows(); if (count($rows) > 0) { $keys = array_keys($rows[0]); self::pruneKeys($keys); echo afOutput::asCsv($keys); foreach ($rows as $row) { echo afOutput::asCsv(self::extractValues($row, $keys)); } } exit; }
<?php include dirname(__FILE__) . '/../bootstrap/dbunit.php'; $t = new lime_test(4, new lime_output_color()); $rows = array(array(1997, 'Ford', 'E350', 'ac, abs, moon', 3000.0), array(1999, 'Chevy', 'Venture "Extended Edition"', '', 4900.0), array(1999, 'Chevy', 'Venture "Extended Edition, Very Large"', '', 5000.0), array(1996, 'Jeep', 'Grand Cherokee', 'MUST SELL! air, moon roof, loaded', 4799.0)); $expected = array('"1997","Ford","E350","ac, abs, moon","3000"' . "\n", '"1999","Chevy","Venture ""Extended Edition""","","4900"' . "\n", '"1999","Chevy","Venture ""Extended Edition, Very Large""","","5000"' . "\n", '"1996","Jeep","Grand Cherokee","MUST SELL! air, moon roof, loaded","4799"' . "\n"); for ($i = 0; $i < count($rows); $i++) { $t->is(afOutput::asCsv($rows[$i]), $expected[$i]); }