本文整理汇总了PHP中sfWebRequest类的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest类的具体用法?PHP sfWebRequest怎么用?PHP sfWebRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了sfWebRequest类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executePaymentSuccess
public function executePaymentSuccess(sfWebRequest $request)
{
$payment_type = $request->getParameter('type');
/** @var sfGuardUser $user */
$user = $this->getUser()->getGuardUser();
/** @var PaymentTransaction $payment */
$payment = $user->getLastNotPayedTransaction($payment_type);
$gtw = new PaypalGateway(array('amount' => $payment->amount, 'success_url' => $this->generateUrl('payment\\success', array('type' => $payment_type)), 'cancel_url' => $this->generateUrl('payment\\cancel'), 'token' => $request->getParameter('token'), 'payer_id' => $request->getParameter('PayerID')));
$res = $gtw->doExpressCheckout();
if ($res) {
$payment->is_payed = true;
$payment->date_payed = date('Y-m-d H:i:s');
$payment->status_code = 'success';
$payment->stamp = $request->getParameter('PayerID');
$payment->save();
$user->account_type = $payment->type;
$user->credit = $payment->type == 'basic' ? 12 : -1;
$user->last_payment_date = date('Y-m-d H:i:s');
$user->save();
$this->getUser()->setFlash('notice', 'The payment is accepted, thank you!');
} else {
$this->getUser()->setFlash('error', 'PayPal connection error');
}
$this->redirect('/project/user/account');
}
示例2: executeSave_slots
public function executeSave_slots(sfWebRequest $request)
{
$this->contentSlots = array();
$this->failedContentSlots = array();
$this->errors = array();
$slotIds = $request->getParameter('slot_ids');
$contentIds = $request->getParameter('content_ids');
foreach ($slotIds as $slotId) {
$content = Doctrine_Core::getTable('sfSympalContent')->find($contentIds[$slotId]);
$contentSlot = Doctrine_Core::getTable('sfSympalContentSlot')->find($slotId);
$contentSlot->setContentRenderedFor($content);
$form = $contentSlot->getEditForm();
$form->bind($request->getParameter($form->getName()));
if ($form->isValid()) {
if ($request->getParameter('preview')) {
$form->updateObject();
} else {
$form->save();
}
$this->contentSlots[] = $contentSlot;
} else {
$this->failedContentSlots[] = $contentSlot;
foreach ($form as $name => $field) {
if ($field->hasError()) {
$this->errors[$contentSlot->getName()] = $field->getError();
}
}
}
}
}
示例3: executeSelect
/**
* Ajax method. Returns JSON data.
* @param sfWebRequest $request
*/
public function executeSelect(sfWebRequest $request)
{
$this->getResponse()->addCacheControlHttpHeader('no-cache');
$this->getResponse()->setContentType('application/json');
$this->getResponse()->sendHttpHeaders();
$group = $request->getParameter('group');
$type = $request->getParameter('type');
$amps = $request->getParameter('amps');
$choices_made = array();
if (intval($group) != -1) {
$choices_made['grp'] = $group;
}
if (intval($type) != -1) {
$choices_made['frame_type'] = $type;
}
if (intval($amps) != -1) {
$choices_made['amps'] = $amps;
}
$manuf_id = intval($request->getParameter('manuf_id'));
$category = new BUCategory();
$dependent_dropdowns = $category->fetchSelectionCriteriaByManuf($manuf_id, $choices_made);
$matching_parts = $category->fetchMatchingParts($manuf_id, $choices_made);
$json_data = json_encode(array_merge($dependent_dropdowns, $matching_parts));
return $this->renderText($json_data);
}
示例4: executeActivityBox
public function executeActivityBox(sfWebRequest $request)
{
$id = $request->getParameter('id', $this->getUser()->getMemberId());
$this->activities = Doctrine::getTable('ActivityData')->getActivityList($id, null, $this->gadget->getConfig('row'));
$this->member = Doctrine::getTable('Member')->find($id);
$this->isMine = $id == $this->getUser()->getMemberId();
}
示例5: executeIndex
public function executeIndex(sfWebRequest $request) {
if ($request->isMethod('post')){
$from = $request->getParameter('From');
if (!Utils::isEmptyStr($from)){
if (Utils::startsWith($from, "+1")) $from = substr($from, 2);
//look up the user by phone number
$guardUser = Doctrine::getTable('SfGuardUser')->findOneByPhone($from);
if ($guardUser){
//get the last response
$response = Doctrine::getTable('BlastResponse')->createQuery()->where('user_id = ?', $guardUser->getId())
->orderBy('updated_at desc')->fetchOne();
if ($response) {
$this->redirect('phoneResponse/intro?responseId=' . $response->getId());
}
}
}
}
?>
<Response>
<Say>Thanks for calling Make A Minyan dot com. Please visit us online at Make A Minyan dot com. Thank you! Goodbye.</Say>
<Hangup />
</Response>
<?
return sfView::NONE;
}
示例6: executeJoin
public function executeJoin(sfWebRequest $request)
{
$eventId = $request['id'];
$this->forward400If(!$this->isAllowed($this->event, $this->getUser()->getMember(), 'addComment'), 'You are not allowed to join this event');
$eventMember = Doctrine::getTable('CommunityEventMember')->retrieveByEventIdAndMemberId($eventId, $this->member->getId());
$flag = $request->getParameter('leave');
if ($flag && 'true' === $flag) {
if (!$eventMember) {
$this->forward400('You can\'t leave this event.');
}
if ($this->event->isClosed()) {
$this->forward400('This event has already been finished.');
}
if ($this->event->isExpired()) {
$this->forward400('This event has already been expired.');
}
$eventMember->delete();
} else {
try {
if ($eventMember) {
throw new opCommunityTopicAPIRuntimeException('You are already this event member.');
}
$this->event->toggleEventMember($this->member->getId());
} catch (RuntimeException $e) {
$this->forward400($e->getMessage());
}
}
}
示例7: executeDownloadDocument
public function executeDownloadDocument(sfWebRequest $request)
{
$student_disciplinary_sanction = StudentDisciplinarySanctionPeer::retrieveByPK($request->getParameter('id'));
if ($student_disciplinary_sanction && $student_disciplinary_sanction->getDocument()) {
$filePath = $student_disciplinary_sanction->getDocumentFullPath();
$response = $this->getResponse();
$response->setHttpHeader('Pragma', '');
$response->setHttpHeader('Cache-Control', '');
$data = file_get_contents($filePath);
$file_exploded = explode('.', $student_disciplinary_sanction->getDocument());
$file_extension = end($file_exploded);
if ($file_extension == 'pdf') {
$response->setHttpHeader('Content-Type', 'application/pdf');
} else {
if ($file_extension == 'jpg') {
$content_type = 'jpeg';
} else {
$content_type = $file_extension;
}
$response->setHttpHeader('Content-Type', 'image/' . $content_type);
}
$response->setHttpHeader('Content-Disposition', "attachment; filename=\"" . $student_disciplinary_sanction->getDocument() . "\"");
$response->setContent($data);
}
return sfView::NONE;
}
示例8: executeDelete
public function executeDelete(sfWebRequest $request)
{
$request->checkCSRFProtection();
$this->album->delete();
$this->getUser()->setFlash('notice', 'The album was deleted successfully.');
$this->redirect('album/list');
}
示例9: executeDelete
public function executeDelete(sfWebRequest $request)
{
$request->checkCSRFProtection();
$this->dispatcher->notify(new sfEvent($this, 'admin.delete_object', array('object' => $this->getRoute()->getObject())));
//On récupère l'image source
$imgSource = $this->getRoute()->getObject()->getFichierSource();
//Ainsi que le dossier qui la contient
$uploadFolder = sfConfig::get('app_images_upload_dir');
//On en déduit son nom est son extension
$filename = substr($imgSource, 0, strrpos($imgSource, '.'));
$extension = substr(strrchr($imgSource, '.'), 1);
//On supprime l'image de base
unlink($uploadFolder . $imgSource);
//Puis pour chacune des tailles prédefinies à laquelle l'image a pu être redimensionnée
foreach (convertImageToThumb::$predefinedSizes as $suffix => $infos) {
//On supprime aussi le bon fichier
unlink($uploadFolder . $filename . "_" . $suffix . "." . $extension);
}
$this->getRoute()->getObject()->delete();
//$this->getUser()->setFlash('notice', 'The item was deleted successfully.');
$this->json['success'] = true;
$this->setRequestParameter('json', $this->json);
$this->forward($this->getModuleName(), 'jsonResponse');
//$this->redirect('@illustration');
}
示例10: processForm
protected function processForm(sfWebRequest $request, sfForm $form)
{
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
if ($form->isValid()) {
try {
$peticion = $form->save();
$aux = Doctrine_Query::create()->from('sfGuardUser s')->where('s.email_address = ?', $peticion->getEmailAddress());
$aux1 = $aux->fetchOne();
if (!$aux1) {
$auxU = Doctrine_Query::create()->from('sfGuardUser s')->where('s.username = ?', $peticion->getUsername());
$auxU1 = $auxU->fetchOne();
if (!$auxU1) {
$this->redirect('peticion/notificacion');
} else {
$peticion->delete();
$this->getUser()->setFlash('error', 'El nombre de usuario "' . $peticion->getUsername() . '" no esta disponible.', false);
}
} else {
$peticion->delete();
$this->getUser()->setFlash('error', 'El correo electrónico "' . $peticion->getEmailAddress() . '" ya se encuentra registrado.', false);
}
} catch (Exception $e) {
$this->getUser()->setFlash('error', 'El correo electrónico ingresado ya se encuentra registrado.', false);
}
}
}
示例11: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
if (!$request->hasParameter('page')) {
//$this->forward404();
}
$this->page = $request->getParameter('page');
}
示例12: executeImage
public function executeImage(sfWebRequest $request)
{
$member = $this->getRoute()->getMember();
if (!$member) {
return sfView::NONE;
}
$community = Doctrine::getTable('Community')->find($request->getParameter('id'));
if (!$community) {
return sfView::ERROR;
}
$isAdmin = Doctrine::getTable('CommunityMember')->isAdmin($member->getId(), $community->getId());
if (!$isAdmin || $community->getImageFileName()) {
return sfView::ERROR;
}
$message = $request->getMailMessage();
if ($images = $message->getImages()) {
$image = array_shift($images);
$validator = new opValidatorImageFile();
$validFile = $validator->clean($image);
$file = new File();
$file->setFromValidatedFile($validFile);
$file->setName('c_' . $community->getId() . '_' . $file->getName());
$community->setFile($file);
$community->save();
}
return sfView::NONE;
}
示例13: executeGuardar
public function executeGuardar(sfWebRequest $request)
{
$this->datos = $request->getParameter('datos');
$unidadeducativa = Doctrine::getTable('SdatRueUnidadEducativa')->find(array($this->datos['codue'], $this->datos['subcea'], $this->datos['periodo']));
if ($unidadeducativa) {
$conn = Doctrine_Manager::connection();
$conn->beginTransaction();
try {
$unidadeducativa->setTelefono1($this->datos['telefono1']);
$unidadeducativa->setTelefono2($this->datos['telefono2']);
$unidadeducativa->setReferenciaTelefono2($this->datos['referenciatelefono2']);
$unidadeducativa->setFax($this->datos['fax']);
$unidadeducativa->setEmail($this->datos['email']);
$unidadeducativa->setCasilla($this->datos['casilla']);
$unidadeducativa->setCiDirector($this->datos['cidirector']);
$unidadeducativa->setDirector($this->datos['director']);
$unidadeducativa->setItemDirector($this->datos['itemdirector']);
$unidadeducativa->setCodCerradaId($this->datos['cerrada']);
if ($this->datos['turno'] == '-999') {
$unidadeducativa->setTurnoId('0');
} else {
$unidadeducativa->setTurnoId($this->datos['turno']);
}
$unidadeducativa->setFechaConsolidacion(date('Y-m-d H:i:s'));
$unidadeducativa->save();
$conn->commit();
$this->getUser()->setFlash('notice_error', "SE CREO CORRECTAMENTE");
$this->redirect('cea_crear_inicio/index');
} catch (Doctrine_Exception $e) {
$conn->rollback();
$this->getUser()->setFlash('notice_error', "ERROR AL CREAR INICIO DE GESTION DEL CEA");
$this->redirect('cea_crear_inicio/index');
}
}
}
示例14: executeDetails
public function executeDetails(sfWebRequest $request) {
$this->forward404Unless($presta_id = $request->getParameter('id'));
$this->presta = PrestaTable::getInstance()->find($presta_id);
$this->gmap = new GMap();
$this->gmap->addMarker(new GMapMarker($this->presta->getLatitude(), $this->presta->getLongitude()));
$this->gmap->centerAndZoomOnMarkers();
}
示例15: executeSave
public function executeSave(sfWebRequest $request)
{
$request->checkCSRFProtection();
$invoices = (array) $request->getParameter('invoices', array());
$estimates = (array) $request->getParameter('estimates', array());
// check that there is only one template for each one
if (count($invoices) > 1 || count($estimates) > 1) {
$this->getUser()->error($this->getContext()->getI18N()->__('There must be only one template for model.'));
$this->redirect('@templates');
}
$templates = Doctrine::getTable('Template')->createQuery()->execute();
foreach ($templates as $t) {
$models = array();
if (in_array($t->getId(), $invoices)) {
$models[] = 'Invoice';
}
if (in_array($t->getId(), $estimates)) {
$models[] = 'Estimate';
}
$t->setModels(implode(',', $models));
$t->save();
}
$this->getUser()->info($this->getContext()->getI18N()->__('Successfully saved.'));
$this->redirect('@templates');
}