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


PHP Controller::curr方法代码示例

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


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

示例1: saveNewsArticle

 function saveNewsArticle($data, Form $form)
 {
     try {
         $form->clearMessage();
         $form->resetValidation();
         if ($data['newsID']) {
             $this->manager->updateNews($data);
         } else {
             $this->manager->postNews($data);
         }
         Session::clear("FormInfo.Form_NewsRequestForm.data");
         return Controller::curr()->redirect('/news-add/?saved=1');
     } catch (EntityValidationException $ex1) {
         $messages = $ex1->getMessages();
         $msg = $messages[0];
         $form->addErrorMessage('Headline', $msg['message'], 'bad');
         SS_Log::log($msg['message'], SS_Log::ERR);
         // Load errors into session and post back
         Session::set("FormInfo.Form_NewsRequestForm.data", $data);
         return $this->redirectBack();
     } catch (Exception $ex) {
         $form->addErrorMessage('Headline', 'Server Error', 'bad');
         SS_Log::log($ex->getMessage(), SS_Log::ERR);
         // Load errors into session and post back
         Session::set("FormInfo.Form_NewsRequestForm.data", $data);
         return $this->redirectBack();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:28,代码来源:NewsRequestPage.php

示例2: SaveDeployment

 function SaveDeployment($data, $form)
 {
     $id = convert::raw2sql($data['DeploymentID']);
     // Only loaded if it belongs to current user
     $Deployment = $form->controller->LoadDeployment($id);
     // If a deployment wasn't returned, we'll create a new one
     if (!$Deployment) {
         $Deployment = new Deployment();
         $Deployment->OrgID = Member::currentUser()->getCurrentOrganization()->ID;
         $newDeploy = true;
     }
     $form->saveInto($Deployment);
     $survey = $form->controller->GetCurrentSurvey();
     $Deployment->DeploymentSurveyID = $survey->ID;
     $Deployment->UpdateDate = SS_Datetime::now()->Rfc2822();
     $Deployment->OrgID = $survey->OrgID;
     $Deployment->write();
     /**/
     $survey->CurrentStep = 'MoreDeploymentDetails';
     $survey->HighestStepAllowed = 'MoreDeploymentDetails';
     $survey->UpdateDate = SS_Datetime::now()->Rfc2822();
     $survey->write();
     // If it is a new deployment and it is public, we send an email...
     if (isset($newDeploy) && $Deployment->IsPublic === 1) {
         global $email_new_deployment;
         global $email_from;
         $email = EmailFactory::getInstance()->buildEmail($email_from, $email_new_deployment, 'New Deployment');
         $email->setTemplate('NewDeploymentEmail');
         $email->populateTemplate(array('Deployment' => $Deployment));
         $email->send();
     }
     Session::set('CurrentDeploymentID', $Deployment->ID);
     Controller::curr()->redirect($form->controller->Link() . 'MoreDeploymentDetails');
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:34,代码来源:DeploymentSurveyDeploymentDetailsForm.php

示例3: doChangePassword

 /**
  * @param array $data
  * @return SS_HTTPResponse|void
  */
 function doChangePassword(array $data)
 {
     try {
         $token = Session::get('AutoLoginHash');
         $member = $this->password_manager->changePassword($token, @$data['NewPassword1'], @$data['NewPassword2']);
         Session::clear('AutoLoginHash');
         $back_url = isset($_REQUEST['BackURL']) ? $_REQUEST['BackURL'] : '/';
         return OpenStackIdCommon::loginMember($member, $back_url);
     } catch (InvalidResetPasswordTokenException $ex1) {
         Session::clear('AutoLoginHash');
         Controller::curr()->redirect('login');
     } catch (EmptyPasswordException $ex2) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.EMPTYNEWPASSWORD', "The new password can't be empty, please try again"), "bad");
         Controller::curr()->redirectBack();
     } catch (PasswordMismatchException $ex3) {
         $this->clearMessage();
         $this->sessionMessage(_t('Member.ERRORNEWPASSWORD', "You have entered your new password differently, try again"), "bad");
         Controller::curr()->redirectBack();
     } catch (InvalidPasswordException $ex4) {
         $this->clearMessage();
         $this->sessionMessage(sprintf(_t('Member.INVALIDNEWPASSWORD', "We couldn't accept that password: %s"), nl2br("\n" . $ex4->getMessage())), "bad");
         Controller::curr()->redirectBack();
     }
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:29,代码来源:CustomChangePasswordForm.php

示例4: getDefaultMapConfiguration

 /**
  * This method returns the default configuration array structure of the 
  * default map. It is used to initialize the OpenLayer JavaScript classes
  * after the page has been loaded.
  *
  * @return array Configuration array which is processed by JS:initMap
  */
 public function getDefaultMapConfiguration()
 {
     $result = array();
     $mapObject = $this->GetComponent('Map');
     if ($mapObject && $mapObject->ID != 0) {
         $result = $mapObject->getConfigurationArray();
         $cont = Controller::curr();
         $request = $cont->getRequest();
         if ($request) {
             if ($request->getVar('bbox')) {
                 $param = $request->getVar('bbox');
                 $array = preg_split("/[\\s]*[,][\\s]*/", $param);
                 if (sizeof($array) == 4) {
                     $result['Latitude'] = '';
                     $result['Longitude'] = '';
                     $result['Zoom'] = '';
                     $extent['left'] = $array[0];
                     $extent['top'] = $array[1];
                     $extent['right'] = $array[2];
                     $extent['bottom'] = $array[3];
                     $result['Map']['DefaultExtent'] = $extent;
                 }
             }
         }
     }
     return $result;
 }
开发者ID:helpfulrobot,项目名称:silverstripe-openlayers,代码行数:34,代码来源:OLMapPage.php

示例5: doAddMockData

 /**
  * A form action that handles populating the record with mock data
  *
  * @param array $data The data that as passed in from the form
  * @param Form $form The Form object that was used
  * @return SSViewer
  */
 public function doAddMockData($data, $form)
 {
     $this->owner->record->fill(array('only_empty' => true, 'include_relations' => false, 'download_images' => false));
     Controller::curr()->getResponse()->addHeader("X-Pjax", "Content");
     $link = Controller::join_links($this->owner->gridField->Link(), "item", $this->owner->record->ID);
     return Controller::curr()->redirect($link);
 }
开发者ID:helpfulrobot,项目名称:unclecheese-mock-dataobjects,代码行数:14,代码来源:MockDataGridFieldItemRequest.php

示例6: allMethodNames

 public function allMethodNames($custom = false)
 {
     // A friendly hack to make hasMethod returns true
     if (Controller::has_curr()) {
         return array(Controller::curr()->getRequest()->param('Action'));
     }
 }
开发者ID:lekoala,项目名称:silverstripe-devtoolkit,代码行数:7,代码来源:TranslatableActionsControllerExtension.php

示例7: isBrowser

 /**
  * A basic browser detection.
  * * if a browser is not here - assume it's a crawler or a bot. In which case, it shouldn't create a shortlist.
  *
  * @see http://stackoverflow.com/a/1537636
  * */
 public static function isBrowser()
 {
     // Regular expression to match common browsers
     $browserlist = '/(opera|aol|msie|firefox|chrome|konqueror|safari|netscape|navigator|mosaic|lynx|amaya|omniweb|avant|camino|flock|seamonkey|mozilla|gecko)+/i';
     $userAgent = strtolower(Controller::curr()->getRequest()->getHeader('User-Agent'));
     return preg_match($browserlist, $userAgent) === 1;
 }
开发者ID:salted-herring,项目名称:silverstripe-shortlist,代码行数:13,代码来源:ShortList.php

示例8: saveAllRecords

 protected function saveAllRecords(\GridField $grid, $arguments, $data)
 {
     if (isset($data[$grid->Name])) {
         $currValue = $grid->Value();
         $grid->setValue($data[$grid->Name]);
         $model = singleton($grid->List->dataClass());
         foreach ($grid->getConfig()->getComponents() as $component) {
             if ($component instanceof \GridField_SaveHandler) {
                 $component->handleSave($grid, $model);
             }
         }
         if ($this->publish) {
             // Only use the viewable list items, since bulk publishing can take a toll on the system
             $list = ($paginator = $grid->getConfig()->getComponentByType('GridFieldPaginator')) ? $paginator->getManipulatedData($grid, $grid->List) : $grid->List;
             $list->each(function ($item) {
                 if ($item->hasExtension('Versioned')) {
                     $item->writeToStage('Stage');
                     $item->publish('Stage', 'Live');
                 }
             });
         }
         if ($model->exists()) {
             $model->delete();
             $model->destroy();
         }
         $grid->setValue($currValue);
         if (\Controller::curr() && ($response = \Controller::curr()->Response)) {
             if (!$this->completeMessage) {
                 $this->completeMessage = _t('GridField.DONE', 'Done.');
             }
             $response->addHeader('X-Status', rawurlencode($this->completeMessage));
         }
     }
 }
开发者ID:helpfulrobot,项目名称:milkyway-multimedia-ss-gridfield-utils,代码行数:34,代码来源:SaveAllButton.php

示例9: build

 /**
  * @param IRSVPTemplate $template
  * @param IRSVP $rsvp
  * @param ISummitEvent $event
  * @param string $form_name
  * @return BootstrapForm|PresentationSpeaker
  */
 public function build(IRSVPTemplate $template, IRSVP $rsvp, ISummitEvent $event, $form_name = 'RSVPForm')
 {
     $fields = new FieldList();
     foreach ($template->getQuestions() as $q) {
         $type = $q->Type();
         $builder_class = $type . 'UIBuilder';
         // @IRSVPQuestionTemplateUIBuilder
         $builder = Injector::inst()->create($builder_class);
         $answer = $rsvp ? $rsvp->findAnswerByQuestion($q) : null;
         $field = $builder->build($rsvp, $q, $answer);
         $fields->add($field);
     }
     $validator = null;
     if ($rsvp) {
         $fields->add(new HiddenField('rsvp_id', 'rsvp_id', $rsvp->getIdentifier()));
     }
     $fields->add(new HiddenField('event_id', 'event_id', $event->getIdentifier()));
     $fields->add(new HiddenField('summit_id', 'summit_id', $event->Summit()->getIdentifier()));
     $fields->add(new HiddenField('seat_type', 'seat_type', $event->getCurrentRSVPSubmissionSeatType()));
     $fields->add(new LiteralField('hr', '<hr>'));
     $actions = new FieldList(FormAction::create('submit_rsvp')->setTitle('Send RSVP')->addExtraClass('rsvp_submit'));
     $form = new BootstrapForm(Controller::curr(), $form_name . '_' . $event->getIdentifier(), $fields, $actions, $validator);
     $form->setAttribute('class', 'rsvp_form');
     return $form;
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:32,代码来源:RSVPTemplateUIBuilder.php

示例10: StartSurvey

 function StartSurvey($data, $form)
 {
     //Check for existing member email address
     if ($member = Member::get()->filter('Email', Convert::raw2sql($data['Email']))->first()) {
         //Set error message
         $form->AddErrorMessage('Email', "Sorry, that email address already exists. Please choose another or login with that email.", 'bad');
         //Set form data from submitted values
         Session::set("FormInfo.Form_DeploymentSurveyRegistrationForm.data", $data);
         //Return back to form
         return Controller::curr()->redirectBack();
     }
     //Otherwise create new member and log them in
     $Member = new Member();
     $form->saveInto($Member);
     $Member->write();
     //Find or create the 'user' group
     if (!($userGroup = Group::get()->filter('Code', 'users')->first())) {
         $userGroup = new Group();
         $userGroup->Code = "users";
         $userGroup->Title = "Users";
         $userGroup->Write();
         $Member->Groups()->add($userGroup);
     }
     //Add member to user group
     $Member->Groups()->add($userGroup);
     $BackURL = Controller::curr()->Link('AboutYou');
     return OpenStackIdCommon::loginMember($Member, $BackURL);
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:28,代码来源:DeploymentSurveyRegistrationForm.php

示例11: save

 function save($data, $form)
 {
     $response = new OSLogoProgramResponse();
     $form->saveInto($response);
     // Combine these two fields so we just store a manually typed name in
     // $data[OtherCompany]
     if ($data['NonSponsorCompany']) {
         $response->OtherCompany = $data['NonSponsorCompany'];
     }
     $response->write();
     // Now set the official company name for the email
     $data['CompanyName'] = 'Not Provided';
     if ($response->OtherCompany) {
         $response->CompanyName = $response->OtherCompany;
     } elseif ($response->CompanyID != 0) {
         $company = Company::get()->byID($response->CompanyID);
         if ($company) {
             $response->CompanyName = $company->Name;
         }
     }
     // Email the logo email list
     $Subject = "Contact Form for Commercial Logo Inquiries";
     $email = EmailFactory::getInstance()->buildEmail($data['Email'], OS_LOGO_PROGRAM_FORM_TO_EMAIL, $Subject);
     $email->setTemplate('OSLogoProgramResponseEmail');
     $email->populateTemplate($response);
     $email->send();
     if ($response->Program === 'Powered') {
         Controller::curr()->setMessage('success', 'Thanks for your interest in licensing the OpenStack Powered logo. Please review the interoperability standards at  <a href="http://www.openstack.org/interop" class="alert-link">openstack.org/interop</a> page and submit test results according to the instructions.');
     }
     return Controller::curr()->redirect(Controller::curr()->Link("thanks"));
 }
开发者ID:OpenStackweb,项目名称:openstack-org,代码行数:31,代码来源:OSLogoProgramForm.php

示例12: augmentSQL

 /**
  * Update any requests to limit the results to the current site
  */
 public function augmentSQL(SQLQuery &$query, DataQuery &$dataQuery = null)
 {
     $ctrl = null;
     if (Controller::has_curr()) {
         $ctrl = Controller::curr();
     }
     if (Subsite::$disable_subsite_filter) {
         return;
     }
     if ($dataQuery->getQueryParam('Subsite.filter') === false) {
         return;
     }
     if ($ctrl && get_class(Controller::curr()) == 'Security') {
         return;
     }
     // Don't run on delete queries, since they are always tied to
     // a specific ID.
     if ($query->getDelete()) {
         return;
     }
     // If you're querying by ID, ignore the sub-site - this is a bit ugly...
     // if(!$query->where || (strpos($query->where[0], ".\"ID\" = ") === false && strpos($query->where[0], ".`ID` = ") === false && strpos($query->where[0], ".ID = ") === false && strpos($query->where[0], "ID = ") !== 0)) {
     if (!$query->filtersOnID()) {
         if (Subsite::$force_subsite) {
             $subsiteID = Subsite::$force_subsite;
         } else {
             $subsiteID = (int) Subsite::currentSubsiteID();
         }
         $froms = $query->getFrom();
         $froms = array_keys($froms);
         $tableName = array_shift($froms);
         $query->addWhere("\"{$tableName}\".\"SubsiteID\" IN ({$subsiteID})");
     }
 }
开发者ID:zarocknz,项目名称:silverstripe-mandrill,代码行数:37,代码来源:EmailTemplateSubsiteExtension.php

示例13: Link

 function Link()
 {
     $brandspage = Controller::curr()->data();
     if ($brandspage->ProductGroupID && ($group = $brandspage->ProductGroup())) {
         return $group->Link() . "?Brand=" . $this->ID;
     }
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce-brandbrowsing,代码行数:7,代码来源:ProductBrand.php

示例14: saveLink

 function saveLink($data, $form)
 {
     $url = $data['HostedMediaURL'];
     $EventID = Session::get('UploadMedia.PresentationID');
     if ($EventID) {
         $Event = VideoPresentation::get()->byID($EventID);
     }
     // Attach a protocol if needed
     if (substr($url, 0, 7) != 'http://' && substr($url, 0, 8) != 'https://') {
         $url = 'http://' . $url;
     }
     if (!filter_var($url, FILTER_VALIDATE_URL)) {
         $form->sessionMessage('That does not appear to be a valid URL', 'bad');
         return $this->controller()->redirectBack();
     } elseif (!$Event) {
         $data["HasError"] = TRUE;
         return $this->controller()->Customise($data);
     } else {
         $Event->HostedMediaURL = $url;
         $Event->MediaType = 'URL';
         $Event->write();
         Session::set('UploadMedia.Success', TRUE);
         Session::set('UploadMedia.URL', $url);
         Session::set('UploadMedia.Type', 'URL');
         Controller::curr()->redirect($form->controller()->link() . 'Success');
     }
 }
开发者ID:Thingee,项目名称:openstack-org,代码行数:27,代码来源:PresentationLinkToForm.php

示例15: getHTMLFragments

 public function getHTMLFragments($gridField)
 {
     $model = Injector::inst()->create($gridField->getModelClass());
     $parent = SiteTree::get()->byId(Controller::curr()->currentPageID());
     if (!$model->canCreate()) {
         return array();
     }
     $children = $this->getAllowedChildren($parent);
     if (count($children) > 1) {
         $pageTypes = DropdownField::create("PageType", "Page Type", $children, $model->defaultChild());
         $pageTypes->setFieldHolderTemplate("GridFieldSiteTreeAddNewButton_holder")->addExtraClass("gridfield-dropdown no-change-track");
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.AddMultipleOptions', 'Add new', "Add button text for multiple options.");
         }
     } else {
         $keys = array_keys($children);
         $pageTypes = HiddenField::create('PageType', 'Page Type', $keys[0]);
         if (!$this->buttonName) {
             $this->buttonName = _t('GridFieldSiteTreeAddNewButton.Add', 'Add new {name}', 'Add button text for a single option.', array($children[$keys[0]]));
         }
     }
     $state = $gridField->State->GridFieldSiteTreeAddNewButton;
     $state->currentPageID = $parent->ID;
     $state->pageType = $parent->defaultChild();
     $addAction = new GridField_FormAction($gridField, 'add', $this->buttonName, 'add', 'add');
     $addAction->setAttribute('data-icon', 'add')->addExtraClass("no-ajax ss-ui-action-constructive dropdown-action");
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($pageTypes);
     $forTemplate->Fields->push($addAction);
     Requirements::css(LUMBERJACK_DIR . "/css/lumberjack.css");
     Requirements::javascript(LUMBERJACK_DIR . "/javascript/GridField.js");
     return array($this->targetFragment => $forTemplate->renderWith("GridFieldSiteTreeAddNewButton"));
 }
开发者ID:micmania1,项目名称:silverstripe-lumberjack,代码行数:34,代码来源:GridFieldSiteTreeAddNewButton.php


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