function fetchBlock($blockID) { $result = array('result' => eZPageBlock::fetch($blockID)); return $result; }
/** * Creates and return eZPageBlock object from given XML * * @static * @param DOMElement $node * @return eZPageBlock */ public static function createFromXML( DOMElement $node ) { $newObj = new eZPageBlock(); if ( $node->hasAttributes() ) { foreach ( $node->attributes as $attr ) { if ( $attr->name == 'id' ) { $value = explode( '_', $attr->value ); $newObj->setAttribute( $attr->name, $value[1] ); } else { $newObj->setAttribute( $attr->name, $attr->value ); } } } foreach ( $node->childNodes as $node ) { if ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'item' ) { $blockItemNode = eZPageBlockItem::createFromXML( $node ); $newObj->addItem( $blockItemNode ); } elseif ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'rotation' ) { $attrValue = array(); foreach ( $node->childNodes as $subNode ) { if ( $subNode->nodeType == XML_ELEMENT_NODE ) $attrValue[$subNode->nodeName] = $subNode->nodeValue; } $newObj->setAttribute( $node->nodeName, $attrValue ); } elseif ( $node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'custom_attributes' ) { $attrValue = array(); foreach ( $node->childNodes as $subNode ) { if ( $subNode->nodeType == XML_ELEMENT_NODE ) $attrValue[$subNode->nodeName] = $subNode->nodeValue; } $newObj->setAttribute( $node->nodeName, $attrValue ); } else { if ( $node->nodeType == XML_ELEMENT_NODE ) $newObj->setAttribute( $node->nodeName, $node->nodeValue ); } } return $newObj; }
/** * Creates and return eZPageZone object from given XML * * @static * @param DOMElement $node * @return eZPageZone */ public static function createFromXML(DOMElement $node) { $newObj = new eZPageZone(); if ($node->hasAttributes()) { foreach ($node->attributes as $attr) { if ($attr->name == 'id') { $value = explode('_', $attr->value); $newObj->setAttribute($attr->name, $value[1]); } else { $newObj->setAttribute($attr->name, $attr->value); } } } foreach ($node->childNodes as $node) { if ($node->nodeType == XML_ELEMENT_NODE && $node->nodeName == 'block') { $blockNode = eZPageBlock::createFromXML($node); $newObj->addBlock($blockNode); } elseif ($node->nodeType == XML_ELEMENT_NODE) { $newObj->setAttribute($node->nodeName, $node->nodeValue); } } return $newObj; }
// GNU General Public License for more details. // // You should have received a copy of version 2.0 of the GNU General // Public License along with this program; if not, write to the Free // Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, // MA 02110-1301, USA. // // // ## END COPYRIGHT, LICENSE AND WARRANTY NOTICE ## // include_once 'extension/ezflow/classes/ezpageblock.php'; include_once 'extension/ezflow/classes/ezpageblockitem.php'; $module = $Params['Module']; $blockID = $Params['BlockID']; $output = $Params['Output']; $block = eZPageBlock::fetch($blockID); $tpl = eZTemplate::factory(); $tpl->setVariable('block', $block); $template = 'design:page/block.tpl'; if (!isset($output)) { $output = 'xhtml'; } switch (strtolower($output)) { case 'json': $template = 'design:page/preview.tpl'; $obj = new stdClass(); foreach ($block->attributes() as $attr) { if (!in_array($attr, array('waiting', 'valid', 'valid_nodes', 'archived'))) { $obj->{$attr} = $block->attribute($attr); } }