当前位置: 首页>>代码示例>>PHP>>正文


PHP FormResponse::status_message方法代码示例

本文整理汇总了PHP中FormResponse::status_message方法的典型用法代码示例。如果您正苦于以下问题:PHP FormResponse::status_message方法的具体用法?PHP FormResponse::status_message怎么用?PHP FormResponse::status_message使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormResponse的用法示例。


在下文中一共展示了FormResponse::status_message方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: validate

 /**
  * Overloaded so that form error messages are displayed.
  * 
  * @see OrderFormValidator::php()
  * @see Form::validate()
  */
 function validate()
 {
     if ($this->validator) {
         $errors = $this->validator->validate();
         if ($errors) {
             if (Director::is_ajax() && $this->validator->getJavascriptValidationHandler() == 'prototype') {
                 FormResponse::status_message(_t('Form.VALIDATIONFAILED', 'Validation failed'), 'bad');
                 foreach ($errors as $error) {
                     FormResponse::add(sprintf("validationError('%s', '%s', '%s');\n", Convert::raw2js($error['fieldName']), Convert::raw2js($error['message']), Convert::raw2js($error['messageType'])));
                 }
             } else {
                 $data = $this->getData();
                 $formError = array();
                 if ($formMessageType = $this->MessageType()) {
                     $formError['message'] = $this->Message();
                     $formError['messageType'] = $formMessageType;
                 }
                 // Load errors into session and post back
                 Session::set("FormInfo.{$this->FormName()}", array('errors' => $errors, 'data' => $data, 'formError' => $formError));
             }
             return false;
         }
     }
     return true;
 }
开发者ID:helpfulrobot,项目名称:swipestripe-swipestripe,代码行数:31,代码来源:AddToCartForm.php

示例2: moderate

 function moderate()
 {
     $id = (int) $this->urlParams['ID'];
     $className = Convert::raw2sql($this->urlParams['ClassName']);
     $state = Convert::raw2sql($this->urlParams['State']);
     $methods = array("delete" => "moderatorDelete", "isspam" => "markSpam", "isham" => "markHam", "approve" => "markApproved", "unapprove" => "markUnapproved");
     ModeratableState::push_state($state);
     $method = $methods[$this->urlParams['Command']];
     if (!$method) {
         FormResponse::clear();
         FormResponse::status_message("Command invalid", 'bad');
     } else {
         if ($error = DataObject::get_by_id($className, $id)->{$method}()) {
             FormResponse::status_message($error, 'bad');
         } else {
             FormResponse::add('$("moderation").elementMoved(' . $id . ');');
         }
     }
     ModeratableState::pop_state();
     return FormResponse::respond();
 }
开发者ID:muskie9,项目名称:silverstripe-moderation,代码行数:21,代码来源:ModeratableAdmin.php

示例3: doPublish

 /**
  * 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 doPublish()
 {
     parent::doPublish();
     // Run the page
     $response = Director::test(Director::makeRelative($this->Link()));
     $errorContent = $response->getBody();
     // Check we have an assets base directory, creating if it we don't
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH, 02775);
     }
     // if the page is published in a language other than default language,
     // write a specific language version of the HTML page
     $filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);
     if ($fh = fopen($filePath, "w")) {
         fwrite($fh, $errorContent);
         fclose($fh);
     } else {
         $fileErrorText = sprintf(_t("ErrorPage.ERRORFILEPROBLEM", "Error opening file \"%s\" for writing. Please check file permissions."), $errorFile);
         FormResponse::status_message($fileErrorText, 'bad');
         FormResponse::respond();
         return;
     }
 }
开发者ID:racontemoi,项目名称:shibuichi,代码行数:31,代码来源:ErrorPage.php

示例4: doPublish

 /**
  * 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 doPublish()
 {
     parent::doPublish();
     // Run the page (reset the theme, it might've been disabled by LeftAndMain::init())
     $oldTheme = SSViewer::current_theme();
     SSViewer::set_theme(SSViewer::current_custom_theme());
     $response = Director::test(Director::makeRelative($this->Link()));
     SSViewer::set_theme($oldTheme);
     $errorContent = $response->getBody();
     // Make the base tag dynamic.
     // $errorContent = preg_replace('/<base[^>]+href="' . str_replace('/','\\/', Director::absoluteBaseURL()) . '"[^>]*>/i', '<base href="$BaseURL" />', $errorContent);
     // Check we have an assets base directory, creating if it we don't
     if (!file_exists(ASSETS_PATH)) {
         mkdir(ASSETS_PATH, 02775);
     }
     // if the page is published in a language other than default language,
     // write a specific language version of the HTML page
     $filePath = self::get_filepath_for_errorcode($this->ErrorCode, $this->Locale);
     if ($fh = fopen($filePath, "w")) {
         fwrite($fh, $errorContent);
         fclose($fh);
     } else {
         $fileErrorText = sprintf(_t("ErrorPage.ERRORFILEPROBLEM", "Error opening file \"%s\" for writing. Please check file permissions."), $errorFile);
         FormResponse::status_message($fileErrorText, 'bad');
         FormResponse::respond();
         return;
     }
 }
开发者ID:Raiser,项目名称:Praktikum,代码行数:36,代码来源:ErrorPage.php

示例5: onAfterSave

 function onAfterSave($record)
 {
     if ($record->hasMethod('NormalRelated') && ($record->NormalRelated() || $record->ReverseRelated())) {
         FormResponse::status_message('Saved, please update related pages.', 'good');
     }
 }
开发者ID:hafriedlander,项目名称:silverstripe-config-experiment,代码行数:6,代码来源:LeftAndMainSubsites.php

示例6: tellBrowserAboutPublicationChange

 /**
  * Return a few pieces of information about a change to a page
  *  - Send the new status message
  *  - Update the action buttons
  *  - Update the treenote
  *  - Send a status message
  */
 function tellBrowserAboutPublicationChange($page, $statusMessage)
 {
     $JS_title = Convert::raw2js($page->TreeTitle());
     $JS_stageURL = $page->DeletedFromStage ? '' : Convert::raw2js($page->AbsoluteLink());
     $liveRecord = Versioned::get_one_by_stage('SiteTree', 'Live', "`SiteTree`.ID = {$page->ID}");
     $JS_liveURL = $liveRecord ? Convert::raw2js($liveRecord->AbsoluteLink()) : '';
     FormResponse::add($this->getActionUpdateJS($page));
     FormResponse::update_status($page->Status);
     if ($JS_stageURL || $JS_liveURL) {
         FormResponse::add("\$('sitetree').setNodeTitle({$page->ID}, '{$JS_title}')");
     } else {
         FormResponse::add("var node = \$('sitetree').getTreeNodeByIdx('{$page->ID}');");
         FormResponse::add("if(node.parentTreeNode)\tnode.parentTreeNode.removeTreeNode(node);");
         FormResponse::add("\$('Form_EditForm').reloadIfSetTo({$page->ID});");
     }
     FormResponse::status_message($statusMessage, 'good');
     FormResponse::add("\$('Form_EditForm').elements.StageURLSegment.value = '{$JS_stageURL}'");
     FormResponse::add("\$('Form_EditForm').elements.LiveURLSegment.value = '{$JS_liveURL}'");
     FormResponse::add("\$('Form_EditForm').notify('PagePublished', \$('Form_EditForm').elements.ID.value);");
     return FormResponse::respond();
 }
开发者ID:ramziammar,项目名称:websites,代码行数:28,代码来源:CMSMain.php

示例7: exportastarball

 public function exportastarball()
 {
     $template = $this->getCurrentDynamicTemplate();
     if (!$template) {
         FormResponse::status_message("No template selected, Please select template");
         FormResponse::load_form($this->getitem(), 'Form_EditForm');
         return FormResponse::respond();
     } else {
         $fileData = $template->exportAs("tar.gz");
         $fileName = $template->Name . ".tar.gz";
         return SS_HTTPRequest::send_file($fileData, $fileName, "application/x-tar");
     }
 }
开发者ID:helpfulrobot,项目名称:silverstripe-dynamictemplate,代码行数:13,代码来源:DynamicTemplateAdmin.php

示例8: restore

 /**
  * Restore a completely deleted page from the SiteTree_versions table.
  */
 function restore($data, $form)
 {
     if (($id = $_REQUEST['ID']) && is_numeric($id)) {
         $restoredPage = Versioned::get_latest_version("SiteTree", $id);
         if ($restoredPage) {
             $restoredPage = $restoredPage->doRestoreToStage();
             FormResponse::get_page($id);
             $title = Convert::raw2js($restoredPage->TreeTitle());
             FormResponse::add("\$('sitetree').setNodeTitle({$id}, '{$title}');");
             FormResponse::status_message(sprintf(_t('CMSMain.RESTORED', "Restored '%s' successfully", PR_MEDIUM, 'Param %s is a title'), $title), 'good');
             return FormResponse::respond();
         } else {
             return new SS_HTTPResponse("SiteTree #{$id} not found", 400);
         }
     } else {
         return new SS_HTTPResponse("Please pass an ID in the form content", 400);
     }
 }
开发者ID:SustainableCoastlines,项目名称:loveyourwater,代码行数:21,代码来源:CMSMain.php

示例9: beforeProcessing

 /**
  * Processing that occurs before a form is executed.
  * This includes form validation, if it fails, we redirect back
  * to the form with appropriate error messages
  */
 function beforeProcessing()
 {
     if ($this->validator) {
         $errors = $this->validator->validate();
         if ($errors) {
             if (Director::is_ajax()) {
                 // Send validation errors back as JSON with a flag at the start
                 //echo "VALIDATIONERROR:" . Convert::array2json($errors);
                 FormResponse::status_message(_t('Form.VALIDATIONFAILED', 'Validation failed'), 'bad');
                 foreach ($errors as $error) {
                     FormResponse::add(sprintf("validationError('%s', '%s', '%s');\n", Convert::raw2js($error['fieldName']), Convert::raw2js($error['message']), Convert::raw2js($error['messageType'])));
                 }
                 echo FormResponse::respond();
                 return false;
             } else {
                 $data = $this->getData();
                 // People will get worried if you leave credit card information in session..
                 if (isset($data['CreditCardNumber'])) {
                     unset($data['CreditCardNumber']);
                 }
                 if (isset($data['DateExpiry'])) {
                     unset($data['Expiry']);
                 }
                 // Load errors into session and post back
                 Session::set("FormInfo.{$this->FormName()}", array('errors' => $errors, 'data' => $data));
                 Director::redirectBack();
             }
             return false;
         }
     }
     return true;
 }
开发者ID:ramziammar,项目名称:websites,代码行数:37,代码来源:Form.php

示例10: startrun

 public function startrun()
 {
     $task = new LinkCheckTask();
     $result = $task->process();
     $script = '';
     if (class_exists('SapphireTest', false) && SapphireTest::is_running_test()) {
         return;
     }
     if (!$result) {
         FormResponse::status_message('There is already a link check running at the moment. Please wait for it to complete before starting a new one.', 'bad');
         return FormResponse::respond();
     }
     if (!empty($result['LinkCheckRunID'])) {
         $run = DataObject::get_by_id('LinkCheckRun', (int) $result['LinkCheckRunID']);
         if ($run) {
             echo $this->addTreeNodeJS($run, true);
         }
     }
 }
开发者ID:halkyon,项目名称:silverstripe-linkchecker,代码行数:19,代码来源:LinkCheckAdmin.php

示例11: javascriptRefresh

 protected function javascriptRefresh($message = 'Please wait...')
 {
     FormResponse::add("\$('Form_EditForm').resetElements();");
     FormResponse::add('$$("#sitetree li.current")[0].selectTreeNode();');
     FormResponse::status_message($message, "good");
     return FormResponse::respond();
 }
开发者ID:rodneyway,项目名称:advancedworkflow,代码行数:7,代码来源:AdvancedWorkflowExtension.php

示例12: delete

 /**
  * Delete a given Dataobjebt by ID
  * 
  * @param $urlParams Array
  * @param $form Form
  * @return String
  */
 function delete($urlParams, $form)
 {
     $id = Convert::raw2sql($_REQUEST['ID']);
     $obj = DataObject::get_by_id($this->stat('data_type'), $id);
     if ($obj) {
         $obj->delete();
     }
     // clear session data
     Session::clear('currentPage');
     FormResponse::status_message(_t('GenericDataAdmin.DELETEDSUCCESS', 'Successfully deleted'), 'good');
     FormResponse::add("\$('Form_EditForm').deleteEffect();");
     return FormResponse::respond();
 }
开发者ID:ramziammar,项目名称:websites,代码行数:20,代码来源:GenericDataAdmin.php

示例13: save

 public function save($urlParams, $form)
 {
     // Don't save the root folder - there's no database record
     if ($_REQUEST['ID'] == 'root') {
         FormResponse::status_message("Saved", "good");
         return FormResponse::respond();
     }
     $form->dataFieldByName('Title')->value = $form->dataFieldByName('Name')->value;
     return parent::save($urlParams, $form);
 }
开发者ID:ramziammar,项目名称:websites,代码行数:10,代码来源:AssetAdmin.php

示例14: savemember

    function savemember()
    {
        $data = $_REQUEST;
        $className = $this->stat('subitem_class');
        $id = $_REQUEST['ID'];
        if ($id == 'new') {
            $id = null;
        }
        if ($id) {
            if (defined('DB::USE_ANSI_SQL')) {
                $record = DataObject::get_one($className, "\"{$className}\".ID = {$id}");
            } else {
                $record = DataObject::get_one($className, "`{$className}`.ID = {$id}");
            }
        } else {
            // send out an email to notify the user that they have been subscribed
            $record = new $className();
        }
        $record->update($data);
        $record->ID = $id;
        $record->write();
        $record->Groups()->add($data['GroupID']);
        $FirstName = Convert::raw2js($record->FirstName);
        $Surname = Convert::raw2js($record->Surname);
        $Email = Convert::raw2js($record->Email);
        $Password = Convert::raw2js($record->Password);
        $response = <<<JS
\t\t\t\$('MemberList').setRecordDetails({$record->ID}, {
\t\t\t\tFirstName : "{$FirstName}",
\t\t\t\tSurname : "{$Surname}",
\t\t\t\tEmail : "{$Email}"
\t\t\t});
\t\t\t\$('MemberList').clearAddForm();
JS;
        FormResponse::add($response);
        FormResponse::status_message(_t('NewsletterAdmin.SAVED'), 'good');
        return FormResponse::respond();
    }
开发者ID:roed,项目名称:silverstripe-newsletter,代码行数:38,代码来源:NewsletterAdmin.php

示例15: workflowAction

 /**
  * Process a workflow action.
  * @param string $workflowClass The sub-class of WorkflowRequest that is expected.
  * @param string $actionName The action method to call on the given WorkflowRequest objec.t
  * @param int $id The ID# of the page.
  * @param string $comment The comment to attach.
  * @param string $successMessage The message to show on success.
  */
 function workflowAction($workflowClass, $actionName, $id, $comment)
 {
     if (is_numeric($id)) {
         // For 2.3 and 2.4 compatibility
         $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`";
         $page = DataObject::get_by_id("SiteTree", $id);
         if (!$page) {
             $page = Versioned::get_one_by_stage("SiteTree", "Live", "{$bt}SiteTree{$bt}.{$bt}ID{$bt} = {$id}");
         }
         if (!$page) {
             return new HTTPResponse("Can't find Page #{$id}", 400);
         }
     } else {
         return new HTTPResponse("Bad ID", 400);
     }
     // If we are creating and approving a workflow in one step, then don't bother emailing
     $notify = !($actionName == 'action' && !$page->openWorkflowRequest($workflowClass));
     if ($request = $page->openOrNewWorkflowRequest($workflowClass, $notify)) {
         $request->clearMembersEmailed();
         if ($successMessage = $request->{$actionName}($comment, null, $notify)) {
             FormResponse::get_page($id);
             $title = Convert::raw2js($page->TreeTitle());
             FormResponse::add("\$('sitetree').setNodeTitle({$id}, \"{$title}\");");
             // gather members for status output
             if ($notify) {
                 $peeps = $request->getMembersEmailed();
                 if ($peeps && $peeps->Count()) {
                     $emails = '';
                     foreach ($peeps as $peep) {
                         if ($peep->Email) {
                             $emails .= $peep->Email . ', ';
                         }
                     }
                     $emails = trim($emails, ', ');
                 } else {
                     $emails = 'no-one';
                 }
             } else {
                 $emails = "no-one";
             }
             if ($successMessage) {
                 FormResponse::status_message(sprintf($successMessage, $emails), 'good');
                 return FormResponse::respond();
             } else {
                 return;
             }
         }
     }
     // Failure
     FormResponse::status_message(_t('SiteTreeCMSWorkflow.WORKFLOW_ACTION_FAILED', "There was an error when processing your workflow request."), 'bad');
     return FormResponse::respond();
 }
开发者ID:helpfulrobot,项目名称:silverstripe-cmsworkflow,代码行数:60,代码来源:LeftAndMainCMSWorkflow.php


注:本文中的FormResponse::status_message方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。