本文整理汇总了PHP中eZHTTPTool类的典型用法代码示例。如果您正苦于以下问题:PHP eZHTTPTool类的具体用法?PHP eZHTTPTool怎么用?PHP eZHTTPTool使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了eZHTTPTool类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: modifySelection
/**
* Aggiorna la selezione delle tematiche da sincronizzare
* @param eZHTTPTool $http
*/
public function modifySelection($http)
{
if ($http->hasPostVariable('BrowseActionName') && $http->postVariable('BrowseActionName') == 'SelectDestinationNodeID') {
// Scelta del nodo di destinazione
$nodeIDArray = $http->postVariable('SelectedNodeIDArray');
$this->object->setAttribute('destination_node_id', $nodeIDArray[0]);
$this->object->store();
} else {
// Abilitazione e disabilitazione delle tematiche
$tematicheChanged = false;
foreach ($http->attribute('post') as $key => $value) {
$action = explode('_', $key);
if ($action[0] == 'DisableTag') {
if (($_key = array_search($value, $this->getTematiche())) !== false) {
$_tematiche = $this->getTematiche();
unset($_tematiche[$_key]);
$this->object->setAttribute('tags', implode(';', $_tematiche));
}
$tematicheChanged = true;
} else {
if ($action[0] == 'EnableTag') {
$_tematiche = $this->getTematiche();
$_tematiche[] = $value;
$this->object->setAttribute('tags', implode(';', $_tematiche));
$tematicheChanged = true;
}
}
}
if ($tematicheChanged) {
$this->object->store();
}
}
}
开发者ID:informaticatrentina,项目名称:itobjectsync,代码行数:37,代码来源:ittematicasync.php
示例2: 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;
}
}
开发者ID:netgen,项目名称:ngpush,代码行数:27,代码来源:ngpush_facebook_base.php
示例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;
}
开发者ID:CG77,项目名称:ezpublish-legacy,代码行数:32,代码来源:ezuserdiscountrule.php
示例4: fetchObjectAttributeHTTPInput
/**
* Set parameters from post data, expects post data to be validated by
* {@link eZGmapLocationType::validateObjectAttributeHTTPInput()}
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*/
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$validPostData = false;
if ($http->hasPostVariable($base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute('id')) && $http->hasPostVariable($base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute('id'))) {
$latitude = $http->postVariable($base . '_data_gmaplocation_latitude_' . $contentObjectAttribute->attribute('id'));
$longitude = $http->postVariable($base . '_data_gmaplocation_longitude_' . $contentObjectAttribute->attribute('id'));
$validPostData = $latitude !== '' && $longitude !== '' && is_numeric($latitude) && is_numeric($longitude);
}
if ($validPostData) {
$address = '';
if ($http->hasPostVariable($base . '_data_gmaplocation_address_' . $contentObjectAttribute->attribute('id'))) {
$address = $http->postVariable($base . '_data_gmaplocation_address_' . $contentObjectAttribute->attribute('id'));
$address = htmlentities($address, ENT_QUOTES, 'UTF-8');
}
if ($contentObjectAttribute->attribute('data_int') != 0) {
$location = eZGmapLocation::fetch($contentObjectAttribute->attribute('id'), $contentObjectAttribute->attribute('version'));
$location->setAttribute('latitude', $latitude);
$location->setAttribute('longitude', $longitude);
$location->setAttribute('address', $address);
} else {
$location = new eZGmapLocation(array('contentobject_attribute_id' => $contentObjectAttribute->attribute('id'), 'contentobject_version' => $contentObjectAttribute->attribute('version'), 'latitude' => $latitude, 'longitude' => $longitude, 'address' => $address));
$contentObjectAttribute->setAttribute('data_int', 1);
}
$contentObjectAttribute->setContent($location);
} else {
if ($contentObjectAttribute->attribute('data_int') != 0) {
$contentObjectAttribute->setAttribute('data_int', 0);
eZGmapLocation::removeById($contentObjectAttribute->attribute('id'), $contentObjectAttribute->attribute('version'));
}
}
return true;
}
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:40,代码来源:ezgmaplocationtype.php
示例5: get
function get($oid)
{
$oidroot = $this->oidRoot();
$oidroot = $oidroot[0];
switch (preg_replace('/\\.0$/', '', $oid)) {
case $oidroot . '1.1':
if (in_array('ezfind', eZExtension::activeExtensions())) {
$ini = eZINI::instance('solr.ini');
$data = eZHTTPTool::getDataByURL($ini->variable('SolrBase', 'SearchServerURI') . "/admin/ping", false);
if (stripos($data, '<str name="status">OK</str>') !== false) {
$status = 1;
} else {
$status = 0;
}
} else {
$status = -1;
}
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $status);
case $oidroot . '1.2':
if (in_array('ezfind', eZExtension::activeExtensions())) {
$ini = eZINI::instance('solr.ini');
$data = eZHTTPTool::getDataByURL($ini->variable('SolrBase', 'SearchServerURI') . "/admin/stats.jsp", false);
if (preg_match('#<stat +name="numDocs" +>[ \\t\\r\\n]*(\\d+)[ \\t\\r\\n]*</stat>#', $data, $status)) {
$status = $status[1];
} else {
$status = -2;
}
} else {
$status = -1;
}
return array('oid' => $oid, 'type' => eZSNMPd::TYPE_INTEGER, 'value' => $status);
}
return self::NO_SUCH_OID;
}
开发者ID:gggeek,项目名称:ezsnmpd,代码行数:34,代码来源:ezsnmpdezfindhandler.php
示例6: 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;
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:28,代码来源:ezsurveytextentry.php
示例7: 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();
}
}
开发者ID:brookinsconsulting,项目名称:ezecosystem,代码行数:29,代码来源:ezpmobiledeviceregexpfilter.php
示例8: 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;
}
开发者ID:nottavi,项目名称:ezpublish,代码行数:60,代码来源:ezwizardbaseclassloader.php
示例9: 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;
}
开发者ID:nfrp,项目名称:eZ-Publish-Training-examples,代码行数:31,代码来源:trainingservercallfunctions.php
示例10: 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;
}
开发者ID:EVE-Corp-Center,项目名称:ECC-Website,代码行数:31,代码来源:ezsimplestockchecktype.php
示例11: gather
static function gather()
{
$contentTypes = array('Objects (including users)' => array('table' => 'ezcontentobject'), 'Users' => array('table' => 'ezuser'), 'Nodes' => array('table' => 'ezcontentobject_tree'), 'Content Classes' => array('table' => 'ezcontentclass'), 'Information Collections' => array('table' => 'ezinfocollection'), 'Pending notification events' => array('table' => 'eznotificationevent', 'wherecondition' => 'status = 0'), 'Objects pending indexation' => array('table' => 'ezpending_actions', 'wherecondition' => "action = 'index_object'"), 'Binary files (content)' => array('table' => 'ezbinaryfile'), 'Image files (content)' => array('table' => 'ezimagefile'), 'Media files (content)' => array('table' => 'ezmedia'), 'Maximum children per node' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_tree GROUP BY parent_node_id ) nodes'), 'Maximum nodes per object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_tree GROUP BY contentobject_id ) nodes'), 'Maximum incoming relations to an object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_link GROUP BY to_contentobject_id ) links', 'nvl' => 0), 'Maximum outgoing relations from an object' => array('sql' => 'SELECT MAX(tot) AS NUM FROM ( SELECT count(*) AS tot FROM ezcontentobject_link GROUP BY from_contentobject_id ) links', 'nvl' => 0));
$db = eZDB::instance();
$contentList = array();
foreach ($contentTypes as $key => $desc) {
if (isset($desc['table'])) {
$sql = 'SELECT COUNT(*) AS NUM FROM ' . $desc['table'];
if (@$desc['wherecondition']) {
$sql .= ' WHERE ' . $desc['wherecondition'];
}
} else {
$sql = $desc['sql'];
}
$count = $db->arrayQuery($sql);
$contentList[$key] = $count[0]['NUM'] === null ? $desc['nvl'] : $count[0]['NUM'];
}
if (in_array('ezfind', eZExtension::activeExtensions())) {
$ini = eZINI::instance('solr.ini');
$ezfindpingurl = $ini->variable('SolrBase', 'SearchServerURI') . "/admin/stats.jsp";
$data = eZHTTPTool::getDataByURL($ezfindpingurl, false);
//var_dump( $data );
if (preg_match('#<stat +name="numDocs" ?>([^<]+)</stat>#', $data, $matches)) {
$contentList['Documents in SOLR'] = trim($matches[1]);
} else {
$contentList['Documents in SOLR'] = 'Unknown';
}
}
return $contentList;
}
开发者ID:gggeek,项目名称:ggsysinfo,代码行数:30,代码来源:contentstatsgatherer.php
示例12: 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!');
}
开发者ID:netgen,项目名称:ngpush,代码行数:25,代码来源:ezjscorengpush.php
示例13: setState
public function setState()
{
$http = eZHTTPTool::instance();
if ($http->hasGetVariable('state')) {
$this->connection->setState(base64_encode($http->getVariable('state')));
}
}
开发者ID:sdaoudi,项目名称:nxc_social_networks,代码行数:7,代码来源:google.php
示例14: fetchAccountInformation
function fetchAccountInformation(&$module)
{
$http = eZHTTPTool::instance();
$http->setSessionVariable('RedirectAfterLogin', '/shop/basket/');
$http->setSessionVariable('DoCheckoutAutomatically', true);
$module->redirectTo('/user/login/');
}
开发者ID:patrickallaert,项目名称:ezpublish-legacy-php7,代码行数:7,代码来源:ezdefaultshopaccounthandler.php
示例15: acquireToken
/**
* @return string
*/
protected function acquireToken()
{
$response = eZHTTPTool::getDataByURL($this->tokenAcquireApiUrl);
$xml = simplexml_load_string($response);
return (string)$xml->data->string;
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:10,代码来源:externallinkhandlermedienspiegel.php
示例16: test_createRedirectUrl
/**
* Some parts of eZ do not benefit from the enhanced checks implemented
* in eZSys::isSSLNow(), especially when using an SSL reverse proxy
* configured to send the HTTP_X_FORWARDED_PROTO header.
*
* @link http://issues.ez.no/21731
*/
public function test_createRedirectUrl()
{
$path = '/a/root/rel/ative';
self::assertEquals('http://example.com' . $path, eZHTTPTool::createRedirectUrl($path, array()));
$_SERVER['HTTP_X_FORWARDED_PROTO'] = 'https';
self::assertEquals('https://example.com' . $path, eZHTTPTool::createRedirectUrl($path, array()));
unset($_SERVER['HTTP_X_FORWARDED_PROTO']);
}
开发者ID:mugoweb,项目名称:ezpublish-legacy,代码行数:15,代码来源:ezhttptool_regression.php
示例17: fetchObjectAttributeHTTPInput
/**
* Fetches the HTTP POST input and stores it in the data instance
*
* @param eZHTTPTool $http
* @param string $base
* @param eZContentObjectAttribute $contentObjectAttribute
*
* @return bool
*/
function fetchObjectAttributeHTTPInput($http, $base, $contentObjectAttribute)
{
$classList = $http->postVariable($base . self::CLASS_LIST_VARIABLE . $contentObjectAttribute->attribute("id"), array());
$classList = !is_array($classList) ? array() : $classList;
$validClassIdentifiers = array();
foreach ($classList as $classIdentifier) {
if (eZContentClass::exists($classIdentifier, eZContentClass::VERSION_STATUS_DEFINED, false, true)) {
$validClassIdentifiers[] = $classIdentifier;
}
}
if (!empty($validClassIdentifiers)) {
$contentObjectAttribute->setAttribute(self::CLASS_LIST_FIELD, implode(",", $validClassIdentifiers));
} else {
$contentObjectAttribute->setAttribute(self::CLASS_LIST_FIELD, "");
}
return true;
}
开发者ID:netgen,项目名称:ngclasslist,代码行数:26,代码来源:ngclasslisttype.php
示例18: getMediaRecent
public function getMediaRecent($pageID = false, $limit = 20)
{
$result = array('result' => array());
$accumulator = $this->debugAccumulatorGroup . '_instagram_media_recent';
eZDebug::accumulatorStart($accumulator, $this->debugAccumulatorGroup, 'media_recent');
$cacheFileHandler = $this->getCacheFileHandler('_media_recent', array($pageID, $limit));
try {
if ($this->isCacheExpired($cacheFileHandler)) {
eZDebug::writeDebug(array('page_id' => $pageID, 'limit' => $limit), self::$debugMessagesGroup);
$items = array();
$userData = eZHTTPTool::getDataByURL('https://api.instagram.com/v1/users/search?' . 'q=' . $pageID . '&' . 'client_id=' . $this->API['key']);
$userID = false;
if ($userData !== false) {
$userDataArray = json_decode($userData, true);
if (count($userDataArray['data'])) {
foreach ($userDataArray['data'] as $user) {
if ($user['username'] == $pageID) {
$userID = $user['id'];
break;
}
}
}
}
if ($userID !== false) {
$leftLimit = $limit;
$feedData = eZHTTPTool::getDataByURL('https://api.instagram.com/v1/users/' . $userID . '/media/recent/?' . 'access_token=' . $this->API['token']);
if ($feedData !== false) {
$feedDataArray = json_decode($feedData, true);
if (isset($feedDataArray['data'])) {
$items = array_merge($items, array_slice($feedDataArray['data'], 0, $leftLimit));
$leftLimit = $leftLimit - count($feedDataArray['data']);
}
$endlessLoopBreaker = 0;
while ($endlessLoopBreaker < 50 && $leftLimit > 0 && isset($feedDataArray['pagination']['next_url'])) {
$endlessLoopBreaker++;
$feedData = eZHTTPTool::getDataByURL($feedDataArray['pagination']['next_url']);
if ($feedData !== false) {
$feedDataArray = json_decode($feedData, true);
$items = array_merge($items, array_slice($feedDataArray['data'], 0, $leftLimit));
}
$leftLimit = $leftLimit - count($feedDataArray['data']);
}
}
}
$cacheFileHandler->fileStoreContents($cacheFileHandler->filePath, serialize($items));
} else {
$items = unserialize($cacheFileHandler->fetchContents());
}
eZDebug::accumulatorStop($accumulator);
$result['result'] = $items;
return $result;
} catch (Exception $e) {
eZDebug::accumulatorStop($accumulator);
eZDebug::writeError($e->getMessage(), self::$debugMessagesGroup);
return $result;
}
}
开发者ID:sdaoudi,项目名称:nxc_social_networks,代码行数:57,代码来源:instagram.php
示例19: 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 ) );
}
}
}
}
开发者ID:sushilbshinde,项目名称:ezpublish-study,代码行数:57,代码来源:section_edit.php
示例20: 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;
}
开发者ID:netgen,项目名称:ngconnect,代码行数:62,代码来源:ngconnectauthtwitter.php
注:本文中的eZHTTPTool类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论