Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fixed EZP-20451: block_view_gui for a manual fetched block don't use …
…override templates

(cherry picked from commit 47db424)
  • Loading branch information
patrickallaert committed Jul 3, 2013
1 parent 027e135 commit 6c408ba
Showing 1 changed file with 38 additions and 8 deletions.
Expand Up @@ -365,20 +365,50 @@ public function removeProcessed()
* @param bool $asObject
* @return eZPageBlock
*/
public function fetch( $blockID, $asObject = true )
static public function fetch( $blockID, $asObject = true )
{
$db = eZDB::instance();
$row = $db->arrayQuery( "SELECT * FROM ezm_block WHERE id='$blockID'" );

if ( $asObject )
$row = $db->arrayQuery(
"SELECT zone_id, name, node_id, overflow_id, last_update, block_type as type, fetch_params, rotation_type, rotation_interval " .
"FROM ezm_block WHERE id='" . $db->escapeString( $blockID ) . "'"
);

$xmlDocs = $db->arrayQuery(
"SELECT oa.data_text " .
"FROM ezcontentobject_tree AS t " .
"INNER JOIN ezcontentobject AS o ON t.contentobject_id = o.id " .
"INNER JOIN ezcontentobject_attribute AS oa ON o.id = oa.contentobject_id AND o.current_version = oa.version " .
"WHERE t.node_id = " . $row[0]["node_id"] . " AND data_type_string = '" . eZPageType::DATA_TYPE_STRING . "'"
);

$pageBlock = null;

foreach ( $xmlDocs as $xmlDoc )
{
$block = new eZPageBlock( null, $row[0] );
return $block;
$doc = new DOMDocument;
$doc->loadXML( $xmlDoc["data_text"] );

$xpath = new DOMXPath( $doc );
foreach ( $xpath->evaluate( '//block[@id="id_' . $blockID . '"]' ) as $result )
{
$pageBlock = self::createFromXML( $result );

// We are only interested by the first match (which is unique)
break;
}
}
else

if ( $pageBlock !== null )
{
return $row[0];
if ( $asObject )
{
return $pageBlock;
}

$row[0] += array( "id" => $blockID, "view" => $pageBlock->attribute( "view" ) );
}

return $asObject ? new eZPageBlock( null, $row[0] ) : $row[0];
}

/**
Expand Down

0 comments on commit 6c408ba

Please sign in to comment.