本文整理汇总了PHP中eZURI::transformURI方法的典型用法代码示例。如果您正苦于以下问题:PHP eZURI::transformURI方法的具体用法?PHP eZURI::transformURI怎么用?PHP eZURI::transformURI使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZURI
的用法示例。
在下文中一共展示了eZURI::transformURI方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getRedirectUri
/**
* This method is used to process the first part of authentication workflow, before redirect
*
* @return array Array with status and redirect URI
*/
public function getRedirectUri()
{
$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.');
}
$callbackUri = self::CALLBACK_URI_PART;
$loginWindowType = trim($ngConnectINI->variable('ngconnect', 'LoginWindowType'));
if ($loginWindowType == 'popup') {
$callbackUri = '/layout/set/ngconnect' . self::CALLBACK_URI_PART;
}
$state = md5(session_id() . (string) time());
$http->setSessionVariable('NGConnectOAuthState', $state);
$callbackUri .= '?state=' . $state;
eZURI::transformURI($callbackUri, false, 'full');
$connection = new TwitterOAuth($consumerKey, $consumerSecret);
$connection->host = self::TWITTER_API_URI;
$tempCredentials = $connection->getRequestToken($callbackUri);
$redirectUri = $connection->getAuthorizeURL($tempCredentials);
if (!$redirectUri) {
return array('status' => 'error', 'message' => 'Invalid redirection URI.');
}
$http->setSessionVariable('NGConnectOAuthToken', $tempCredentials['oauth_token']);
$http->setSessionVariable('NGConnectOAuthTokenSecret', $tempCredentials['oauth_token_secret']);
return array('status' => 'success', 'redirect_uri' => $redirectUri);
}
示例2: message
public static function message($publishHandler, eZContentObject $object, $message, $messageLength = null, $options)
{
$url = false;
if (isset($options['include_url']) && (bool) $options['include_url'] === true) {
$url = $object->attribute('main_node')->attribute('url_alias');
eZURI::transformURI($url, true, 'full');
if (isset($options['shorten_url']) && (bool) $options['shorten_url'] === true) {
$urlReturned = $publishHandler->shorten($url, $options['shorten_handler']);
if (is_string($urlReturned)) {
$url = $urlReturned;
}
}
if ($messageLength != null) {
$messageLength = $messageLength - strlen($url) - 1;
}
}
if (class_exists('Normalizer')) {
$message = Normalizer::normalize($message, Normalizer::FORM_C);
}
if ($messageLength != null) {
$message = mb_substr($message, 0, $messageLength);
}
if ($url) {
$message .= ' ' . $url;
}
return $message;
}
示例3: 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;
}
}
示例4: getLoginURL
public function getLoginURL(array $scopes = null, $redirectURL = null)
{
eZURI::transformURI($redirectURL, false, 'full');
$connection = $this->getFacebookConnection();
$params = array('scope' => implode(', ', $scopes), 'redirect_uri' => $redirectURL);
return $connection->getLoginUrl($params);
}
示例5: feZMetaData_ContentActionHandler
function feZMetaData_ContentActionHandler( &$module, &$http, &$objectID )
{
// Action when user clicks on the Add Button
if( $http->hasPostVariable( 'AddMetaDataButton' ) )
{
$link = 'fezmetadata/edit/0/(contentObjectID)/'.$objectID;
$link .= '/(metaDataName)/'.$_POST['metaDataName'];
$link .= '/(language)/'.$_POST['language'];
eZURI::transformURI( $link );
$http->redirect( $link );
}
// Action when user clicks on the Remove Button
if( $http->hasPostVariable( 'RemoveMetaDataButton' ) and $http->hasPostVariable( 'MetaDataIDSelection' ) )
{
$metaDataSelection = $http->postVariable( 'MetaDataIDSelection' );
foreach( $metaDataSelection as $metaData )
{
$metaDataObject = feZMetaData::fetch( $metaData );
$metaDataObject->remove();
}
eZContentCacheManager::clearContentCache( $objectID );
$ContentObject = eZContentObject::fetch( $objectID );
$ContentNodeID = $ContentObject->mainNodeID();
return $module->redirect( 'content', 'view', array( 'full', $ContentNodeID ) );
}
}
示例6: requestToken
public function requestToken($Account)
{
$NGPushIni = eZINI::instance('ngpush.ini');
$ConsumerKey = $NGPushIni->variable($Account, 'ConsumerKey');
$ConsumerSecret = $NGPushIni->variable($Account, 'ConsumerSecret');
$AccessToken = $NGPushIni->variable($Account, 'AccessToken');
$AccessTokenSecret = $NGPushIni->variable($Account, 'AccessTokenSecret');
// If access tokens are given
if ($AccessToken && $AccessTokenSecret) {
// Save request signing tokens to cache
ngPushBase::save_token($Account, $AccessToken, 'request_sign_oauth_token');
ngPushBase::save_token($Account, $AccessTokenSecret, 'request_sign_oauth_token_secret');
ngPushBase::save_token($Account, $AccessToken . '%%%' . $AccessTokenSecret, 'main_token');
} else {
$connection = new TwitterOAuth($ConsumerKey, $ConsumerSecret);
$connection->host = "https://api.twitter.com/1.1/";
$AdministrationUrl = '/';
eZURI::transformURI($AdministrationUrl, false, 'full');
$AdministrationUrl = base64_encode($AdministrationUrl);
$SettingsBlock = base64_encode($Account);
$temporary_credentials = $connection->getRequestToken('http://' . $NGPushIni->variable('PushNodeSettings', 'ConnectURL') . '/redirect.php/' . $AdministrationUrl . '/' . $SettingsBlock . '?case=twitter');
// Save request signing tokens to cache
ngPushBase::save_token($Account, $temporary_credentials['oauth_token'], 'request_sign_oauth_token');
ngPushBase::save_token($Account, $temporary_credentials['oauth_token_secret'], 'request_sign_oauth_token_secret');
$redirect_url = $connection->getAuthorizeURL($temporary_credentials, FALSE);
self::$response['RequestPermissionsUrl'] = $redirect_url;
}
}
示例7: parse
protected function parse()
{
$urlAlias = '/' . $this->rawResult['main_url_alias'];
eZURI::transformURI($urlAlias, false, 'full');
$this->data = array('id' => $this->rawResult['id'], 'name' => $this->rawResult['name'], 'class_identifier' => $this->rawResult['class_identifier'], 'main_node_id' => $this->rawResult['main_node_id'], 'href' => $urlAlias);
$fromDate = self::getDateTime($this->rawResult['fields']['attr_from_time_dt']);
if (!$fromDate instanceof DateTime) {
throw new Exception("Value of 'attr_from_time_dt' not a valid date");
}
$this->data['fromDateTime'] = $fromDate;
$this->data['from'] = $fromDate->getTimestamp();
$this->data['identifier'] = $fromDate->format(OpenPACalendarData::FULLDAY_IDENTIFIER_FORMAT);
if (isset($this->rawResult['fields']['attr_to_time_dt'])) {
$toDate = self::getDateTime($this->rawResult['fields']['attr_to_time_dt']);
if (!$toDate instanceof DateTime) {
throw new Exception("Param 'attr_to_time_dt' is not a valid date");
}
if ($toDate->getTimestamp() == 0) {
$toDate = $this->fakeToTime($this->data['fromDateTime']);
}
} else {
$toDate = $this->fakeToTime($this->data['fromDateTime']);
}
$this->data['toDateTime'] = $toDate;
$this->data['to'] = $toDate->getTimestamp();
$this->data['duration'] = $this->data['to'] - $this->data['from'];
$this->isValid = $this->isValid();
}
示例8: getMetadataByLocation
/**
* Returns metadata for given content location as array
* @param ezpContentLocation $location
* @return array
*/
public static function getMetadataByLocation(ezpContentLocation $location)
{
$url = $location->url_alias;
eZURI::transformURI($url, false, 'full');
// $url is passed as a reference
$aMetadata = array('nodeId' => (int) $location->node_id, 'nodeRemoteId' => $location->remote_id, 'fullUrl' => $url);
return $aMetadata;
}
示例9: status
public static function status( $args )
{
if ( count( $args ) != 2 )
{
throw new ezcBaseFunctionalityNotSupportedException( 'status', 'Missing argument(s)' );
}
list( $contentObjectId, $version ) = $args;
$process = ezpContentPublishingProcess::fetchByContentObjectVersion( $contentObjectId, $version );
// No process: check if the object's still a draft
// @todo Change to a PENDING check when applied (operation => step 2)
if ( $process instanceof ezpContentPublishingProcess )
{
$return = array();
$status = $process->attribute( 'status' ) == ezpContentPublishingProcess::STATUS_WORKING ? 'working' : 'finished';
switch( $process->attribute( 'status' ) )
{
case ezpContentPublishingProcess::STATUS_WORKING:
$status = 'working';
break;
case ezpContentPublishingProcess::STATUS_FINISHED:
$status = 'finished';
$objectVersion = $process->attribute( 'version' );
$object = $objectVersion->attribute( 'contentobject' );
$node = $object->attribute( 'main_node' );
$uri = $node->attribute( 'url_alias' );
eZURI::transformURI( $uri );
$return['node_uri'] = $uri;
break;
case ezpContentPublishingProcess::STATUS_PENDING:
$status = 'pending';
break;
case ezpContentPublishingProcess::STATUS_DEFERRED:
$status = 'deferred';
$versionViewUri = "content/versionview/{$contentObjectId}/{$version}";
eZURI::transformURI( $versionViewUri );
$return['versionview_uri'] = $versionViewUri;
break;
}
$return['status'] = $status;
}
else
{
$version = eZContentObjectVersion::fetchVersion( $version, $contentObjectId );
if ( $version === null )
throw new ezcBaseFunctionalityNotSupportedException( 'status', 'Object version not found' );
else
$return = array( 'status' => 'queued' );
}
return $return;
}
示例10: 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;
}
示例11: fetchMapMarkers
public static function fetchMapMarkers($parentNodeId, $childrenClassIdentifiers)
{
foreach ($childrenClassIdentifiers as $key => $value) {
if (empty($value)) {
unset($childrenClassIdentifiers[$key]);
}
}
$sortBy = array('name' => 'asc');
$result = array();
if ($parentNode = self::getNode($parentNodeId)) {
if (!empty($childrenClassIdentifiers)) {
$childrenClassTypes = (array) eZContentClass::fetchList(0, true, false, null, null, $childrenClassIdentifiers);
} else {
$childrenClassTypes = self::getChildrenClasses($parentNodeId);
}
// ricavo gli attributi delle classi
$geoAttributes = array();
foreach ($childrenClassTypes as $classType) {
if ($classType instanceof eZContentClass) {
$geoAttributes = array_merge($geoAttributes, eZContentClassAttribute::fetchFilteredList(array('contentclass_id' => $classType->attribute('id'), 'version' => $classType->attribute('version'), 'data_type_string' => 'ezgmaplocation')));
}
}
if (count($geoAttributes)) {
// imposto i filtri di ricerca
$geoFields = $geoFieldsNames = array();
foreach ($geoAttributes as $geoAttribute) {
if ($geoAttribute instanceof eZContentClassAttribute) {
$geoFields[$geoAttribute->attribute('identifier')] = $geoAttribute->attribute('name');
$geoFieldsNames[] = "subattr_{$geoAttribute->attribute('identifier')}___coordinates____gpt";
}
}
$childrenParameters = array('SearchSubTreeArray' => array($parentNode->attribute('node_id')), 'Filter' => array('-meta_id_si:' . $parentNode->attribute('contentobject_id')), 'SearchLimit' => 1000, 'AsObjects' => false, 'SortBy' => $sortBy, 'FieldsToReturn' => $geoFieldsNames);
// cerco i figli
$solr = new OCSolr();
$children = $solr->search('', $childrenParameters);
if ($children['SearchCount'] > 0) {
foreach ($children['SearchResult'] as $item) {
foreach ($geoFieldsNames as $geoFieldsName) {
@(list($longitude, $latitude) = explode(',', $item['fields'][$geoFieldsName][0]));
if (intval($latitude) > 0 && intval($longitude) > 0) {
$href = isset($item['main_url_alias']) ? $item['main_url_alias'] : $item['main_url_alias_ms'];
eZURI::transformURI($href, false, 'full');
$popup = isset($item['name']) ? $item['name'] : $item['name_t'];
$id = isset($item['id_si']) ? $item['id_si'] : $item['id'];
$result[] = array('id' => $id, 'type' => null, 'lat' => floatval($latitude), 'lon' => floatval($longitude), 'lng' => floatval($longitude), 'popupMsg' => $popup, 'title' => $popup, 'description' => "<h3><a href='{$href}'>{$popup}</a></h3>", 'urlAlias' => $href, 'objectID' => $id);
}
}
}
}
}
}
return array('result' => $result);
}
示例12: 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();
$clientID = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientID'));
$clientSecret = trim($ngConnectINI->variable('LoginMethod_google', 'GoogleClientSecret'));
if (empty($clientID) || empty($clientSecret)) {
return array('status' => 'error', 'message' => 'Google client ID or Google client 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');
$scope = self::SCOPE;
$userScope = trim($ngConnectINI->variable('LoginMethod_google', 'Scope'));
if (!empty($userScope)) {
$scope = $userScope . ' ' . $scope;
}
$client = new Google_Client();
$client->setApplicationName(trim($ngConnectINI->variable('LoginMethod_google', 'MethodName')));
$client->setScopes($scope);
$client->setClientId($clientID);
$client->setClientSecret($clientSecret);
$client->setRedirectUri($callbackUri);
$client->setUseObjects(true);
$plus = new Google_PlusService($client);
$authString = $client->authenticate();
$accessToken = $client->getAccessToken();
if (empty($authString) || empty($accessToken)) {
return array('status' => 'error', 'message' => 'Unable to authenticate to Google.');
}
$me = $plus->people->get('me');
if (!$me instanceof Google_Person) {
return array('status' => 'error', 'message' => 'Invalid Google user.');
}
$result = array('status' => 'success', 'login_method' => 'google', 'id' => $me->id, 'first_name' => !empty($me->name->givenName) ? $me->name->givenName : '', 'last_name' => !empty($me->name->familyName) ? $me->name->familyName : '', 'email' => !empty($me->emails[0]['value']) ? $me->emails[0]['value'] : '', 'picture' => !empty($me->image->url) ? $me->image->url : '');
return $result;
}
示例13: getAccessToken
public function getAccessToken($redirectURL = null)
{
$http = eZHTTPTool::instance();
if ($http->hasGetVariable('code') === false) {
throw new Exception('Wrong request token. Refresh the page or try again later.');
}
if ($redirectURL !== null) {
eZURI::transformURI($redirectURL, false, 'full');
$this->connection->setRedirectUri($redirectURL);
}
$this->connection->authenticate();
$accessToken = $this->connection->getAccessToken();
return array('token' => $accessToken, 'secret' => null);
}
示例14: getAuthorizeURL
public function getAuthorizeURL(array $scopes = null, $redirectURL = null)
{
$http = eZHTTPTool::instance();
if ($redirectURL !== null) {
eZURI::transformURI($redirectURL, false, 'full');
$this->connection->setCallbackUrl($redirectURL);
}
$response = $this->connection->retrieveTokenRequest($scopes);
if ($response['success'] === true) {
$http->setSessionVariable('linkedin_request_token', $response['linkedin']);
return LinkedIn::_URL_AUTH . $response['linkedin']['oauth_token'];
} else {
throw new Exception('Request token retrieval failed. Refresh the page or try again later.');
}
}
示例15: getAccessToken
public function getAccessToken($redirectURL = null)
{
$http = eZHTTPTool::instance();
if ($redirectURL === null) {
$redirectURL = '/nxc_social_network_token/get_access_token/facebook';
}
eZURI::transformURI($redirectURL, false, 'full');
$data = file_get_contents('https://graph.facebook.com/oauth/access_token?' . 'client_id=' . $this->appSettings['key'] . '&' . 'client_secret=' . $this->appSettings['secret'] . '&' . 'code=' . $http->getVariable('code') . '&' . 'redirect_uri=' . $redirectURL);
if (strpos($data, 'access_token=') !== false) {
preg_match('/access_token=([^&]*)/i', $data, $matches);
if (isset($matches[1])) {
return array('token' => $matches[1], 'secret' => null);
}
}
throw new Exception('Could not get access token. Refresh the page or try again later.');
}