/** * Returns a node data for given object / node id * * Following parameters are supported: * ezjscnode::load::embed_id[::attribute[::load_image_size]] * * eg: ezjscnode::load::ezobject_46::image::large * eg: ezjscnode::load::eznode_44::summary *eg: ezjscnode::load::44::summary (44 is in this case node id) * * @since 1.2 * @param mixed $args * @throws InvalidArgumentException * @return array */ public static function load($args) { $embedObject = false; if (isset($args[0]) && $args[0]) { $embedType = 'eznode'; if (is_numeric($args[0])) { $embedId = $args[0]; } else { list($embedType, $embedId) = explode('_', $args[0]); } if ($embedType === 'eznode' || strcasecmp($embedType, 'eznode') === 0) { $embedObject = eZContentObject::fetchByNodeID($embedId); } else { $embedObject = eZContentObject::fetch($embedId); } } if (!$embedObject instanceof eZContentObject) { throw new InvalidArgumentException("Argument 1: '{$embedType}\\_{$embedId}' does not map to a valid content object"); } else { if (!$embedObject->canRead()) { throw new InvalidArgumentException("Argument 1: '{$embedType}\\_{$embedId}' is not available"); } } // Params for node to json encoder $params = array('loadImages' => true); $params['imagePreGenerateSizes'] = array('small', 'original'); // look for attribute parameter ( what attribute we should load ) if (isset($args[1]) && $args[1]) { $params['dataMap'] = array($args[1]); } // what image sizes we want returned with full data ( url++ ) if (isset($args[2]) && $args[2]) { $params['imagePreGenerateSizes'][] = $args[2]; } // Simplify and load data in accordance to $params return ezjscAjaxContent::simplify($embedObject, $params); }