本文整理汇总了PHP中Requirements::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP Requirements::clear方法的具体用法?PHP Requirements::clear怎么用?PHP Requirements::clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Requirements
的用法示例。
在下文中一共展示了Requirements::clear方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generatePDF
function generatePDF()
{
// tempfolder
$tmpBaseFolder = TEMP_FOLDER . '/shopsystem';
$tmpFolder = project() ? "{$tmpBaseFolder}/" . project() : "{$tmpBaseFolder}/site";
if (is_dir($tmpFolder)) {
Filesystem::removeFolder($tmpFolder);
}
if (!file_exists($tmpFolder)) {
Filesystem::makeFolder($tmpFolder);
}
$baseFolderName = basename($tmpFolder);
//Get site
Requirements::clear();
$link = Director::absoluteURL($this->pdfLink() . "/?view=1");
$response = Director::test($link);
$content = $response->getBody();
$content = utf8_decode($content);
$contentfile = "{$tmpFolder}/" . $this->PublicURL . ".html";
if (!file_exists($contentfile)) {
// Write to file
if ($fh = fopen($contentfile, 'w')) {
fwrite($fh, $content);
fclose($fh);
}
}
return $contentfile;
}
示例2: emulateuser
/**
* Action to emulate a specific user
* @param $request = HTTPRequest
* @return redirect
**/
public function emulateuser($request)
{
Requirements::clear();
Requirements::css(DEVTOOLS_DIR . '/css/dev-tools.css');
// not enabled, or not allowed >> get out
if (!$this->CanEmulateUser()) {
echo 'You cannot do that';
die;
}
// get URL parameters
$params = $this->owner->getRequest()->params();
// URL attribute?
if (!isset($params['ID'])) {
$members = Member::get();
$membersList = array();
foreach ($members as $member) {
$membersList[$member->ID] = $member;
}
$membersList = ArrayList::create($membersList);
$membersList = PaginatedList::create($membersList, $this->owner->getRequest());
$membersList->setPageLength(20);
return $this->owner->customise(array('Users' => $membersList))->renderWith('EmulateUserPage');
}
$member = Member::get()->byID($params['ID']);
if (!isset($member->ID)) {
echo 'Could not find user by #' . $params['ID'];
die;
}
$member->logIn();
return $this->owner->redirect($this->owner->Link());
}
示例3: init
public function init()
{
parent::init();
Requirements::clear();
Requirements::insertHeadTags('<meta http-equiv="Content-language" content="' . i18n::get_locale() . '" />');
Requirements::themedCSS('sendfriend', 'screen');
}
示例4: index
/**
* Includes all JS required for ImageEditor. This method requires setting
* a fileToEdit URL in POST.
*
* @return String
*/
public function index() {
Requirements::clear();
Requirements::javascript(THIRDPARTY_DIR . '/prototype.js');
Requirements::javascript(THIRDPARTY_DIR . '/scriptaculous/scriptaculous.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Utils.js');
//Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageHistory.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Image.js');
//Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageTransformation.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Resizeable.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Effects.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Environment.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Crop.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/Resize.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageBox.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/ImageEditor.js');
Requirements::javascript(CMS_DIR . '/javascript/ImageEditor/DocumentBody.js');
Requirements::javascript(THIRDPARTY_DIR . '/loader.js');
Requirements::javascript(THIRDPARTY_DIR . '/behaviour.js');
Requirements::javascript(CMS_DIR . '/javascript/LeftAndMain.js');
Requirements::css(CMS_DIR . 'css/ImageEditor/ImageEditor.css');
if(!isset($this->requestParams['fileToEdit'])) $this->raiseError();
$fileWithPath = $this->requestParams['fileToEdit'];
$this->fileToEdit = $this->file2Origin($fileWithPath);
$this->fileToEditOnlyName = $this->urlToFilename($this->fileToEdit);
return $this->renderWith(__CLASS__);
}
示例5: overview_data
/**
* Gets the overview data from new relic
*/
public function overview_data()
{
//Purge Requirements
Requirements::clear();
//If we're not configured properly return an error
if (!$this->getIsConfigured()) {
$msg = _t('NewRelicPerformanceReport.API_APP_CONFIG_ERROR', '_New Relic API Key or Application ID is missing, check configuration');
$e = new SS_HTTPResponse_Exception($msg, 400);
$e->getResponse()->addHeader('Content-Type', 'text/plain');
$e->getResponse()->addHeader('X-Status', rawurlencode($msg));
throw $e;
return;
}
//Build the base restful service object
$service = new RestfulService('https://api.newrelic.com/v2/applications/' . Convert::raw2url($this->config()->application_id) . '/metrics/data.json', $this->config()->refresh_rate);
$service->httpHeader('X-Api-Key:' . Convert::raw2url($this->config()->api_key));
//Perform the request
$response = $service->request('', 'POST', 'names[]=HttpDispatcher&names[]=Apdex&names[]=EndUser/Apdex&names[]=Errors/all&names[]=EndUser&period=60');
//Retrieve the body
$body = $response->getBody();
if (!empty($body)) {
$this->response->addHeader('Content-Type', 'application/json; charset=utf-8');
return $body;
}
//Data failed to load
$msg = _t('NewRelicPerformanceReport.DATA_LOAD_FAIL', '_Failed to retrieve data from New Relic');
$e = new SS_HTTPResponse_Exception($msg, 400);
$e->getResponse()->addHeader('Content-Type', 'text/plain');
$e->getResponse()->addHeader('X-Status', rawurlencode($msg));
throw $e;
}
示例6: preview
/**
* Body for the preview iframe with just the typography styles included
* @return string html
*/
public function preview()
{
Requirements::clear();
// Should contain text styles of the page by Silverstripe theme conventions.
Requirements::css('themes/' . Config::inst()->get('SSViewer', 'theme') . '/css/editor.css');
return $this->renderWith('PreviewFrame');
}
示例7: uploadiframe
/**
* Show the content of the upload iframe. The form is specified by a template.
*/
function uploadiframe()
{
Requirements::clear();
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/prototype/prototype.js");
Requirements::javascript(SAPPHIRE_DIR . '/javascript/loader.js');
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/behaviour/behaviour.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/prototype_improvements.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/layout_helpers.js");
Requirements::javascript(CMS_DIR . "/javascript/LeftAndMain.js");
Requirements::javascript(CMS_DIR . "/thirdparty/multifile/multifile.js");
Requirements::css(CMS_DIR . "/thirdparty/multifile/multifile.css");
Requirements::javascript(SAPPHIRE_DIR . "/thirdparty/jquery/jquery.js");
Requirements::javascript(SAPPHIRE_DIR . "/javascript/jquery_improvements.js");
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");
$id = (int) $this->request->param('ID');
if ($id) {
$folder = DataObject::get_by_id("Folder", $id);
} else {
$folder = singleton('Folder');
}
return array('CanUpload' => $folder->canEdit());
}
示例8: init
function init()
{
parent::init();
// somehow themed css gets mixed in, remove it
$reqbe = Requirements::backend();
foreach ($reqbe->get_css() as $file => $val) {
if (preg_match('/^themes\\//', $file)) {
Requirements::block($file);
}
}
Requirements::javascript(THIRDPARTY_DIR . '/jquery-form/jquery.form.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.core.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.widget.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.mouse.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.tabs.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.button.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.position.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.dialog.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-ui/jquery.ui.draggable.js');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.core.css');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.dialog.css');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.theme.css');
Requirements::css(THIRDPARTY_DIR . '/jquery-ui-themes/base/jquery.ui.tabs.css');
Requirements::clear('jsparty/prototype.js');
Requirements::javascript(SAPPHIRE_DIR . "/javascript/i18n.js");
Requirements::add_i18n_javascript('dbplumber/javascript/lang');
Requirements::javascript("dbplumber/javascript/DatabaseBrowser.js");
Requirements::javascript("dbplumber/thirdparty/jquery.event.drag-1.4.js");
Requirements::javascript("dbplumber/thirdparty/jquery.kiketable.colsizable-1.1.js");
Requirements::javascript("dbplumber/thirdparty/jquery.textarea-expander.js");
Requirements::css("dbplumber/thirdparty/jquery.kiketable.colsizable-1.1.css");
Requirements::css("dbplumber/css/DatabaseBrowser_left.css");
Requirements::css("dbplumber/css/DatabaseBrowser_right.css");
}
示例9: publish
/**
* When an error page is published, create a static HTML page with its
* content, so the page can be shown even when SilverStripe is not
* functioning correctly before publishing this page normally.
* @param string|int $fromStage Place to copy from. Can be either a stage name or a version number.
* @param string $toStage Place to copy to. Must be a stage name.
* @param boolean $createNewVersion Set this to true to create a new version number. By default, the existing version number will be copied over.
*/
function publish($fromStage, $toStage, $createNewVersion = false)
{
// Temporarily log out when producing this page
$loggedInMember = Member::currentUser();
Session::clear("loggedInAs");
$alc_enc = isset($_COOKIE['alc_enc']) ? $_COOKIE['alc_enc'] : null;
Cookie::set('alc_enc', null);
$oldStage = Versioned::current_stage();
// Run the page
Requirements::clear();
$controller = new ErrorPage_Controller($this);
$errorContent = $controller->run(array())->getBody();
if (!file_exists("../assets")) {
mkdir("../assets", 02775);
}
if ($fh = fopen("../assets/error-{$this->ErrorCode}.html", "w")) {
fwrite($fh, $errorContent);
fclose($fh);
}
// Restore the version we're currently connected to.
Versioned::reading_stage($oldStage);
// Log back in
if ($loggedInMember) {
Session::set("loggedInAs", $loggedInMember->ID);
}
if (isset($alc_enc)) {
Cookie::set('alc_enc', $alc_enc);
}
return $this->extension_instances['Versioned']->publish($fromStage, $toStage, $createNewVersion);
}
示例10: init
/**
* Loads the requirements, checks perms, etc. If an ID is in the URL, that becomes the
* current folder.
*/
public function init()
{
parent::init();
if (!Permission::check("ADMIN") && !Permission::check("CMS_ACCESS_BrowseFiles")) {
return Security::permissionFailure($this, _t('KickAssets.PERMISSIONFAIL', 'You do not have permission to access this section of the CMS.'));
}
Requirements::clear();
Requirements::css('kickassets/css/core.css');
Requirements::css('kickassets/css/kickassets.css');
Requirements::javascript('kickassets/javascript/jquery.js');
Requirements::javascript(THIRDPARTY_DIR . '/jquery-livequery/jquery.livequery.js');
Requirements::javascript('kickassets/javascript/apprise/apprise-1.5.full.js');
Requirements::javascript('kickassets/javascript/jquery.tooltip.js');
Requirements::css('kickassets/javascript/apprise/apprise.css');
Requirements::javascript('kickassets/javascript/kickassets_ui.js');
Requirements::javascript('kickassets/javascript/chosen/chosen.jquery.js');
Requirements::css('kickassets/javascript/chosen/chosen.css');
Requirements::javascript('kickassets/javascript/jquery.form.js');
Requirements::javascript('kickassets/javascript/kickassets.js');
Requirements::css('kickassets/css/kickassets_ui.css');
if ($this->getRequest()->param('ID')) {
$this->currentFolder = DataObject::get_by_id("Folder", (int) $this->getRequest()->param('ID'));
$this->currentPath = KickAssetUtil::relative_asset_dir($this->currentFolder->Filename);
} else {
$this->currentFolder = singleton('Folder');
$this->currentPath = false;
}
}
示例11: init
public function init()
{
if (!$this->trackChairCheck()) {
Security::permissionFailure($this);
}
parent::init();
Requirements::clear();
}
示例12: handlePrint
/**
* Handle the print, for both the action button and the URL
*/
public function handlePrint($gridField, $request = null) {
set_time_limit(60);
Requirements::clear();
Requirements::css(FRAMEWORK_DIR . '/css/GridField_print.css');
if($data = $this->generatePrintData($gridField)){
return $data->renderWith("GridField_print");
}
}
示例13: setupMailer
/**
* this is mainly a test harness
* @return [type] [description]
*/
public function setupMailer()
{
Requirements::clear();
$this->parseVariables(true);
if (empty($this->from)) {
$this->from = Email::config()->admin_email;
}
$headers = $this->customHeaders;
if (project()) {
$headers['X-SilverStripeSite'] = project();
}
$to = $this->to;
$from = $this->from;
$subject = $this->subject;
if ($sendAllTo = $this->config()->send_all_emails_to) {
$subject .= " [addressed to {$to}";
$to = $sendAllTo;
if ($this->cc) {
$subject .= ", cc to {$this->cc}";
}
if ($this->bcc) {
$subject .= ", bcc to {$this->bcc}";
}
$subject .= ']';
unset($headers['Cc']);
unset($headers['Bcc']);
} else {
if ($this->cc) {
$headers['Cc'] = $this->cc;
}
if ($this->bcc) {
$headers['Bcc'] = $this->bcc;
}
}
if ($ccAllTo = $this->config()->cc_all_emails_to) {
if (!empty($headers['Cc']) && trim($headers['Cc'])) {
$headers['Cc'] .= ', ' . $ccAllTo;
} else {
$headers['Cc'] = $ccAllTo;
}
}
if ($bccAllTo = $this->config()->bcc_all_emails_to) {
if (!empty($headers['Bcc']) && trim($headers['Bcc'])) {
$headers['Bcc'] .= ', ' . $bccAllTo;
} else {
$headers['Bcc'] = $bccAllTo;
}
}
if ($sendAllfrom = $this->config()->send_all_emails_from) {
if ($from) {
$subject .= " [from {$from}]";
}
$from = $sendAllfrom;
}
Requirements::restore();
return self::mailer()->setupMailer($to, $from, $subject, $this->attachments, $headers);
}
示例14: onBeforeHTTPError
/**
* Retrieve the correct error page for the current multisite instance.
* @param integer
* @param SS_HTTPRequest
* @throws SS_HTTPResponse_Exception
*/
public function onBeforeHTTPError($code, $request)
{
$errorPage = ErrorPage::get()->filter(array('ErrorCode' => $code, 'SiteID' => Multisites::inst()->getCurrentSiteId()))->first();
if ($errorPage) {
Requirements::clear();
Requirements::clear_combined_files();
$response = ModelAsController::controller_for($errorPage)->handleRequest($request, DataModel::inst());
throw new SS_HTTPResponse_Exception($response, $code);
}
}
开发者ID:helpfulrobot,项目名称:sheadawson-silverstripe-multisites,代码行数:16,代码来源:MultisitesControllerExtension.php
示例15: setUp
public function setUp()
{
Requirements::clear();
// Reset Yepnope::$backend to null for each test
$yep = new Yepnope();
$reflection = new ReflectionClass('Yepnope');
$backendProp = $reflection->getProperty('backend');
$backendProp->setAccessible(true);
$backendProp->setValue($yep, null);
}