本文整理汇总了PHP中eZHTTPTool::instance方法的典型用法代码示例。如果您正苦于以下问题:PHP eZHTTPTool::instance方法的具体用法?PHP eZHTTPTool::instance怎么用?PHP eZHTTPTool::instance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZHTTPTool
的用法示例。
在下文中一共展示了eZHTTPTool::instance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setState
public function setState()
{
$http = eZHTTPTool::instance();
if ($http->hasGetVariable('state')) {
$this->connection->setState(base64_encode($http->getVariable('state')));
}
}
示例2: redirect
/**
* Handles redirection to the mobile optimized interface
*
*/
public function redirect()
{
$http = eZHTTPTool::instance();
$currentSiteAccess = eZSiteAccess::current();
if ($http->hasGetVariable('notmobile')) {
setcookie('eZMobileDeviceDetect', 1, time() + (int) eZINI::instance()->variable('SiteAccessSettings', 'MobileDeviceDetectCookieTimeout'), '/');
$http->redirect(eZSys::indexDir());
eZExecution::cleanExit();
}
if (!isset($_COOKIE['eZMobileDeviceDetect']) && !in_array($currentSiteAccess['name'], eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessList'))) {
$currentUrl = eZSys::serverURL() . eZSys::requestURI();
$redirectUrl = eZINI::instance()->variable('SiteAccessSettings', 'MobileSiteAccessURL');
// Do not redirect if already on the redirect url
if (strpos($currentUrl, $redirectUrl) !== 0) {
// Default siteaccess name needs to be removed from the uri when redirecting
$uri = explode('/', ltrim(eZSys::requestURI(), '/'));
if (array_shift($uri) == $currentSiteAccess['name']) {
$http->redirect($redirectUrl . '/' . implode('/', $uri));
} else {
$http->redirect($redirectUrl . eZSys::requestURI());
}
}
eZExecution::cleanExit();
}
}
示例3: fetchIDListByUserID
static function fetchIDListByUserID($userID)
{
if ($userID == eZUser::anonymousId()) {
$userCache = eZUSer::getUserCacheByAnonymousId();
$ruleArray = $userCache['discount_rules'];
} else {
$http = eZHTTPTool::instance();
$handler = eZExpiryHandler::instance();
$expiredTimeStamp = 0;
if ($handler->hasTimestamp('user-discountrules-cache')) {
$expiredTimeStamp = $handler->timestamp('user-discountrules-cache');
}
$ruleTimestamp =& $http->sessionVariable('eZUserDiscountRulesTimestamp');
$ruleArray = false;
// check for cached version in session
if ($ruleTimestamp > $expiredTimeStamp) {
if ($http->hasSessionVariable('eZUserDiscountRules' . $userID)) {
$ruleArray =& $http->sessionVariable('eZUserDiscountRules' . $userID);
}
}
if (!is_array($ruleArray)) {
$ruleArray = self::generateIDListByUserID((int) $userID);
$http->setSessionVariable('eZUserDiscountRules' . $userID, $ruleArray);
$http->setSessionVariable('eZUserDiscountRulesTimestamp', time());
}
}
$rules = array();
foreach ($ruleArray as $ruleRow) {
$rules[] = $ruleRow['id'];
}
return $rules;
}
示例4: execute
function execute($process, $event)
{
$parameters = $process->attribute('parameter_list');
$http = eZHTTPTool::instance();
eZDebug::writeNotice($parameters, "parameters");
$orderID = $parameters['order_id'];
$order = eZOrder::fetch($orderID);
if (empty($orderID) || get_class($order) != 'ezorder') {
eZDebug::writeWarning("Can't proceed without a Order ID.", "SimpleStockCheck");
return eZWorkflowEventType::STATUS_FETCH_TEMPLATE_REPEAT;
}
// Decrement the quantitity field
$order = eZOrder::fetch($orderID);
$productCollection = $order->productCollection();
$ordereditems = $productCollection->itemList();
foreach ($ordereditems as $item) {
$contentObject = $item->contentObject();
$contentObjectVersion = $contentObject->version($contentObject->attribute('current_version'));
$contentObjectAttributes = $contentObjectVersion->contentObjectAttributes();
foreach (array_keys($contentObjectAttributes) as $key) {
$contentObjectAttribute = $contentObjectAttributes[$key];
$contentClassAttribute = $contentObjectAttribute->contentClassAttribute();
// Each attribute has an attribute identifier called 'quantity' that identifies it.
if ($contentClassAttribute->attribute("identifier") == "quantity") {
$contentObjectAttribute->setAttribute("data_int", $contentObjectAttribute->attribute("value") - $item->ItemCount);
$contentObjectAttribute->store();
}
}
}
return eZWorkflowEventType::STATUS_ACCEPTED;
}
示例5: answer
function answer()
{
if ($this->Answer !== false) {
return $this->Answer;
}
$http = eZHTTPTool::instance();
$prefix = eZSurveyType::PREFIX_ATTRIBUTE;
$postSurveyAnswer = $prefix . '_ezsurvey_answer_' . $this->ID . '_' . $this->contentObjectAttributeID();
if ($http->hasPostVariable($postSurveyAnswer)) {
$surveyAnswer = $http->postVariable($postSurveyAnswer);
return $surveyAnswer;
}
$user = eZUser::instance();
$value = $this->Default;
if ($user->isLoggedIn() === true) {
switch ($this->Text3) {
case "user_email":
$value = $this->userEmail();
break;
case "user_name":
$value = $this->userName();
break;
default:
$value = $this->defaultUserValue();
}
}
return $value;
}
示例6: createClass
static function createClass( $tpl,
$module,
$stepArray,
$basePath,
$storageName = false,
$metaData = false )
{
if ( !$storageName )
{
$storageName = 'eZWizard';
}
if ( !$metaData )
{
$http = eZHTTPTool::instance();
$metaData = $http->sessionVariable( $storageName . '_meta' );
}
if ( !isset( $metaData['current_step'] ) ||
$metaData['current_step'] < 0 )
{
$metaData['current_step'] = 0;
eZDebug::writeNotice( 'Setting wizard step to : ' . $metaData['current_step'], __METHOD__ );
}
$currentStep = $metaData['current_step'];
if ( count( $stepArray ) <= $currentStep )
{
eZDebug::writeError( 'Invalid wizard step count: ' . $currentStep, __METHOD__ );
return false;
}
$filePath = $basePath . $stepArray[$currentStep]['file'];
if ( !file_exists( $filePath ) )
{
eZDebug::writeError( 'Wizard file not found : ' . $filePath, __METHOD__ );
return false;
}
include_once( $filePath );
$className = $stepArray[$currentStep]['class'];
eZDebug::writeNotice( 'Creating class : ' . $className, __METHOD__ );
$returnClass = new $className( $tpl, $module, $storageName );
if ( isset( $stepArray[$currentStep]['operation'] ) )
{
$operation = $stepArray[$currentStep]['operation'];
return $returnClass->$operation();
eZDebug::writeNotice( 'Running : "' . $className . '->' . $operation . '()". Specified in StepArray', __METHOD__ );
}
if ( isset( $metaData['current_stage'] ) )
{
$returnClass->setMetaData( 'current_stage', $metaData['current_stage'] );
eZDebug::writeNotice( 'Setting wizard stage to : ' . $metaData['current_stage'], __METHOD__ );
}
return $returnClass;
}
示例7: getNextItems
/**
* Returns block item XHTML
*
* @param mixed $args
* @return array
*/
public static function getNextItems($args)
{
$http = eZHTTPTool::instance();
$tpl = eZTemplate::factory();
$result = array();
$galleryID = $http->postVariable('gallery_id');
$offset = $http->postVariable('offset');
$limit = $http->postVariable('limit');
$galleryNode = eZContentObjectTreeNode::fetch($galleryID);
if ($galleryNode instanceof eZContentObjectTreeNode) {
$params = array('Depth' => 1, 'Offset' => $offset, 'Limit' => $limit);
$pictureNodes = $galleryNode->subtree($params);
foreach ($pictureNodes as $validNode) {
$tpl->setVariable('node', $validNode);
$tpl->setVariable('view', 'block_item');
$tpl->setVariable('image_class', 'blockgallery1');
$content = $tpl->fetch('design:node/view/view.tpl');
$result[] = $content;
if ($counter === $limit) {
break;
}
}
}
return $result;
}
示例8: fetchAccountInformation
function fetchAccountInformation(&$module)
{
$http = eZHTTPTool::instance();
$http->setSessionVariable('RedirectAfterLogin', '/shop/basket/');
$http->setSessionVariable('DoCheckoutAutomatically', true);
$module->redirectTo('/user/login/');
}
示例9: push
public static function push($args)
{
if (!self::userHasAccessToModule()) {
return self::$noAccessResponse;
}
$http = eZHTTPTool::instance();
if ($http->hasPostVariable('nodeID') && $http->hasPostVariable('accountID')) {
$NGPushIni = eZINI::instance('ngpush.ini');
$NGPushAccount = $http->postVariable('accountID');
$NGPushNodeID = $http->postVariable('nodeID');
switch ($NGPushIni->variable($NGPushAccount, 'Type')) {
case 'twitter':
$TwitterStatus = $http->postVariable('tw_status');
return ngPushTwitterStatus::push($NGPushAccount, $TwitterStatus);
break;
case 'facebook_feed':
$Arguments = array('name' => $http->postVariable('fb_name'), 'description' => $http->postVariable('fb_description'), 'message' => $http->postVariable('fb_message'), 'link' => $http->postVariable('fb_link'), 'picture' => $http->postVariable('fb_picture'));
return ngPushFacebookFeed::push($NGPushAccount, $Arguments);
break;
default:
break;
}
}
return array('status' => 'error', 'message' => 'Account not found!');
}
示例10: requestToken
public function requestToken($Account)
{
$NGPushIni = eZINI::instance('ngpush.ini');
$SiteIni = eZINI::instance('site.ini');
$AccessToken = $NGPushIni->variable($Account, 'AccessToken');
// If access tokens are given
if ($AccessToken) {
//Save request signing tokens to cache
ngPushBase::save_token($Account, $AccessToken, 'main_token');
} else {
$AdministrationUrl = '/';
eZURI::transformURI($AdministrationUrl, false, 'full');
$AdministrationUrl = base64_encode($AdministrationUrl);
$SettingsBlock = base64_encode($Account);
$redirectUrl = 'http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=facebook';
$Facebook = new Facebook(array('appId' => $NGPushIni->variable($Account, 'AppAPIKey'), 'secret' => $NGPushIni->variable($Account, 'AppSecret')));
$Permissions = array('publish_actions', 'user_posts');
if ($NGPushIni->variable($Account, 'EntityType') == 'page') {
$Permissions[] = 'manage_pages';
}
$state = md5(uniqid(rand(), true));
$http = eZHTTPTool::instance();
$http->setSessionVariable('ngpush_state', $state);
$LoginUrl = $Facebook->getLoginUrl(array('redirect_uri' => $redirectUrl, 'scope' => implode($Permissions, ','), 'state' => $state));
self::$response['RequestPermissionsUrl'] = $LoginUrl;
}
}
示例11: sectionEditActionCheck
function sectionEditActionCheck( $module, $class, $object, $version, $contentObjectAttributes, $editVersion, $editLanguage, $fromLanguage )
{
if ( $module->isCurrentAction( 'SectionEdit' ) )
{
$http = eZHTTPTool::instance();
if ( $http->hasPostVariable( 'SelectedSectionId' ) )
{
$selectedSectionID = (int) $http->postVariable( 'SelectedSectionId' );
$selectedSection = eZSection::fetch( $selectedSectionID );
if ( is_object( $selectedSection ) )
{
$currentUser = eZUser::currentUser();
if ( $currentUser->canAssignSectionToObject( $selectedSectionID, $object ) )
{
$db = eZDB::instance();
$db->begin();
$assignedNodes = $object->attribute( 'assigned_nodes' );
if ( count( $assignedNodes ) > 0 )
{
foreach ( $assignedNodes as $node )
{
if ( eZOperationHandler::operationIsAvailable( 'content_updatesection' ) )
{
$operationResult = eZOperationHandler::execute( 'content',
'updatesection',
array( 'node_id' => $node->attribute( 'node_id' ),
'selected_section_id' => $selectedSectionID ),
null,
true );
}
else
{
eZContentOperationCollection::updateSection( $node->attribute( 'node_id' ), $selectedSectionID );
}
}
}
else
{
// If there are no assigned nodes we should update db for the current object.
$objectID = $object->attribute( 'id' );
$db->query( "UPDATE ezcontentobject SET section_id='$selectedSectionID' WHERE id = '$objectID'" );
$db->query( "UPDATE ezsearch_object_word_link SET section_id='$selectedSectionID' WHERE contentobject_id = '$objectID'" );
}
$object->expireAllViewCache();
$db->commit();
}
else
{
eZDebug::writeError( "You do not have permissions to assign the section <" . $selectedSection->attribute( 'name' ) .
"> to the object <" . $object->attribute( 'name' ) . ">." );
}
$module->redirectToView( 'edit', array( $object->attribute( 'id' ), $editVersion, $editLanguage, $fromLanguage ) );
}
}
}
}
示例12: suggest
/**
* Provides suggestion results when adding tags to object
*
* @static
* @param mixed $args
* @return array
*/
public static function suggest($args)
{
$tags = array();
$siteINI = eZINI::instance('site.ini');
if ($siteINI->variable('SearchSettings', 'SearchEngine') == 'ezsolr' && class_exists('eZSolr')) {
$tagsCount = 1;
$filteredTagsArray = array();
$http = eZHTTPTool::instance();
$tagsString = $http->postVariable('tags_string');
$tagsArray = explode('|#', $tagsString);
$subTreeLimit = $http->postVariable('subtree_limit');
$hideRootTag = $http->postVariable('hide_root_tag') == '1' ? true : false;
if (!empty($tagsArray) && strlen(trim($tagsArray[0])) > 0) {
$solrFilter = '"' . trim($tagsArray[0]) . '"';
$filteredTagsArray[] = strtolower(trim($tagsArray[0]));
for ($i = 1; $i < count($tagsArray); $i++) {
if (strlen(trim($tagsArray[$i])) > 0) {
$solrFilter = $solrFilter . ' OR "' . trim($tagsArray[$i]) . '"';
$filteredTagsArray[] = strtolower(trim($tagsArray[$i]));
$tagsCount++;
}
}
$solrFilter = 'ezf_df_tags:(' . $solrFilter . ')';
$solrSearch = new eZSolr();
$params = array('SearchOffset' => 0, 'SearchLimit' => 0, 'Facet' => array(array('field' => 'ezf_df_tags', 'limit' => 5 + $tagsCount, 'mincount', 1)), 'SortBy' => null, 'Filter' => $solrFilter, 'QueryHandler' => 'ezpublish', 'FieldsToReturn' => null);
$searchResult = $solrSearch->search('', $params);
$facetResult = $searchResult['SearchExtras']->attribute('facet_fields');
$facetResult = $facetResult[0]['nameList'];
$tags = array();
foreach ($facetResult as $facetValue) {
if (!in_array(strtolower($facetValue), $filteredTagsArray)) {
$tags[] = trim($facetValue);
}
}
if (!empty($tags)) {
$tags = eZTagsObject::fetchByKeyword(array($tags));
}
}
}
$returnArray = array();
$returnArray['status'] = 'success';
$returnArray['message'] = '';
$returnArray['tags'] = array();
foreach ($tags as $tag) {
if (!$subTreeLimit > 0 || $subTreeLimit > 0 && strpos($tag->attribute('path_string'), '/' . $subTreeLimit . '/') !== false) {
if (!$hideRootTag || $hideRootTag && $tag->attribute('id') != $subTreeLimit) {
$returnArrayChild = array();
$returnArrayChild['tag_parent_id'] = (int) $tag->attribute('parent_id');
$returnArrayChild['tag_parent_name'] = $tag->hasParent() ? $tag->getParent()->attribute('keyword') : '';
$returnArrayChild['tag_name'] = $tag->attribute('keyword');
$returnArrayChild['tag_id'] = (int) $tag->attribute('id');
$returnArray['tags'][] = $returnArrayChild;
}
}
}
return $returnArray;
}
示例13: processAuth
/**
* This method is used to process the second part of authentication workflow, after redirect
*
* @return array Array with status and user details
*/
public function processAuth()
{
$ngConnectINI = eZINI::instance('ngconnect.ini');
$http = eZHTTPTool::instance();
$consumerKey = trim($ngConnectINI->variable('LoginMethod_twitter', 'AppConsumerKey'));
$consumerSecret = trim($ngConnectINI->variable('LoginMethod_twitter', 'AppConsumerSecret'));
if (empty($consumerKey) || empty($consumerSecret)) {
return array('status' => 'error', 'message' => 'Consumer key or consumer secret undefined.');
}
$oAuthToken = trim($http->getVariable('oauth_token', ''));
$oAuthVerifier = trim($http->getVariable('oauth_verifier', ''));
$state = trim($http->getVariable('state', ''));
if (empty($oAuthToken) || empty($oAuthVerifier) || empty($state)) {
return array('status' => 'error', 'message' => 'oauth_token, oauth_verifier or state GET parameters undefined.');
}
if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) {
$http->removeSessionVariable('NGConnectOAuthState');
return array('status' => 'error', 'message' => 'State parameter does not match stored value.');
} else {
$http->removeSessionVariable('NGConnectOAuthState');
}
if (!$http->hasSessionVariable('NGConnectOAuthToken') || !$http->hasSessionVariable('NGConnectOAuthTokenSecret') || $oAuthToken != $http->sessionVariable('NGConnectOAuthToken')) {
$http->removeSessionVariable('NGConnectOAuthToken');
$http->removeSessionVariable('NGConnectOAuthTokenSecret');
return array('status' => 'error', 'message' => 'Token does not match stored value.');
} else {
$oAuthTokenSecret = $http->sessionVariable('NGConnectOAuthTokenSecret');
$http->removeSessionVariable('NGConnectOAuthToken');
$http->removeSessionVariable('NGConnectOAuthTokenSecret');
}
$connection = new TwitterOAuth($consumerKey, $consumerSecret, $oAuthToken, $oAuthTokenSecret);
$connection->host = self::TWITTER_API_URI;
$accessToken = $connection->getAccessToken($oAuthVerifier);
if (!(isset($accessToken['oauth_token']) && isset($accessToken['oauth_token_secret']))) {
return array('status' => 'error', 'message' => 'Error while retrieving access token.');
}
$connection = new TwitterOAuth($consumerKey, $consumerSecret, $accessToken['oauth_token'], $accessToken['oauth_token_secret']);
$connection->host = self::TWITTER_API_URI;
$user = $connection->get(self::TWITTER_USER_API_URI);
if (!isset($user->id) || empty($user->id)) {
return array('status' => 'error', 'message' => 'Invalid Twitter user.');
}
if (isset($user->profile_image_url) && !empty($user->profile_image_url)) {
$pictureUri = $user->profile_image_url;
$imageSize = trim($ngConnectINI->variable('LoginMethod_twitter', 'ImageSize'));
if ($imageSize == 'original') {
//Hm... it seems there's no way to get the full size image through API
//Even https://api.twitter.com/1/users/profile_image/username never returns full version
//Replacing is not safe, but at least we're replacing last occurrence
$pictureUri = substr_replace($user->profile_image_url, '', strrpos($user->profile_image_url, '_normal'), 7);
}
} else {
$pictureUri = '';
}
$result = array('status' => 'success', 'login_method' => 'twitter', 'id' => $user->id, 'first_name' => isset($user->name) ? $user->name : '', 'last_name' => '', 'email' => '', 'picture' => $pictureUri);
return $result;
}
示例14: run
/**
* @return array
*/
public function run()
{
$result = array();
$http = eZHTTPTool::instance();
$action = $http->getVariable('action', false);
$parameters = $http->getVariable('parameters', false);
$result['request'] = array('action' => $action, 'parameters' => $parameters);
$result['response'] = call_user_func(array($this, $action), $parameters);
return $result;
}
示例15: processAuth
/**
* This method is used to process the second part of authentication workflow, after redirect
*
* @return array Array with status and user details
*/
public function processAuth()
{
$ngConnectINI = eZINI::instance('ngconnect.ini');
$http = eZHTTPTool::instance();
$appID = trim($ngConnectINI->variable('LoginMethod_facebook', 'FacebookAppID'));
$appSecret = trim($ngConnectINI->variable('LoginMethod_facebook', 'FacebookAppSecret'));
if (empty($appID) || empty($appSecret)) {
return array('status' => 'error', 'message' => 'Facebook app ID or Facebook app secret undefined.');
}
$code = trim($http->getVariable('code', ''));
$state = trim($http->getVariable('state', ''));
if (empty($code) || empty($state)) {
return array('status' => 'error', 'message' => 'code or state GET parameters undefined.');
}
if (!$http->hasSessionVariable('NGConnectOAuthState') || $state != $http->sessionVariable('NGConnectOAuthState')) {
$http->removeSessionVariable('NGConnectOAuthState');
return array('status' => 'error', 'message' => 'State parameter does not match stored value.');
} else {
$http->removeSessionVariable('NGConnectOAuthState');
}
$callbackUri = self::CALLBACK_URI_PART;
$loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType'));
if ($loginWindowType == 'popup') {
$callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART;
}
eZURI::transformURI($callbackUri, false, 'full');
$tokenUri = str_replace(array('%app_id%', '%site_url%', '%app_secret%', '%code%'), array(urlencode($appID), urlencode($callbackUri), urlencode($appSecret), urlencode($code)), self::TOKEN_URI);
$accessToken = ngConnectFunctions::fetchDataFromUrl($tokenUri);
if (!$accessToken) {
return array('status' => 'error', 'message' => 'Error while retrieving access token.');
}
$accessTokenJson = json_decode($accessToken, true);
if ($accessTokenJson !== null) {
return array('status' => 'error', 'message' => $accessTokenJson['error']['message']);
}
$graphUri = str_replace(array('%access_token%'), array(trim($accessToken)), self::GRAPH_URI);
$graphResponse = ngConnectFunctions::fetchDataFromUrl($graphUri);
if (!$graphResponse) {
return array('status' => 'error', 'message' => 'Error while retrieving graph response.');
}
$user = json_decode($graphResponse, true);
if ($user === null) {
return array('status' => 'error', 'message' => 'Invalid JSON data returned.');
}
if (!isset($user['id'])) {
return array('status' => 'error', 'message' => 'Invalid Facebook user.');
}
$pictureUri = self::PICTURE_URI;
$imageSize = trim($ngConnectINI->variable('LoginMethod_facebook', 'ImageSize'));
if ($imageSize == 'original') {
$pictureUri = $pictureUri . '?type=large';
}
$result = array('status' => 'success', 'login_method' => 'facebook', 'id' => $user['id'], 'first_name' => isset($user['first_name']) ? $user['first_name'] : '', 'last_name' => isset($user['last_name']) ? $user['last_name'] : '', 'email' => isset($user['email']) ? $user['email'] : '', 'picture' => str_replace('%user_id%', $user['id'], $pictureUri));
return $result;
}