public function index() { ContentNegotiator::disable(); BasicAuth::disable(); $request_count = count($_REQUEST); $get_count = count($_GET); $post_count = count($_POST); $request = ''; foreach ($_REQUEST as $key=>$value) { $request .= "\t\t<request_item name=\"$key\">$value</request_item>\n"; } $get = ''; foreach ($_GET as $key => $value) { $get .= "\t\t<get_item name=\"$key\">$value</get_item>\n"; } $post = ''; foreach ($_POST as $key => $value) { $post .= "\t\t<post_item name=\"$key\">$value</post_item>\n"; } $out = <<<XML <?xml version="1.0"?> <test> <request count="$request_count"> $request </request> <get count="$get_count"> $get </get> <post count="$post_count"> $post </post> </test> XML; header('Content-type: text/xml'); echo $out; }
/** * Refresh the list of attached files * * @return SSViewer */ public function refresh() { ContentNegotiator::disable(); $count = 0; $before = is_array($this->Value()) ? sizeof($this->Value()) : 0; if (isset($_REQUEST['FileIDs'])) { $ids = explode(",", $_REQUEST['FileIDs']); if (is_array($ids)) { $this->setValue($ids); $count = sizeof($ids) - $before; } } return Convert::array2json(array('html' => $this->renderWith('AttachedFiles'), 'success' => sprintf(_t('Uploadify.SUCCESSFULADDMULTI', 'Added files successfully.'), $count))); }
/** * Refresh the attached files box. This method may receive a list of IDs, * but it will only accept the last one in the list. * * @param SS_HTTPRequest $request * @return SSViewer */ public function refresh(SS_HTTPRequest $request) { ContentNegotiator::disable(); if ($id = $request->requestVar('FileIDs')) { if (!is_numeric($id)) { $arr = explode(',', $id); if (is_array($arr)) { $id = end($arr); } } $this->setValue($id); $name = null; if (is_numeric($id)) { if ($file = DataObject::get_by_id($this->baseFileClass, Convert::raw2sql($id))) { $name = $file->Name; } } } return Convert::array2json(array('html' => $this->renderWith('AttachedFiles'), 'success' => sprintf(_t('Uploadify.SUCCESSFULADDSINGLE', 'Added file "%s" successfully.'), $name))); }
/** * Get all content as a javascript-compatible string (only if there is an Ajax-Request present). * Falls back to {non_ajax_content}, {redirect_url} or Director::redirectBack() (in this order). * * @return string */ static function respond() { // we don't want non-ajax calls to receive javascript if (isset($_REQUEST['forcehtml'])) { return self::$non_ajax_content; } else { if (isset($_REQUEST['forceajax']) || Director::is_ajax()) { ContentNegotiator::disable(); // TODO figure out a way to stay backwards-compatible with Ajax.Evaluator and still use the automatic evaluating of Prototype //header("Content-type: text/javascript"); return self::get_javascript(); } elseif (!empty(self::$non_ajax_content)) { return self::$non_ajax_content; } elseif (!empty(self::$redirect_url)) { Director::redirect(self::$redirect_url); return null; } else { Director::redirectBack(); return null; } } }
function wsdl() { ContentNegotiator::disable(); header("Content-type: text/xml"); return array(); }
function index($url) { // We need to override the default content-type ContentNegotiator::disable(); header('Content-type: application/xml; charset="utf-8"'); // But we want to still render. return array(); }
public function invalid() { ContentNegotiator::disable(); BasicAuth::protect_entire_site(false); $out = <<<XML <?xml version="1.0"?> <test> \t<fail><invalid> </test> XML; header('Content-type: text/xml'); echo $out; }
/** * This handler acts as the switchboard for the controller. * Since no $Action url-param is set, all requests are sent here. */ function index() { ContentNegotiator::disable(); if (!isset($this->urlParams['ClassName'])) { return $this->notFound(); } $className = $this->urlParams['ClassName']; $id = isset($this->urlParams['ID']) ? $this->urlParams['ID'] : null; $relation = isset($this->urlParams['Relation']) ? $this->urlParams['Relation'] : null; // Check input formats if (!class_exists($className)) { return $this->notFound(); } if ($id && !is_numeric($id)) { return $this->notFound(); } if ($relation && !preg_match('/^[a-zA-Z_\\x7f-\\xff][a-zA-Z0-9_\\x7f-\\xff]*$/', $relation)) { return $this->notFound(); } // if api access is disabled, don't proceed $apiAccess = singleton($className)->stat('api_access'); if (!$apiAccess) { return $this->permissionFailure(); } // authenticate through HTTP BasicAuth $this->member = $this->authenticate(); // handle different HTTP verbs if ($this->request->isGET() || $this->request->isHEAD()) { return $this->getHandler($className, $id, $relation); } if ($this->request->isPOST()) { return $this->postHandler($className, $id, $relation); } if ($this->request->isPUT()) { return $this->putHandler($className, $id, $relation); } if ($this->request->isDELETE()) { return $this->deleteHandler($className, $id, $relation); } // if no HTTP verb matches, return error return $this->methodNotAllowed(); }
function SetUp() { parent::SetUp(); self::$page = new UnsubscribeController(); ContentNegotiator::disable(); }
/** * Show the content of the upload iframe. The form is specified by a template. */ function uploadiframe() { Requirements::clear(); Requirements::javascript(THIRDPARTY_DIR . "/prototype.js"); Requirements::javascript(THIRDPARTY_DIR . "/loader.js"); Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js"); Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js"); Requirements::javascript(THIRDPARTY_DIR . "/layout_helpers.js"); Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js"); Requirements::javascript(THIRDPARTY_DIR . "/multifile/multifile.js"); Requirements::css(THIRDPARTY_DIR . "/multifile/multifile.css"); Requirements::css(CMS_DIR . "/css/typography.css"); Requirements::css(CMS_DIR . "/css/layout.css"); Requirements::css(CMS_DIR . "/css/cms_left.css"); Requirements::css(CMS_DIR . "/css/cms_right.css"); if (isset($data['ID']) && $data['ID'] != 'root') { $folder = DataObject::get_by_id("Folder", $data['ID']); } else { $folder = singleton('Folder'); } // Don't modify the output of the template, or it will become invalid ContentNegotiator::disable(); return array('CanUpload' => $folder->canEdit()); }
function index($url) { if (self::$enabled) { SSViewer::set_source_file_comments(false); // We need to override the default content-type ContentNegotiator::disable(); $this->getResponse()->addHeader('Content-Type', 'application/xml; charset="utf-8"'); // But we want to still render. return array(); } else { return new HTTPResponse('Not allowed', 405); } }