本文整理汇总了PHP中sfWebRequest::isXmlHttpRequest方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest::isXmlHttpRequest方法的具体用法?PHP sfWebRequest::isXmlHttpRequest怎么用?PHP sfWebRequest::isXmlHttpRequest使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWebRequest
的用法示例。
在下文中一共展示了sfWebRequest::isXmlHttpRequest方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeDelete
/**
* Удалить изображение
*/
public function executeDelete(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$image = $this->getRoute()->getObject();
$image->delete();
return sfView::HEADER_ONLY;
}
示例2: executeSignin
public function executeSignin(sfWebRequest $request)
{
$user = $this->getUser();
if ($user->isAuthenticated()) {
return $this->redirect('@homepage');
}
$class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
$this->form = new $class();
if ($request->isMethod('post')) {
$this->form->bind($request->getParameter('signin'));
if ($this->form->isValid()) {
$values = $this->form->getValues();
$remember = isset($values['remember']) ? $values['remember'] : false;
$this->getUser()->signin($values['user'], $remember);
$signinUrl = sfConfig::get('app_sf_guard_plugin_success_signin_url', $user->getReferer($request->getReferer()));
return $this->redirect('' != $signinUrl ? $signinUrl : '@homepage');
}
} else {
if ($request->isXmlHttpRequest()) {
$this->getResponse()->setHeaderOnly(true);
$this->getResponse()->setStatusCode(401);
return sfView::NONE;
}
$user->setReferer($request->getReferer());
$module = sfConfig::get('sf_login_module');
if ($this->getModuleName() != $module) {
return $this->redirect($module . '/' . sfConfig::get('sf_login_action'));
}
$this->getResponse()->setStatusCode(401);
}
}
示例3: executeCreate
/**
* Зарегистрировать
*/
public function executeCreate(sfWebRequest $request)
{
$this->executeSignup();
$this->form->bind($request->getParameter($this->form->getName()));
if ($this->form->isValid()) {
$user = $this->form->save();
$loginzaData = $this->getUser()->getAttribute('loginza.identity', false, 'loginza');
// связываем юзера с идентификатором
$identity = new Identity();
$identity->setIdentity($loginzaData['identity']);
$identity->setProvider($loginzaData['provider']);
$identity->setUser($user);
$identity->save();
$this->getUser()->setAttribute('identity.id', $identity->getId());
// авторизуем
$this->getUser()->signin($user, true);
}
if (!$this->form->hasErrors()) {
if ($request->isXmlHttpRequest()) {
return $this->renderText("<script type='text/javascript'>window.location.href='/';</script>");
} else {
return $this->redirect('homepage');
}
}
$this->setTemplate('signup');
}
示例4: executePit
public function executePit(sfWebRequest $request)
{
if ($request->isXmlHttpRequest())
{
return $this->renderText('No results.');
}
}
示例5: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->class = $request->getParameter('class');
if (empty($this->class)) {
$this->class = $request->getGetParameter('class');
}
$this->method = $request->getParameter('method');
if (empty($this->method)) {
$this->method = $request->getGetParameter('method');
}
if (!empty($this->method)) {
$this->class = array($this->class, $this->method);
}
$this->viewer = new sfCodeViewer($this->class);
if ($request->isXmlHttpRequest()) {
sfProjectConfiguration::getActive()->loadHelpers('Url');
$this->renderText($this->viewer->render(url_for('sfCodeView')));
return sfView::NONE;
} else {
// maintain history
$this->history = $this->getUser()->getAttribute('history', array());
if (false !== ($index = array_search($this->class, $this->history))) {
unset($this->history[$index]);
}
array_unshift($this->history, $this->class);
array_splice($this->history, 10);
$this->getUser()->setAttribute('history', $this->history);
}
}
示例6: executeSingle
/**
* Single notification
* @param sfWebRequest $request
*/
public function executeSingle(sfWebRequest $request)
{
$this->notification = $this->getRoute()->getObject();
$this->forward404Unless($this->notification->belongs_to($this->user));
$this->notification->read();
$this->ajax_mode = $request->isXmlHttpRequest();
}
示例7: executeNovaPagina
public function executeNovaPagina(sfWebRequest $request)
{
if ($request->isXmlHttpRequest() || true) {
//apenas por ajax
sfConfig::set('sf_web_debug', false);
sfProjectConfiguration::getActive()->loadHelpers(array('I18N', 'Date'));
$cmspage = new Cmspage();
$content = new Content();
$content->setId(null);
$cmspage->setContent($content);
$cmspage->setId(null);
$cmsGroupcontent = $this->getUser()->getAttribute('contentGroup');
$this->forward404Unless($cmsGroupcontent);
$cmspage->setCmsgroupcontent($cmsGroupcontent);
$this->formContent = new PageContentForm($cmspage);
if ($request->isMethod('post')) {
//return $this->renderPartial('cms/debug',array('values'=>$request->getParameter('pagina')));
$this->formContent->bind($request->getParameter('pagina'));
if ($this->formContent->isValid()) {
$this->logMessage('O formContent foi válido. cms/actions: ' . __FILE__ . __LINE__);
try {
$this->formContent->save();
return $this->renderPartial("cms/viewPage", array('page' => $this->formContent->getCmspageobj(), 'isNew' => true, 'values' => $this->formContent->getValues()));
} catch (Exception $e) {
//TODO: We should to handle the error and render it.
throw $e;
}
//return $this->renderPartial("cms/viewPage",array('page'));
}
}
//parent::executeNew($request);
return $this->renderPartial('cms/content_form', array('formContent' => $this->formContent));
}
}
示例8: executeQuery
public function executeQuery(sfWebRequest $request)
{
if ($request->isXmlHttpRequest()) {
if ($request->isMethod(sfRequest::GET)) {
$startDate = $request->getGetParameter('startDate');
$endDate = $request->getGetParameter('endDate');
$page = $request->getGetParameter('page');
$start = $request->getGetParameter('start');
$limit = $request->getGetParameter('limit');
$this->convertParamToDateTime($startDate);
$this->convertParamToDateTime($endDate);
$result = Doctrine_Core::getTable('Appointment')->getBetween($startDate, $endDate);
$response = $this->buildResponse($result, "Loading Record");
} else {
if ($request->isMethod(sfRequest::POST)) {
$form_data = json_decode(file_get_contents('php://input'));
$location = $form_data->loc;
$title = $form_data->title;
$notes = $form_data->notes;
$url = $form_data->url;
$reminder = $form_data->rem;
$cid = $form_data->cid;
$startDate = str_replace('T', ' ', $form_data->start);
$endDate = str_replace('T', ' ', $form_data->end);
$this->convertParamToDateTime($startDate, 'Y-m-d H:i:s');
$this->convertParamToDateTime($endDate, 'Y-m-d H:i:s');
$a = new Appointment();
$a->fromArray(array('coach_id' => 1, 'client_id' => 1, 'calendar_type_id' => $cid, 'scheduled' => $startDate, 'started_at' => $startDate, 'finished_at' => $endDate, 'title' => $title, 'location' => $location, 'notes' => $notes, 'web_link' => $url, 'reminder' => $reminder));
$a->save();
$response = $this->buildResponse($a, "Creating Record");
} else {
if ($request->isMethod(sfRequest::PUT)) {
$form_data = json_decode(file_get_contents('php://input'));
$location = $form_data->loc;
$title = $form_data->title;
$notes = $form_data->notes;
$url = $form_data->url;
$reminder = $form_data->rem;
$cid = $form_data->cid;
$startDate = str_replace('T', ' ', $form_data->start);
$endDate = str_replace('T', ' ', $form_data->end);
$this->convertParamToDateTime($startDate, 'Y-m-d H:i:s');
$this->convertParamToDateTime($endDate, 'Y-m-d H:i:s');
$a = Doctrine_Core::getTable('Appointment')->find(array($request->getParameter('id')));
$a->fromArray(array('coach_id' => 1, 'client_id' => 1, 'calendar_type_id' => $cid, 'scheduled' => $startDate, 'started_at' => $startDate, 'finished_at' => $endDate, 'title' => $title, 'location' => $location, 'notes' => $notes, 'web_link' => $url, 'reminder' => $reminder));
$a->save();
$response = $this->buildResponse($a, "Updating Record");
} else {
if ($request->isMethod(sfRequest::DELETE)) {
$app = Doctrine_Core::getTable('Appointment')->find(array($request->getParameter('id')));
$app->delete();
$response = array('success' => true, 'message' => 'Destroyed Record', 'data' => array());
}
}
}
}
sfConfig::set('sf_web_debug', false);
return $this->renderPartial('global/ajax', array('ajax' => json_encode($response)));
}
}
示例9: executeUpdate
public function executeUpdate(sfWebRequest $request)
{
if ($this->getUser()->hasCredential('admin')) {
$this->a_event = $this->getRoute()->getObject();
} else {
$this->a_event = Doctrine::getTable('aEvent')->findOneEditable($request->getParameter('id'), $this->getUser()->getGuardUser()->getId());
}
$this->forward404Unless($this->a_event);
$this->form = $this->configuration->getForm($this->a_event);
if ($request->isXmlHttpRequest()) {
$this->setLayout(false);
$response = array();
$this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
if ($this->form->isValid()) {
$this->a_event = $this->form->save();
//We need to recreate the form to handle the fact that it is not possible to change the value of a sfFormField
$this->form = $this->configuration->getForm($this->a_event);
$this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $this->a_event)));
}
$response['errors'] = $this->form->getErrorSchema()->getErrors();
aPageTable::queryWithTitles()->addWhere('page_id = ?', $this->a_event['page_id'])->execute();
$response['aBlogPost'] = $this->a_event->toArray();
$response['aBlogPost']['title'] = html_entity_decode($response['aBlogPost']['title'], ENT_COMPAT, 'UTF-8');
$response['modified'] = $this->a_event->getLastModified();
$response['time'] = aDate::time($this->a_event['updated_at']);
//Any additional messages can go here
$output = json_encode($response);
$this->getResponse()->setHttpHeader("X-JSON", '(' . $output . ')');
return sfView::HEADER_ONLY;
} else {
$this->processForm($request, $this->form);
}
$this->setTemplate('edit');
}
示例10: executeSearchLocation
public function executeSearchLocation(sfWebRequest $request)
{
if ($request->isXmlHttpRequest()) {
$lat = $request->getParameter("lat");
$lng = $request->getParameter("lng");
$sql = "SELECT *, \r\n\t (\r\n\t asin(\r\n\t POW(sin((RADIANS(latitude)-RADIANS({$lat}))/2),2) + \r\n\t ( cos(RADIANS(latitude)) * cos(RADIANS({$lat})) * POW(sin( (RADIANS(longitude) - RADIANS({$lng})) / 2 ),2) )\r\n\t )\r\n\t * 2 * 6367000) AS haversineDistance\r\n\t FROM photographer_region WHERE 1\r\n\t ORDER BY haversineDistance ASC LIMIT 25";
$connection = Propel::getConnection();
$statement = $connection->prepare($sql);
$statement->execute();
$objects = array();
while ($resultset = $statement->fetch(PDO::FETCH_OBJ)) {
$p = PhotographerPeer::retrieveByPK($resultset->photographer_id);
$arr = array();
$arr["latitude"] = $resultset->latitude;
$arr["longitude"] = $resultset->longitude;
$arr["address"] = $resultset->address;
$arr["photographer_name"] = $p->getName();
$arr["distance"] = $resultset->haversineDistance;
$arr["link"] = sfContext::getInstance()->getRouting()->generate("photographer_view", array("slug" => $p->getSlug()));
$objects[] = $arr;
}
$this->renderText(json_encode($objects));
return sfView::NONE;
}
}
示例11: executeSearch
public function executeSearch(sfWebRequest $request)
{
$this->forwardUnless($this->luceneQuery = $request->getParameter('query'), 'dsMailing', 'index');
//$this->jobs = Doctrine_Core::getTable('dsPerson')->getForLuceneQuery($query);
// $this->pager = $this->getPager();
$ds_class_letter_drafts = Doctrine_Core::getTable('dsClassLetter')
->addDraftQuery( $this->getBaseQuery() )
->execute();
$ds_class_letter_sent = Doctrine_Core::getTable('dsClassLetter')
->addSentQuery( $this->getBaseQuery() )
->execute();
if ($request->isXmlHttpRequest())
{
if ('*' == $this->luceneQuery || !($ds_class_letter_drafts || $ds_class_letter_sent))
{
return $this->renderText('No results.');
}
return $this->renderPartial('dsMailing/list',
array(
//'pager' => $this->pager,
'ds_class_letter_drafts' => $ds_class_letter_drafts
,'ds_class_letter_sent' => $ds_class_letter_sent
,'helper' => $this->helper));
}
}
示例12: executeShow
public function executeShow(sfWebRequest $request)
{
$this->photo = Doctrine_Core::getTable('Photo')->findOneBySlug($request->getParameter('photo_slug'));
$this->ajax = $request->isXmlHttpRequest();
$uploadDir = sfConfig::get('sf_upload_dir') . '/photo/';
$this->image = new sfImage($uploadDir . $this->photo->path, swImageTransform::mime_content_type($uploadDir . $this->photo->path));
}
示例13: executeSelect
public function executeSelect(sfWebRequest $request)
{
if ($request->isXmlHttpRequest()) {
// steps 1-3 requests & restart
$this->setLayout(false);
sfProjectConfiguration::getActive()->loadHelpers('Partial');
$agent = new CircuitBreakerSelectionAgent($request->getGetParameters());
if ($data = $agent->executeStep()) {
$partial = 'filter' . ucfirst($request->getParameter('step')) . 'Step';
$html = get_partial($partial, array('selection' => $request->getParameter($request->getParameter('step'), NULL), 'back_qs' => $data['back_qs'], 'data' => $data['data'], 'results_so_far' => $data['results_so_far'], 'search_params' => $agent->getSearchParameters()));
} else {
/*
* Would only get here if LWS DB is incomplete.
* In this case we need to use the query string to retrieve the relevant
* data set from teh DB and then fill in the missing values.
*
* Do not throw 404 from Ajax request,
* just send error messgae back to user.
*
* !! I should log the query string in these cases to facilitate
* updating of DB.
*/
$html = "<p id='tech_prob'>Sorry, we our experiencing technical difficulties. Please contact technical support at <a href='mailto:webmaster@livewiresupply.com'>webmaster@livewiresupply.com</a></p>";
}
$response = $this->getResponse();
$response->addCacheControlHttpHeader('no-cache');
$response->setContentType('text/html');
$response->sendHttpHeaders();
return $this->renderText($html);
} else {
// ONLY FOR VOLTS/LAST STEP, or graceful degradation for non JavaScript enabled browsers
$this->manuf_slug = LWS::getManufSlug($request->getParameter('manuf_id'));
$this->manuf = LWS::unslugify($this->manuf_slug, true);
$template = 'Filter' . ucfirst($request->getParameter('step')) . 'Step';
$this->selection = $request->getParameter($request->getParameter('step'));
$agent = new CircuitBreakerSelectionAgent($request->getGetParameters());
/*
* $agent would not return data only if LWS DB is incomplete.
* Sequence of steps dictate that once LWS DB is complete,
* server should throw a 404. User may have be url surfing.
*
* !!! be sure to update DB if necessary.
*/
$this->forward404Unless($this->data = $agent->executeStep());
if ($request->getParameter('step') == 'volts') {
$this->redirect("@part?cat_slug=circuit-breakers&manuf_slug={$this->manuf_slug}&part_no=" . LWS::encode($this->data[0]['part']['part_no']));
} else {
// remove unecessary ajax 'back a step' query string from end of data array
unset($this->data['back_qs']);
$this->results_so_far = $this->data['results_so_far'];
$this->data = $this->data['data'];
$this->search_params = $agent->getSearchParameters();
$response = $this->getResponse();
$response->setTitle("{$this->manuf} Circuit Breakers Selection Process");
$response->setSlot('body_class', 'cb_manuf');
return $template;
}
}
}
示例14: executeAdd
public function executeAdd(sfWebRequest $request)
{
$this->forward404unless($request->isXmlHttpRequest());
$number = intval($request->getParameter("num"));
$this->form = new SportForm();
$this->form->addNewFields($number);
return $this->renderPartial('addNew', array('form' => $this->form, 'number' => $number));
}
示例15: executeDelete
/**
* Executes delete action
*
* @param sfWebRequest $request A request object
* @return string
*/
public function executeDelete(sfWebRequest $request)
{
$this->forward404Unless($request->isXmlHttpRequest());
$this->getRoute()->getObject()->delete();
$this->setLayout(false);
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
return $this->renderText(json_encode(true));
}