Permalink
Browse files

CS: fixed various space issues

  • Loading branch information...
1 parent 86b95e1 commit 19b4a2d92c476fcfea199a80c78f412390776f5c @patrickallaert patrickallaert committed with Mar 15, 2012
@@ -262,7 +262,11 @@ public function checkTarget( $iterator=null )
* @todo prevent loops
* @todo smarter checking: if node x is not there all its children can not be there either
*/
+<<<<<<< HEAD
public function checkNode( $node, $recursive=true, $iterator=false, $transport=false )
+=======
+ function checkNode( $node, $recursive = true, $transport = false )
+>>>>>>> d3f2787... CS: fixed various space issues
{
//static $testedobjects;
//$objectID = $object->attribute( 'id' );
@@ -246,7 +246,11 @@ static public function fetch( $id, $asObject = true )
* and by event type.
* @todo refactor: asObject as last param
*/
+<<<<<<< HEAD
static public function fetchByObject( $object_id, $target_id = null, $to_sync = null, $asObject = true, $language=null )
+=======
+ static function fetchByObject( $object_id, $target_id = null, $to_sync = null, $asObject = true, $language = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$conds = array( 'object_id' => $objectId );
if ( $target_id != null )
@@ -280,7 +284,11 @@ static public function fetchByObject( $object_id, $target_id = null, $to_sync =
* @return array of eZContentStagingEvent
* @todo refactor: asObject as last param
*/
+<<<<<<< HEAD
static public function fetchByNode( $nodeId, $objectId=null, $target_id=null, $asObject=true, $language=null )
+=======
+ static function fetchByNode( $nodeId, $objectId = null, $target_id = null, $asObject = true, $language = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
if ( $objectId == null )
{
@@ -321,7 +329,11 @@ static public function fetchByNode( $nodeId, $objectId=null, $target_id=null, $a
* array where the key is the feed id
* @return array of array of eZContentStagingEvent
*/
+<<<<<<< HEAD
static public function fetchByNodeGroupedByTarget( $nodeId, $objectId=null, $language=null )
+=======
+ static function fetchByNodeGroupedByTarget( $nodeId, $objectId = null, $language = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$targets = array();
$events = self::fetchByNode( $nodeId, $objectId, null, true, $language );
@@ -335,7 +347,11 @@ static public function fetchByNodeGroupedByTarget( $nodeId, $objectId=null, $lan
/**
* @todo refactor: asObject as last param
*/
+<<<<<<< HEAD
static public function fetchListGroupedByObject( $target_id=null, $asObject= true, $offset=null, $limit=null, $language=null )
+=======
+ static function fetchListGroupedByObject( $target_id = null, $asObject = true, $offset = null, $limit = null, $language = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$conditions = array();
if ( $target_id != '' )
@@ -397,7 +413,11 @@ static public function fetchListGroupedByObject( $target_id=null, $asObject= tru
*
* @todo refactor: asObject as last param
*/
+<<<<<<< HEAD
static public function fetchList( $target_id=null, $asObject= true, $offset=null, $limit=null, $language=null, $status=null )
+=======
+ static function fetchList( $target_id = null, $asObject = true, $offset = null, $limit = null, $language = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$conditions = array();
if ( $target_id != '' )
@@ -491,7 +511,11 @@ static function fetchSumUpList( $target_id=false, $asObject = true, $offset = fa
* Returns count of events to sync to a given server
* @return integer
*/
+<<<<<<< HEAD
static public function fetchListCount( $target_id=null, $language=null, $status=null )
+=======
+ static function fetchListCount( $target_id = null, $language = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$conditions = array();
if ( $target_id != '' )
@@ -547,7 +571,11 @@ static protected function languagesSQLFilter( $language )
* @todo add intelligent deduplication, eg: if there is an hide event then a show one,
* do not add show but remove hide, etc...
*/
+<<<<<<< HEAD
static public function addEvent( $targetId, $objectId, $action, $data, $nodeIds=array(), $langMask=null )
+=======
+ static function addEvent( $targetId, $objectId, $action, $data, $nodeIds = array(), $langMask = null )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$event = new eZContentStagingEvent( array(
'target_id' => $targetId,
@@ -707,7 +735,11 @@ static public function syncEvents( array $events, $iterator=null )
*
* @todo return real number of deleted events - this is not really atomic...
*/
+<<<<<<< HEAD
static public function removeEvents( $eventIDList, $also_syncing=false )
+=======
+ static function removeEvents( $eventIDList, $also_syncing = false )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$db = eZDB::instance();
if ( !$also_syncing )
@@ -732,7 +764,11 @@ static public function removeEvents( $eventIDList, $also_syncing=false )
*
* @todo return real number of deleted events - this is not really atomic...
*/
+<<<<<<< HEAD
static public function removeEventsByTargets( $targetIDList, $also_syncing=false )
+=======
+ static function removeEventsByTargets( $targetIDList, $also_syncing = false )
+>>>>>>> d3f2787... CS: fixed various space issues
{
$db = eZDB::instance();
foreach ( $targetIDList as $key => $val )
@@ -21,7 +21,11 @@ public function __construct( $target )
* Uses local id on source as remote id on target server, with a prefix
* @todo verify that remote id built is not longer than 32 chars
*/
+<<<<<<< HEAD
public function buildRemoteId( $sourceId, $sourceRemoteId, $type='node' )
+=======
+ function buildRemoteId( $sourceId, $sourceRemoteId, $type = 'node' )
+>>>>>>> d3f2787... CS: fixed various space issues
{
return "ezcs:" . $this->target . ':' . $sourceId;
}
@@ -17,7 +17,11 @@ public function __construct( $target )
/**
* Uses the same remote id on source and on target server
*/
+<<<<<<< HEAD
public function buildRemoteId( $sourceId, $sourceRemoteId, $type='node' )
+=======
+ function buildRemoteId( $sourceId, $sourceRemoteId, $type = 'node' )
+>>>>>>> d3f2787... CS: fixed various space issues
{
return $sourceRemoteId;
}
@@ -653,7 +653,7 @@ static protected function encodeLanguageId( $value )
/**
* @todo !important implement factory pattern - store $generator for speed
*/
- protected function buildRemoteId( $sourceId, $sourceRemoteId, $type='node' )
+ protected function buildRemoteId( $sourceId, $sourceRemoteId, $type = 'node' )
{
$generator = $this->getRemoteIdGenerator();
return $generator ? $generator->buildRemoteId( $sourceId, $sourceRemoteId, $type ) : $sourceRemoteId ;
@@ -187,7 +187,7 @@ static protected function updateAttributesList( array $attributes, array $fields
* @todo fix object publication date if the parameter is received
* @todo change user id if the parameter is received
*/
- static public function createContent( eZContentObjectTreeNode $parent, $input, $sectionId=null )
+ static public function createContent( eZContentObjectTreeNode $parent, $input, $sectionId = null )
{
$class = eZContentClass::fetchByIdentifier( $input['contentType'] );
if ( !$class instanceof eZContentClass )
@@ -330,7 +330,7 @@ static public function publishVersion( eZContentObject $object, eZContentObjectV
* @todo make more params optional: $newNodeRemoteId
* @todo perms checking: Is it doen always by called code?
*/
- static public function addLocation( eZContentObject $object, eZContentObjectTreeNode $parent, $newNodeRemoteId, $priority=null, $sortField=null, $sortOrder=null )
+ static public function addLocation( eZContentObject $object, eZContentObjectTreeNode $parent, $newNodeRemoteId, $priority = null, $sortField = null, $sortOrder = null )
{
if ( $priority !== null )
{
@@ -738,7 +738,7 @@ static public function decodeValue( $attribute, $value )
{
$zoneBlocksIds[$i] = $db->escapeString( $v );
}
- $db->query( "DELETE from ezm_block WHERE zone_id='" . $db->escapeString( $pageZone->attribute( 'id' ) ) . "' AND id NOT IN ('" . implode( "', '", $zoneBlocksIds ). "')" );
+ $db->query( "DELETE from ezm_block WHERE zone_id = '" . $db->escapeString( $pageZone->attribute( 'id' ) ) . "' AND id NOT IN ('" . implode( "', '", $zoneBlocksIds ). "')" );
}
else
{
@@ -0,0 +1,131 @@
+<?php
+/**
+ * Class used to wrap REST responses.
+ * Needs the json ext. for json
+ *
+ * @author G. Giunta
+ * @copyright (C) 2009-2012 G. Giunta
+ */
+
+class eZRESTResponse
+{
+ const INVALIDRESPONSEERROR = -301;
+
+ /// @todo use a single array for all error strings
+ const INVALIDRESPONSESTRING = 'Response received from server is not valid';
+
+ /// Contains the response value
+ protected $Value = false;
+ /// Contains fault string
+ protected $FaultString = false;
+ /// Contains the fault code
+ protected $FaultCode = false;
+ /// Contains true if the response was an fault
+ protected $IsFault = false;
+ /// Contains the name of the response, i.e. function call name
+ protected $Name;
+
+ public function __construct( $name = '' )
+ {
+ $this->Name = $name;
+ }
+
+ /**
+ * Returns true if the response was a fault
+ */
+ public function isFault()
+ {
+ return $this->IsFault;
+ }
+
+ /**
+ * Returns the fault code
+ */
+ public function faultCode()
+ {
+ return $this->FaultCode;
+ }
+
+ /**
+ * Returns the fault string
+ */
+ public function faultString()
+ {
+ return $this->FaultString;
+ }
+
+ /**
+ * Returns the response value as plain php value
+ */
+ public function value()
+ {
+ return $this->Value;
+ }
+
+ /**
+ * Sets the value of the response (plain php value).
+ * If $values is (subclass of) eZRESTFault, sets the response to error state.
+ */
+ public function setValue( $value )
+ {
+ $this->Value = $value;
+ if ( $value instanceof eZRESTFault )
+ {
+ $this->IsFault = true;
+ $this->FaultCode = $value->faultCode();
+ $this->FaultString = $value->faultString();
+ }
+ else
+ {
+ $this->IsFault = false;
+ }
+ }
+
+ /**
+ * Decodes the REST response stream.
+ * Request is not used, kept for compat with sibling classes
+ * Name is not set to response from request - a bit weird...
+ */
+ public function decodeStream( $request, $stream, $headers = false, $cookies = array(), $statuscode = "200" )
+ {
+ $this->Cookies = $cookies;
+
+ // Allow empty payloads regardless of declared content type, for 204 and 205 responses
+ if ( $statuscode == '204' || $statuscode == '205' )
+ {
+ if ( $stream == '' && ( !isset( $headers['content-length'] ) || $headers['content-length'] == 0 ) )
+ {
+ $this->Value = null;
+ $this->IsFault = false;
+ $this->FaultString = false;
+ $this->FaultCode = false;
+ return;
+ }
+
+ /// @todo this is not valid according to rfc 2616 - but we should leave that control to client really
+ $this->IsFault = true;
+ $this->FaultCode = self::INVALIDRESPONSEERROR;
+ $this->FaultString = self::INVALIDRESPONSESTRING . " (received http response 204/205 with a body. Not valid http)";
+ }
+
+ $val = json_decode( $stream, true );
+ if ( function_exists( 'json_last_error' ) )
+ {
+ $err = json_last_error();
+ }
+ else
+ {
+ $err = ( $val === null ) ? 1 : false;
+ }
+ if ( $err )
+ {
+ $this->IsFault = true;
+ $this->FaultCode = self::INVALIDRESPONSEERROR;
+ $this->FaultString = self::INVALIDRESPONSESTRING . ' json. Decoding error: ' . $err;
+ }
+ else
+ {
+ $this->Value = $val;
+ }
+ }
+}
@@ -87,11 +87,11 @@ public function execute( $process, $event )
/*
if ( $version->attribute( 'status' ) != eZContentObjectVersion::STATUS_PUBLISHED )
{
- eZDebug::writeNotice( "Object not published(status: " . $version->attribute('status') . "), no syndication needed.", 'eZStagePublishType::execute' );
+ eZDebug::writeNotice( "Object not published(status: " . $version->attribute( 'status' ) . "), no syndication needed.", 'eZStagePublishType::execute' );
return eZWorkflowType::STATUS_ACCEPTED;
}
- $parentNodeId = $version->attribute('main_parent_node_id');
+ $parentNodeId = $version->attribute( 'main_parent_node_id' );
$parentNode = eZContentObjectTreeNode::fetch( $parentNodeId );
if ( !is_object( $parentNode ) )
@@ -102,7 +102,7 @@ public function execute( $process, $event )
$assignedNodeRemoteIds = array();
$assignedNodes = $object->assignedNodes();
- $mainNode = $object->attribute('main_node');
+ $mainNode = $object->attribute( 'main_node' );
foreach ( $assignedNodes as $assignedNode )
{
$assignedNodeRemoteIds[] = $assignedNode->attribute( 'remote_id' );
@@ -126,13 +126,13 @@ public function execute( $process, $event )
'node_remote_id' => $parentNodeRemoteID,
'timestamp' => $time,
'action' => eZSyndicationNodeActionLog::ACTION_PUBLISH,
- 'options' => serialize( array( 'object_remote_id' => $object->attribute('remote_id'),
- 'object_modified' => $object->attribute('modified'),
- 'version_created' => $version->attribute('created'),
- 'version_modified' => $version->attribute('modified'),
- 'version_language_mask' => $version->attribute('language_mask'),
+ 'options' => serialize( array( 'object_remote_id' => $object->attribute( 'remote_id' ),
+ 'object_modified' => $object->attribute( 'modified' ),
+ 'version_created' => $version->attribute( 'created' ),
+ 'version_modified' => $version->attribute( 'modified' ),
+ 'version_language_mask' => $version->attribute( 'language_mask' ),
'assigned_nodes' => $assignedNodeRemoteIds,
- 'main_node' => $mainNode->attribute('remote_id')
+ 'main_node' => $mainNode->attribute( 'remote_id' )
) ) ) );
$log->store();
@@ -21,5 +21,5 @@ public function __construct( $target );
* @todo This interface is crappy. Let's receive an object instead, and get the
* remote_id from it...
*/
- public function buildRemoteId( $sourceId, $sourceRemoteId, $type='node' );
-}
+ public function buildRemoteId( $sourceId, $sourceRemoteId, $type = 'node' );
+}
Oops, something went wrong. Retry.

0 comments on commit 19b4a2d

Please sign in to comment.