示例#1
0
 /**
  * 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);
 }
 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
0
 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
0
 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);
 }
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
0
 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;
     }
 }
 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();
 }
 /**
  * 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;
 }
    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
0
 /**
  * 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;
 }
 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
0
 /**
  * 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
0
 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
0
 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
0
 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.');
 }
示例#16
0
 /** Get an include tag for the given base URL and parameters.
  *
  * This performs the processing common to both types of includes.
  * @param string $url The base of the URL that should be included.
  * @param array $keys An associative array of GET parameters to add to the
  * URL before including it.
  * @return string The generated esi:include tag for the given URL.
  */
 private function getIncludeTag($url, $params)
 {
     if ($this->sendDoESIHeader) {
         header(self::DO_ESI_HEADER);
     }
     nxcESIEAS::setUseESI(true);
     foreach ($params as $key => $value) {
         $url .= '&' . rawurlencode($key) . '=' . rawurlencode($value);
     }
     eZURI::transformURI($url);
     $include = '<esi:include src="' . $url;
     if ($this->continueOnError) {
         $include .= '" onerror="continue';
     }
     $include .= '"/>';
     return $include;
 }
示例#17
0
 public function execute($process, $event)
 {
     $processParameters = $process->attribute('parameter_list');
     $object = eZContentObject::fetch($processParameters['object_id']);
     $node = $object->mainNode();
     $href = '/push/node/' . $node->attribute('node_id');
     $version = eZContentObjectVersion::fetchVersion($processParameters['version'], $processParameters['object_id']);
     if ($version instanceof eZContentObjectVersion) {
         $language = eZContentLanguage::fetch($version->attribute('initial_language_id'));
         if ($language instanceof eZContentLanguage) {
             $href .= '/' . $language->attribute('locale');
         }
     }
     eZURI::transformURI($href, false, 'full');
     $http = eZHTTPTool::instance();
     $http->setSessionVariable('RedirectURIAfterPublish', $href);
     return eZWorkflowType::STATUS_ACCEPTED;
 }
示例#18
0
 public function getAuthorizeURL(array $scopes = null, $redirectURL = null)
 {
     $connection = new TwitterOAuth($this->appSettings['key'], $this->appSettings['secret']);
     if ($redirectURL === null) {
         $redirectURL = '/nxc_social_network_token/get_access_token/twitter';
     }
     eZURI::transformURI($redirectURL, false, 'full');
     $requestToken = $connection->getRequestToken($redirectURL);
     $http = eZHTTPTool::instance();
     $http->setSessionVariable('twitter_request_token', $requestToken['oauth_token']);
     $http->setSessionVariable('twitter_request_token_secret', $requestToken['oauth_token_secret']);
     switch ($connection->http_code) {
         case 200:
             return $connection->getAuthorizeURL($requestToken['oauth_token'], true);
         default:
             throw new Exception('Could not connect to Twitter. Refresh the page or try again later.');
     }
 }
 public static function getMetadataByLocation(ezpContentLocation $location)
 {
     $url = $location->url_alias;
     eZURI::transformURI($url, false, 'full');
     // $url is passed as a reference
     // Forzo l'utilizzo di HTTPS
     $url_https = str_replace("http://", "https://", $url);
     $aMetadata = array('nodeId' => (int) $location->node_id, 'nodeRemoteId' => $location->remote_id, 'fullUrl' => $url_https);
     try {
         $node = eZContentObjectTreeNode::fetch($location->node_id);
         if ($node instanceof eZContentObjectTreeNode) {
             $pathNames = explode('/', $node->attribute('path_with_names'));
             $aMetadata['path'] = $pathNames;
         }
     } catch (Exception $e) {
     }
     return $aMetadata;
 }
 function execute($process, $event)
 {
     // get object being published
     $parameters = $process->attribute('parameter_list');
     $objectId = $parameters['object_id'];
     eZDebug::writeDebug('Expire remote cache event begins execution for object ' . $objectId);
     $ini = eZINI::instance('ezworkflowcollection.ini');
     $object = eZContentObject::fetch($objectId);
     if ($object != null) {
         if ($ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireOnlyObjectNodes') == 'enabled') {
             // basic version
             // get list of nodes this object is published with
             $assigned_nodes = $object->attribute('assigned_nodes');
         } else {
             // smart-cache enabled version
             // get list of nodes whose view-cache is expired
             $assigned_nodes = array();
             eZContentCacheManager::nodeListForObject($object, true, eZContentCacheManager::CLEAR_DEFAULT, $assigned_nodes, $handledObjectList);
             foreach ($assigned_nodes as $i => $nodeID) {
                 $assigned_nodes[$i] = eZContentObjectTreeNode::fetch($nodeID);
             }
         }
         $domains = $ini->variable('ExpireRemoteCacheFlowSettings', 'ExpireDomains');
         foreach ($assigned_nodes as $assigned_node) {
             // for every node, call eZHTTPCacheManager to clean the remote cache
             $url = $assigned_node->urlAlias();
             if (is_array($domains) && (count($domains) > 1 || count($domains) > 0 && $domains[0] != '')) {
                 eZURI::transformURI($url);
                 foreach ($domains as $domain) {
                     eZHTTPCacheManager::execute($domain . $url);
                 }
             } else {
                 eZURI::transformURI($url, false, 'full');
                 eZHTTPCacheManager::execute($url);
             }
         }
     } else {
         eZDebug::writeError('Expire remote cache event triggered for inexisting object: ' . $objectId);
         return eZWorkflowType::STATUS_WORKFLOW_CANCELLED;
     }
     return eZWorkflowType::STATUS_ACCEPTED;
 }
示例#21
0
 public function getAccessToken($redirectURL = null)
 {
     $http = eZHTTPTool::instance();
     if ($redirectURL === null) {
         $redirectURL = '/nxc_social_network_token/get_access_token/instagram';
     }
     eZURI::transformURI($redirectURL, false, 'full');
     $postdata = http_build_query(array('client_id' => $this->appSettings['key'], 'grant_type' => 'authorization_code', 'client_secret' => $this->appSettings['secret'], 'code' => $http->getVariable('code'), 'redirect_uri' => $redirectURL));
     $opts = array('http' => array('method' => 'POST', 'content' => $postdata));
     $context = stream_context_create($opts);
     $data = file_get_contents('https://api.instagram.com/oauth/access_token', false, $context);
     $dataArray = json_decode($data, true);
     if (isset($adataArray['access_token'])) {
         return array('token' => $adataArray['access_token'], 'secret' => null);
     }
     if (isset($dataArray['access_token'])) {
         return array('token' => $dataArray['access_token'], 'secret' => null);
     }
     if (isset($dataArray['error_message']) && isset($dataArray['code']) && isset($dataArray['error_type'])) {
         throw new Exception($dataArray['error_type'] . '(' . $dataArray['code'] . '): ' . $dataArray['error_message']);
     }
     throw new Exception('Could not get access token. Refresh the page or try again later.');
 }
 public function generateNodeListCache($nodeList)
 {
     eZDebug::accumulatorStart('StaticCacheMugo', '', 'StaticCacheMugo');
     if (!empty($nodeList)) {
         foreach ($nodeList as $nodeId) {
             $urls = $this->nodeId2Urls($nodeId);
             foreach ($urls as $url) {
                 if ($this->pathPrefixModifier) {
                     $this->applyPreFixModifier($url);
                 }
                 $key = md5($url);
                 if (!isset(self::$urlsToPurge[$key])) {
                     if ($this->uriTransformation) {
                         eZURI::transformURI($url);
                     }
                     if ($this->urlModifierMatch) {
                         $url = preg_replace($this->urlModifierMatch, $this->urlModifierReplace, $url);
                     }
                     // exclude URLs based on configured patterns
                     if (!empty($this->omitUrlPatterns)) {
                         $matched = false;
                         foreach ($this->omitUrlPatterns as $pattern) {
                             $matched = preg_match($pattern, $purgeUrl);
                         }
                         // skip it and process next URL
                         if ($matched) {
                             continue;
                         }
                     }
                     // add final version of URL to list
                     self::$urlsToPurge[$key] = $url;
                 }
             }
         }
     }
     eZDebug::accumulatorStop('StaticCacheMugo', '', 'StaticCacheMugo');
 }
示例#23
0
 $response['children'] = array();
 foreach ($children as $child) {
     $childObject = $child->object();
     $childResponse = array();
     $childResponse['node_id'] = $child->NodeID;
     $childResponse['object_id'] = $child->ContentObjectID;
     $object = $child->object();
     $childResponse['class_id'] = $object->ClassID;
     $childResponse['has_children'] = $child->subTreeCount($conditions) ? 1 : 0;
     $childResponse['name'] = $child->getName();
     $childResponse['url'] = $child->url();
     // force system url on empty urls (root node)
     if ($childResponse['url'] === '') {
         $childResponse['url'] = 'content/view/full/' . $childResponse['node_id'];
     }
     eZURI::transformURI($childResponse['url']);
     $childResponse['modified_subnode'] = $child->ModifiedSubNode;
     $childResponse['languages'] = $childObject->availableLanguages();
     $childResponse['is_hidden'] = $child->IsHidden;
     $childResponse['is_invisible'] = $child->IsInvisible;
     if ($createHereMenu == 'full') {
         $childResponse['class_list'] = array();
         foreach ($child->canCreateClassList() as $class) {
             $childResponse['class_list'][] = $class['id'];
         }
     }
     $response['children'][] = $childResponse;
     unset($object);
     eZContentObject::clearCache();
 }
 $httpCharset = eZTextCodec::httpCharset();
示例#24
0
 function modify($tpl, $operatorName, $operatorParameters, $rootNamespace, $currentNamespace, &$operatorValue, $namedParameters)
 {
     switch ($operatorName) {
         case $this->ININameHasVariable:
         case $this->ININame:
             if (count($operatorParameters) > 0) {
                 $iniGroup = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace);
                 if (count($operatorParameters) == 1) {
                     $tpl->error($operatorName, "Missing variable name parameter");
                     return;
                 }
                 $iniVariable = $tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace);
                 $iniName = isset($operatorParameters[2]) ? $tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace) : false;
                 $iniPath = isset($operatorParameters[3]) ? $tpl->elementValue($operatorParameters[3], $rootNamespace, $currentNamespace) : false;
                 // If we should check for existence of variable.
                 // You can use like:
                 //     ezini( <BlockName>, <SettingName>, <FileName>, <IniPath>, _use under template compiling mode_ , <Should We Check for existence: 'hasVariable' or true()> )
                 //     ezini_hasvariable( <BlockName>, <SettingName>, <FileName>, <IniPath>... )
                 if ($operatorName == $this->ININameHasVariable) {
                     $checkExistence = true;
                 } else {
                     $checkExistence = isset($operatorParameters[5]) ? ($tpl->elementValue($operatorParameters[5], $rootNamespace, $currentNamespace) === true or $tpl->elementValue($operatorParameters[5], $rootNamespace, $currentNamespace) == 'hasVariable') ? true : false : false;
                 }
                 if ($iniPath !== false) {
                     $ini = eZINI::instance($iniName, $iniPath, null, null, null, true);
                 } elseif ($iniName !== false) {
                     $ini = eZINI::instance($iniName);
                 } else {
                     $ini = eZINI::instance();
                 }
                 if ($ini->hasVariable($iniGroup, $iniVariable)) {
                     $operatorValue = !$checkExistence ? $ini->variable($iniGroup, $iniVariable) : true;
                 } else {
                     if ($checkExistence) {
                         $operatorValue = false;
                         return;
                     }
                     if ($iniPath !== false) {
                         // Return empty string instead of displaying error when using 'path' parameter
                         // and DirectAccess mode for ezini.
                         $operatorValue = '';
                     } else {
                         if ($iniName === false) {
                             $iniName = 'site.ini';
                         }
                         $tpl->error($operatorName, "!!!No such variable '{$iniVariable}' in group '{$iniGroup}' for {$iniName}");
                     }
                 }
                 return;
             } else {
                 $tpl->error($operatorName, "Missing group name parameter");
             }
             break;
         case $this->HTTPNameHasVariable:
         case $this->HTTPName:
             $http = eZHTTPTool::instance();
             if (count($operatorParameters) > 0) {
                 $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_POST;
                 $httpName = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace);
                 if (count($operatorParameters) > 1) {
                     $httpTypeName = strtolower($tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace));
                     if ($httpTypeName == 'post') {
                         $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_POST;
                     } else {
                         if ($httpTypeName == 'get') {
                             $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_GET;
                         } else {
                             if ($httpTypeName == 'session') {
                                 $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_SESSION;
                             } else {
                                 if ($httpTypeName == 'cookie') {
                                     $httpType = eZURLOperator::HTTP_OPERATOR_TYPE_COOKIE;
                                 } else {
                                     $tpl->warning($operatorName, "Unknown http type '{$httpTypeName}'");
                                 }
                             }
                         }
                     }
                 }
                 // If we should check for existence of http variable
                 // You can use like:
                 //     ezhttp( <Variable>, <Method: post, get, session>, <Should We Check for existence: 'hasVariable' or true()> )
                 //     ezhttp_hasvariable( <Variable>, <Method> )
                 if ($operatorName == $this->HTTPNameHasVariable) {
                     $checkExistence = true;
                 } else {
                     $checkExistence = isset($operatorParameters[2]) ? ($tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace) === true or $tpl->elementValue($operatorParameters[2], $rootNamespace, $currentNamespace) == 'hasVariable') ? true : false : false;
                 }
                 switch ($httpType) {
                     case eZURLOperator::HTTP_OPERATOR_TYPE_POST:
                         if ($http->hasPostVariable($httpName)) {
                             $operatorValue = !$checkExistence ? $http->postVariable($httpName) : true;
                         } else {
                             // If only check for existence - return false
                             if ($checkExistence) {
                                 $operatorValue = false;
                                 return;
                             }
                             $tpl->error($operatorName, "Unknown post variable '{$httpName}'");
                         }
                         break;
                     case eZURLOperator::HTTP_OPERATOR_TYPE_GET:
                         if ($http->hasGetVariable($httpName)) {
                             $operatorValue = !$checkExistence ? $http->getVariable($httpName) : true;
                         } else {
                             if ($checkExistence) {
                                 $operatorValue = false;
                                 return;
                             }
                             $tpl->error($operatorName, "Unknown get variable '{$httpName}'");
                         }
                         break;
                     case eZURLOperator::HTTP_OPERATOR_TYPE_SESSION:
                         if ($http->hasSessionVariable($httpName)) {
                             $operatorValue = !$checkExistence ? $http->sessionVariable($httpName) : true;
                         } else {
                             if ($checkExistence) {
                                 $operatorValue = false;
                                 return;
                             }
                             $tpl->error($operatorName, "Unknown session variable '{$httpName}'");
                         }
                         break;
                     case eZURLOperator::HTTP_OPERATOR_TYPE_COOKIE:
                         if (array_key_exists($httpName, $_COOKIE)) {
                             $operatorValue = !$checkExistence ? $_COOKIE[$httpName] : true;
                         } else {
                             if ($checkExistence) {
                                 $operatorValue = false;
                                 return;
                             }
                             $tpl->error($operatorName, "Unknown cookie variable '{$httpName}'");
                         }
                         break;
                 }
             } else {
                 $operatorValue = $http;
             }
             return;
             break;
         case $this->URLName:
             eZURI::transformURI($operatorValue, false, $namedParameters['server_url']);
             break;
         case $this->URLRootName:
             if (preg_match("#^[a-zA-Z0-9]+:#", $operatorValue) or substr($operatorValue, 0, 2) == '//') {
                 break;
             }
             if (strlen($operatorValue) > 0 and $operatorValue[0] != '/') {
                 $operatorValue = '/' . $operatorValue;
             }
             // Same as "ezurl" without "index.php" and the siteaccess name in the returned address.
             eZURI::transformURI($operatorValue, true, $namedParameters['server_url']);
             break;
         case $this->SysName:
             if (count($operatorParameters) == 0) {
                 $tpl->warning('eZURLOperator' . $operatorName, 'Requires attributename');
             } else {
                 $sysAttribute = $tpl->elementValue($operatorParameters[0], $rootNamespace, $currentNamespace);
                 if (!$this->Sys->hasAttribute($sysAttribute)) {
                     $tpl->warning('eZURLOperator' . $operatorName, "No such attribute '{$sysAttribute}' for eZSys");
                 } else {
                     $operatorValue = $this->Sys->attribute($sysAttribute);
                 }
             }
             return;
             break;
         case $this->ImageName:
             if (count($operatorParameters) == 2 && $tpl->elementValue($operatorParameters[1], $rootNamespace, $currentNamespace) == true && strlen($this->Sys->wwwDir()) == 0) {
                 $skipSlash = true;
             } else {
                 $skipSlash = false;
             }
             $operatorValue = $this->eZImage($tpl, $operatorValue, $operatorName, $skipSlash);
             break;
         case $this->ExtName:
             $urlMD5 = md5($operatorValue);
             $url = eZURL::urlByMD5($urlMD5);
             if ($url === false) {
                 eZURL::registerURL($operatorValue);
             } else {
                 $operatorValue = $url;
             }
             break;
         case $this->DesignName:
             $operatorValue = $this->eZDesign($tpl, $operatorValue, $operatorName);
             break;
     }
     $quote = "\"";
     $val = $namedParameters['quote_val'];
     if ($val == 'single') {
         $quote = "'";
     } else {
         if ($val == 'no') {
             $quote = false;
         }
     }
     $http = eZHTTPTool::instance();
     if (isset($http->UseFullUrl) and $http->UseFullUrl and strncasecmp($operatorValue, '/', 1) === 0) {
         $operatorValue = $http->createRedirectUrl($operatorValue, array('pre_url' => false));
     }
     if ($quote !== false) {
         $operatorValue = $quote . $operatorValue . $quote;
     }
 }
 unset($var1);
 $var1 = (array_key_exists($rootNamespace, $vars) and array_key_exists('lang', $vars[$rootNamespace])) ? $vars[$rootNamespace]['lang'] : null;
 $var2 = compiledFetchAttribute($var1, 'url');
 unset($var1);
 $var1 = $var2;
 if (!isset($var1)) {
     $var1 = NULL;
 }
 while (is_object($var1) and method_exists($var1, 'templateValue')) {
     $var1 = $var1->templateValue();
 }
 while (is_object($var1) and method_exists($var1, 'templateValue')) {
     $var1 = $var1->templateValue();
 }
 //include_once( 'lib/ezutils/classes/ezuri.php' );
 eZURI::transformURI($var1, false, 'relative');
 $var1 = '"' . $var1 . '"';
 $var = $var1;
 unset($var1);
 if (!isset($var)) {
     $var = NULL;
 }
 while (is_object($var) and method_exists($var, 'templateValue')) {
     $var = $var->templateValue();
 }
 $text .= $var;
 unset($var);
 $text .= '>';
 unset($var);
 unset($var1);
 unset($var1);
示例#26
0
 /**
  * This is a hook which is called by the language switcher module on
  * implementation classes.
  *
  * In this implementation it is doing initialisation as an example.
  *
  * @return void
  */
 public function process()
 {
     $saIni = $this->getSiteAccessIni();
     $this->destinationLocale = $saIni->variable('RegionalSettings', 'ContentObjectLocale');
     // Detect the type of siteaccess we are dealing with. Initially URI and Host are supported.
     // We don't want the siteaccess part here, since we are inserting our siteaccess name.
     $indexFile = trim(eZSys::indexFile(false), '/');
     switch ($GLOBALS['eZCurrentAccess']['type']) {
         case eZSiteAccess::TYPE_URI:
             eZURI::transformURI($host, true, 'full');
             break;
         default:
             $host = $saIni->variable('SiteSettings', 'SiteURL');
             $host = eZSys::serverProtocol() . "://" . $host;
             break;
     }
     $this->baseDestinationUrl = "{$host}{$indexFile}";
 }
 /**
  * Formats the current response as a JSON string
  *
  * @return string The JSON encoded object
  */
 public function __toString()
 {
     $stringObject = new stdClass();
     $stringObject->image_url = $this->getNewImagePath();
     $stringObject->thumbnail_url = $this->getNewThumbnailPath();
     $stringObject->history_version = $this->getNewHistoryVersion();
     eZURI::transformURI($stringObject->image_url, true);
     eZURI::transformURI($stringObject->thumbnail_url, true);
     return json_encode($stringObject);
 }
示例#28
0
 static function printReport($newWindow = false, $as_html = true, $returnReport = false, $allowedDebugLevels = false, $useAccumulators = true, $useTiming = true, $useIncludedFiles = false)
 {
     if (!self::isDebugEnabled()) {
         return null;
     }
     $debug = self::instance();
     $report = $debug->printReportInternal($as_html, $returnReport & $newWindow, $allowedDebugLevels, $useAccumulators, $useTiming, $useIncludedFiles);
     if ($newWindow == true) {
         $debugFilePath = eZDir::path(array(eZSys::varDirectory(), 'cache', 'debug.html'));
         $debugFileURL = $debugFilePath;
         eZURI::transformURI($debugFileURL, true);
         print "\n<script type='text/javascript'>\n<!--\n\n(function()\n{\n    var debugWindow;\n\n    if  (navigator.appName == \"Microsoft Internet Explorer\")\n    {\n        //Microsoft Internet Explorer\n        debugWindow = window.open( '{$debugFileURL}', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.close();\n        debugWindow.location.reload();\n    }\n    else if (navigator.appName == \"Opera\")\n    {\n        //Opera\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.location.href=\"{$debugFileURL}\";\n        debugWindow.navigate(\"{$debugFileURL}\");\n    }\n    else\n    {\n        //Mozilla, Firefox, etc.\n        debugWindow = window.open( '', 'ezdebug', 'width=500,height=550,status,scrollbars,resizable,screenX=0,screenY=20,left=20,top=40');\n        debugWindow.document.location.href=\"{$debugFileURL}\";\n    };\n})();\n\n// -->\n</script>\n";
         $header = "<!DOCTYPE html><html><head><title>eZ debug</title></head><body>";
         $footer = "</body></html>";
         $fullPage = ezpEvent::getInstance()->filter('response/output', $header . $report . $footer);
         file_put_contents($debugFilePath, $fullPage);
     } else {
         if ($returnReport) {
             return $report;
         }
     }
     return null;
 }
 }
 while (is_object($var5) and method_exists($var5, 'templateValue')) {
     $var5 = $var5->templateValue();
 }
 while (is_object($var5) and method_exists($var5, 'templateValue')) {
     $var5 = $var5->templateValue();
 }
 $var1 = 'content/edit/' . $var3 . '/f/' . $var5;
 unset($var3, $var5);
 if (!isset($var1)) {
     $var1 = NULL;
 }
 while (is_object($var1) and method_exists($var1, 'templateValue')) {
     $var1 = $var1->templateValue();
 }
 eZURI::transformURI($var1, false, eZURI::getTransformURIMode());
 $var = $var1;
 unset($var1);
 if (!isset($var)) {
     $var = NULL;
 }
 while (is_object($var) and method_exists($var, 'templateValue')) {
     $var = $var->templateValue();
 }
 $text .= $var;
 unset($var);
 $text .= '">
     <img src="/design/standard/images/edit.gif" width="16" height="16" alt="Modifier" title="';
 unset($var);
 unset($var1);
 unset($var3);
示例#30
0
 /**
  * Function for simplifying a content object or node
  *
  * @param mixed $obj
  * @param array $params
  * @return array
  */
 public static function simplify($obj, $params = array())
 {
     if (!$obj) {
         return array();
     } else {
         if ($obj instanceof eZContentObject) {
             $node = $obj->attribute('main_node');
             $contentObject = $obj;
         } else {
             if ($obj instanceof eZContentObjectTreeNode || $obj instanceof eZFindResultNode) {
                 $node = $obj;
                 $contentObject = $obj->attribute('object');
             } else {
                 if (isset($params['fetchNodeFunction']) && method_exists($obj, $params['fetchNodeFunction'])) {
                     // You can supply fetchNodeFunction parameter to be able to support other node related classes
                     $node = call_user_func(array($obj, $params['fetchNodeFunction']));
                     if (!$node instanceof eZContentObjectTreeNode) {
                         return '';
                     }
                     $contentObject = $node->attribute('object');
                 } else {
                     if (is_array($obj)) {
                         return $obj;
                         // Array is returned as is
                     } else {
                         return '';
                         // Other passed objects are not supported
                     }
                 }
             }
         }
     }
     $ini = eZINI::instance('site.ini');
     $params = array_merge(array('dataMap' => array(), 'fetchPath' => false, 'fetchSection' => false, 'fetchChildrenCount' => false, 'dataMapType' => array(), 'loadImages' => false, 'imagePreGenerateSizes' => array('small')), $params);
     if (!isset($params['imageSizes'])) {
         $imageIni = eZINI::instance('image.ini');
         $params['imageSizes'] = $imageIni->variable('AliasSettings', 'AliasList');
     }
     if ($params['imageSizes'] === null || !isset($params['imageSizes'][0])) {
         $params['imageSizes'] = array();
     }
     if (!isset($params['imageDataTypes'])) {
         $params['imageDataTypes'] = $ini->variable('ImageDataTypeSettings', 'AvailableImageDataTypes');
     }
     $ret = array();
     $attrtibuteArray = array();
     $ret['name'] = htmlentities($contentObject->attribute('name'), ENT_QUOTES, "UTF-8");
     $ret['contentobject_id'] = $ret['id'] = (int) $contentObject->attribute('id');
     $ret['contentobject_remote_id'] = $contentObject->attribute('remote_id');
     $ret['contentobject_state'] = implode(", ", $contentObject->attribute('state_identifier_array'));
     $ret['main_node_id'] = (int) $contentObject->attribute('main_node_id');
     $ret['version'] = (int) $contentObject->attribute('current_version');
     $ret['modified'] = $contentObject->attribute('modified');
     $ret['published'] = $contentObject->attribute('published');
     $ret['section_id'] = (int) $contentObject->attribute('section_id');
     $ret['current_language'] = $contentObject->attribute('current_language');
     $ret['owner_id'] = (int) $contentObject->attribute('owner_id');
     $ret['class_id'] = (int) $contentObject->attribute('contentclass_id');
     $ret['class_name'] = $contentObject->attribute('class_name');
     $ret['path_identification_string'] = $node->attribute('path_identification_string');
     $ret['translations'] = eZContentLanguage::decodeLanguageMask($contentObject->attribute('language_mask'), true);
     $ret['can_edit'] = $contentObject->attribute('can_edit');
     if (isset($params['formatDate'])) {
         $ret['modified_date'] = self::formatLocaleDate($contentObject->attribute('modified'), $params['formatDate']);
         $ret['published_date'] = self::formatLocaleDate($contentObject->attribute('published'), $params['formatDate']);
     }
     if (isset($params['fetchCreator'])) {
         $creator = $contentObject->attribute('current')->attribute('creator');
         if ($creator instanceof eZContentObject) {
             $ret['creator'] = array('id' => $creator->attribute('id'), 'name' => $creator->attribute('name'));
         } else {
             $ret['creator'] = array('id' => $contentObject->attribute('current')->attribute('creator_id'), 'name' => null);
             // user has been deleted
         }
     }
     if (isset($params['fetchClassIcon'])) {
         $operator = new eZWordToImageOperator();
         $tpl = eZTemplate::instance();
         $operatorValue = $contentObject->attribute('class_identifier');
         $operatorParameters = array(array(array(1, 'small')));
         $namedParameters = array();
         $operatorName = 'class_icon';
         $operator->modify($tpl, $operatorName, $operatorParameters, '', '', $operatorValue, $namedParameters, array());
         $ret['class_icon'] = $operatorValue;
     }
     if (isset($params['fetchThumbPreview'])) {
         $thumbUrl = '';
         $thumbWidth = 0;
         $thumbHeight = 0;
         $thumbDataType = isset($params['thumbDataType']) ? $params['thumbDataType'] : 'ezimage';
         $thumbImageSize = isset($params['thumbImageSize']) ? $params['thumbImageSize'] : 'small';
         foreach ($contentObject->attribute('data_map') as $key => $atr) {
             if ($atr->attribute('data_type_string') == $thumbDataType && $atr->attribute('has_content')) {
                 $imageContent = $atr->attribute('content');
                 if ($imageContent->hasAttribute($thumbImageSize)) {
                     $imageAlias = $imageContent->attribute($thumbImageSize);
                 } else {
                     eZDebug::writeError("Image alias does not exist: '{$thumbImageSize}', missing from image.ini?", __METHOD__);
                 }
                 $thumbUrl = isset($imageAlias['full_path']) ? $imageAlias['full_path'] : '';
                 $thumbWidth = isset($imageAlias['width']) ? (int) $imageAlias['width'] : 0;
                 $thumbHeight = isset($imageAlias['height']) ? (int) $imageAlias['height'] : 0;
                 if ($thumbUrl !== '') {
                     eZURI::transformURI($thumbUrl, true);
                 }
                 break;
             }
         }
         $ret['thumbnail_url'] = $thumbUrl;
         $ret['thumbnail_width'] = $thumbWidth;
         $ret['thumbnail_height'] = $thumbHeight;
     }
     if ($params['fetchSection']) {
         $section = eZSection::fetch($ret['section_id']);
         if ($section instanceof eZSection) {
             $ret['section'] = array('id' => $section->attribute('id'), 'name' => $section->attribute('name'), 'navigation_part_identifier' => $section->attribute('navigation_part_identifier'), 'locale' => $section->attribute('locale'));
         } else {
             $ret['section'] = null;
         }
     }
     if ($node) {
         // optimization for eZ Publish 4.1 (avoid fetching class)
         if ($node->hasAttribute('is_container')) {
             $ret['class_identifier'] = $node->attribute('class_identifier');
             $ret['is_container'] = (int) $node->attribute('is_container');
         } else {
             $class = $contentObject->attribute('content_class');
             $ret['class_identifier'] = $class->attribute('identifier');
             $ret['is_container'] = (int) $class->attribute('is_container');
         }
         $ret['node_id'] = (int) $node->attribute('node_id');
         $ret['parent_node_id'] = (int) $node->attribute('parent_node_id');
         $ret['node_remote_id'] = $node->attribute('remote_id');
         $ret['url_alias'] = $node->attribute('url_alias');
         $ret['url'] = $node->url();
         // force system url on empty urls (root node)
         if ($ret['url'] === '') {
             $ret['url'] = 'content/view/full/' . $node->attribute('node_id');
         }
         eZURI::transformURI($ret['url']);
         $ret['depth'] = (int) $node->attribute('depth');
         $ret['priority'] = (int) $node->attribute('priority');
         $ret['hidden_status_string'] = $node->attribute('hidden_status_string');
         if ($params['fetchPath']) {
             $ret['path'] = array();
             foreach ($node->attribute('path') as $n) {
                 $ret['path'][] = self::simplify($n);
             }
         } else {
             $ret['path'] = false;
         }
         if ($params['fetchChildrenCount']) {
             $ret['children_count'] = $ret['is_container'] ? (int) $node->attribute('children_count') : 0;
         } else {
             $ret['children_count'] = false;
         }
     } else {
         $class = $contentObject->attribute('content_class');
         $ret['class_identifier'] = $class->attribute('identifier');
         $ret['is_container'] = (int) $class->attribute('is_container');
     }
     $ret['image_attributes'] = array();
     if (is_array($params['dataMap']) && is_array($params['dataMapType'])) {
         $dataMap = $contentObject->attribute('data_map');
         $datatypeBlacklist = array_fill_keys($ini->variable('ContentSettings', 'DatatypeBlackListForExternal'), true);
         foreach ($dataMap as $key => $atr) {
             $dataTypeString = $atr->attribute('data_type_string');
             //if ( in_array( $dataTypeString, $params['imageDataTypes'], true) !== false )
             if (!in_array('all', $params['dataMap'], true) && !in_array($key, $params['dataMap'], true) && !in_array($dataTypeString, $params['dataMapType'], true) && !($params['loadImages'] && in_array($dataTypeString, $params['imageDataTypes'], true))) {
                 continue;
             }
             $attrtibuteArray[$key]['id'] = $atr->attribute('id');
             $attrtibuteArray[$key]['type'] = $dataTypeString;
             $attrtibuteArray[$key]['identifier'] = $key;
             if (isset($datatypeBlacklist[$dataTypeString])) {
                 $attrtibuteArray[$key]['content'] = null;
             } else {
                 $attrtibuteArray[$key]['content'] = $atr->toString();
             }
             // images
             if (in_array($dataTypeString, $params['imageDataTypes'], true) && $atr->hasContent()) {
                 $content = $atr->attribute('content');
                 $imageArray = array();
                 if ($content != null) {
                     foreach ($params['imageSizes'] as $size) {
                         $imageArray[$size] = false;
                         if (in_array($size, $params['imagePreGenerateSizes'], true)) {
                             if ($content->hasAttribute($size)) {
                                 $imageArray[$size] = $content->attribute($size);
                             } else {
                                 eZDebug::writeError("Image alias does not exist: '{$size}', missing from image.ini?", __METHOD__);
                             }
                         }
                     }
                     $ret['image_attributes'][] = $key;
                 }
                 if (!isset($imageArray['original'])) {
                     $imageArray['original'] = $content->attribute('original');
                 }
                 array_walk_recursive($imageArray, function (&$element, $key) {
                     // json_encode/xmlEncode need UTF8 encoded strings
                     // (exif) metadata might not be for instance
                     // see https://jira.ez.no/browse/EZP-19929
                     if (!mb_check_encoding($element, 'UTF-8')) {
                         $element = mb_convert_encoding((string) $element, 'UTF-8');
                     }
                 });
                 $attrtibuteArray[$key]['content'] = $imageArray;
             }
         }
     }
     $ret['data_map'] = $attrtibuteArray;
     return $ret;
 }