本文整理汇总了PHP中sfWebRequest::getRelativeUrlRoot方法的典型用法代码示例。如果您正苦于以下问题:PHP sfWebRequest::getRelativeUrlRoot方法的具体用法?PHP sfWebRequest::getRelativeUrlRoot怎么用?PHP sfWebRequest::getRelativeUrlRoot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfWebRequest
的用法示例。
在下文中一共展示了sfWebRequest::getRelativeUrlRoot方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeInit
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeInit(sfWebRequest $request)
{
//Check if kernel init went fine:
$this->status = $this->getContext()->get('KernelStatus');
$this->getContext()->getUser()->setAttribute('relativeUrlRoot', $request->getRelativeUrlRoot());
//Add the log entry corresponding to the Kernel status:
$log_ok = $this->getContext()->get('Kernel')->addLogIf(empty($this->status), array('info' => 'Application startup successful', 'error' => 'Application startup failed.'));
//Check if error occured while logging:
if (!$log_ok) {
$this->status['log'] = 'Log files are unreachable, please check permissions on the log directory.';
}
//Edit the databases.yml file:
ParametersConfiguration::editYaml();
//Redirect to the localized homepage if everything went fine:
$usersAuth = new usersAuth();
/*Depending on the user Type (disconnected, admin, viewer), a redirection is done*/
if ($usersAuth->isAdmin()) {
$this->redirectIf(empty($this->status), '@localized_homepage');
} else {
if ($usersAuth->isViewer()) {
$this->redirectIf(empty($this->status), '@localized_homepage');
} else {
$this->redirectIf(empty($this->status), '@authentification');
}
}
}
示例2: executePost
public function executePost(sfWebRequest $request)
{
$this->forward400Unless($request['target'], 'target not specified.');
$this->forward400Unless($request['target_id'], 'target_id not specified.');
$this->forward400Unless($request['member_id'], 'member_id not specified.');
$foreignTable = $request['target'];
$foreignId = $request['target_id'];
$foreignMemberId = $request['member_id'];
$toMember = Doctrine::getTable('Member')->findOneById($foreignMemberId);
$this->forward400Unless($toMember, 'member does not exist.');
$this->forward400If(1 < strlen($foreignTable), 'must be a single character.');
$alreadyLike = Doctrine::getTable('Nice')->isAlreadyNiced($this->memberId, $foreignTable, $foreignId);
$this->forward400If($alreadyLike, 'It has already been registered');
$fromMember = $this->getUser()->getMember();
$baseUrl = $request->getRelativeUrlRoot();
switch ($foreignTable) {
case 'A':
$this->forward400Unless($activity = Doctrine::getTable('ActivityData')->find($foreignId));
$timelineId = $activity->in_reply_to_activity_id ? $activity->in_reply_to_activity_id : $activity->id;
$url = $baseUrl . '/timeline/show/id/' . $timelineId;
break;
case 'D':
$url = $baseUrl . '/diary/' . $foreignId;
break;
case 'd':
$diaryComment = Doctrine::getTable('DiaryComment')->findOneById($foreignId);
$this->forward400Unless($diaryComment, 'diary comment does not exist.');
$url = $baseUrl . '/diary/' . $diaryComment->getDiaryId();
break;
case 'e':
$eventComment = Doctrine::getTable('CommunityEventComment')->findOneById($foreignId);
$this->forward400Unless($eventComment, 'event comment does not exist.');
$url = $baseUrl . '/communityEvent/' . $eventComment->getCommunityEventId();
break;
case 't':
$topicComment = Doctrine::getTable('CommunityTopicComment')->findOneById($foreignId);
$this->forward400Unless($topicComment, 'topic comment does not exist.');
$url = $baseUrl . '/communityTopic/' . $topicComment->getCommunityTopicId();
break;
default:
$url = '#';
break;
}
$like = new Nice();
$like->setMemberId($this->memberId);
$like->setForeignTable($foreignTable);
$like->setForeignId($foreignId);
$like->save();
$this->like = $like;
if ($fromMember->getId() !== $toMember->getId()) {
opLikePluginUtil::sendNotification($fromMember, $toMember, $url);
}
}
示例3: executeIndex
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex(sfWebRequest $request)
{
$this->structure = Doctrine::getTable('Structure')->createQuery('a')->fetchOne();
sfContext::getInstance()->getUser()->setAttribute('relativeUrlRoot', $request->getRelativeUrlRoot());
if ($request->isMethod(sfRequest::POST)) {
/*$context=sfContext::getInstance();*/
$login = $this->getRequestParameter('login');
$password = $this->getRequestParameter('password');
$usersAuth = new usersAuth();
$checked = $usersAuth->verifyAuth($login, $password);
//if the authentification is done
if ($checked == 1 || $checked == 2) {
ParametersConfiguration::setUserPrefix(sfContext::getInstance()->getUser()->getAttribute('login'));
$loginDisplay = ParametersConfiguration::getDefault('default_follow_moderator');
/*According to the 'default_follow_moderator' parameter, the login will appear in logs or not*/
if ($loginDisplay == 1) {
$this->getContext()->get('Kernel')->addLog("info", "Authentification success for the login \"" . $login . "\".");
} else {
$this->getContext()->get('Kernel')->addLog("info", "Authentification success.");
}
//Get the preferred culture of the user, based on those which are installed:
$culture = ParametersConfiguration::getDefault('default_language');
$this->getUser()->setCulture($culture);
$request->setParameter('sf_culture', $culture);
$this->redirect('@localized_homepage');
} else {
if ($checked === 0) {
// this delay complicates a brute force attack
sleep(1);
$this->getUser()->setFlash('error', 'Login or password incorrect. Please try again.', true);
$this->getContext()->get('Kernel')->addLog("error", "Authentification denied for the login \"" . $login . "\".");
} else {
if ($checked === -2) {
$this->getUser()->setFlash('error', 'Login and password are correct but your account is locked.', true);
$this->getContext()->get('Kernel')->addLog("error", "Authentification denied for the login \"" . $login . "\". Account is locked.");
} else {
//The error message is copied in the error log
$this->getContext()->get('Kernel')->addLog("error", "Connection to the database failed:\"" . $checked . "\".");
$this->getUser()->setFlash('error', 'Impossible authentification. Check the connection to the database.', true);
}
}
}
} else {
$this->login = null;
$this->password = null;
}
}
示例4: executeWidgetOuter
public function executeWidgetOuter(sfWebRequest $request)
{
$this->fetchWidget();
$petition = $this->widget['Petition'];
/* @var $petition Petition */
$petition_text = $this->widget['PetitionText'];
/* @var $petition_text PetitionText */
$this->count = $petition->getCount(60);
$this->target = $this->count . '-' . Petition::calcTarget($this->count, $this->widget->getPetition()->getTargetNum());
$image_prefix = ($request->isSecure() ? 'https://' : 'http://') . $request->getHost() . '/' . $request->getRelativeUrlRoot() . 'images/';
$this->kind = $this->widget->getPetition()->getKind();
$this->lang = $this->widget->getPetitionText()->getLanguageId();
$this->getUser()->setCulture($this->lang);
$this->label_mode = $this->widget->getPetition()->getLabelMode();
$stylings = json_decode($this->widget->getStylings(), true);
if (!is_array($stylings)) {
$stylings = array();
}
$widget_colors = $petition->getWidgetIndividualiseDesign();
foreach (array('title_color', 'body_color', 'button_color', 'bg_left_color', 'bg_right_color', 'form_title_color') as $style) {
if (!$widget_colors || !isset($stylings[$style]) || !$stylings[$style]) {
$stylings[$style] = $petition['style_' . $style];
}
}
$this->stylings = $stylings;
$this->keyvisual = $this->widget->getPetition()->getKeyVisual() ? $image_prefix . 'keyvisual/' . $this->widget->getPetition()->getKeyVisual() : null;
$this->sprite = $image_prefix . 'policat.spr.png';
$this->url = $this->getContext()->getRouting()->generate('sign', array('id' => $this->widget['id'], 'hash' => $this->widget->getLastHash(true)), true);
$this->getResponse()->setContentType('text/javascript');
$this->setLayout(false);
$title = $this->widget->getTitle();
if (!$petition->getWidgetIndividualiseText()) {
$title = $petition_text->getTitle();
}
$this->title = Util::enc($title);
}
示例5: smtPost
protected function smtPost(sfWebRequest $request)
{
$this->publicFlags = Doctrine::getTable('Diary')->getPublicFlags();
unset($this->publicFlags[4]);
$this->relativeUrlRoot = $request->getRelativeUrlRoot();
$this->setLayout('smtLayoutSns');
$this->setTemplate('smtPost');
}