/** * @param RokSprocket_ItemCollection $items * * @param $module_id * * @throws RokSprocket_Exception */ protected function mapPerItemData(RokSprocket_ItemCollection &$items, $module_id) { global $wpdb; $query = 'SELECT i.provider_id as id, i.order, i.params'; $query .= ' FROM #__roksprocket_items as i'; $query .= ' WHERE i.widget_id = "' . $module_id . '"'; $query .= ' AND i.provider = "' . RokSprocket_Provider_Simple_Storage_Interface::PROVIDER_NAME . '"'; $query = str_replace('#__', $wpdb->prefix, $query); //add wp db prefix $sprocket_items = $wpdb->get_results($query, OBJECT_K); if ($sprocket_items === false) { throw new RokSprocket_Exception($wpdb->last_error); } /** @var $items RokSprocket_Item[] */ foreach ($items as $item_id => &$item) { list($provider, $id) = explode('-', $item_id); if (array_key_exists($id, $sprocket_items)) { $items[$item_id]->setOrder((int) $sprocket_items[$id]->order); if (!is_null($sprocket_items[$id]->params)) { $items[$item_id]->setParams(RokCommon_Utils_ArrayHelper::fromObject(RokCommon_JSON::decode($sprocket_items[$id]->params))); } else { $items[$item_id]->setParams(array()); } } } }
/** * @param RokSprocket_ItemCollection $items * * @param string $module_id * * @throws RokSprocket_Exception */ protected function mapPerItemData(RokSprocket_ItemCollection &$items, $module_id) { $db = JFactory::getDbo(); $query = $db->getQuery(true); $query->select('i.provider_id as id, i.order, i.params')->from('#__roksprocket_items as i'); $query->where('i.module_id = ' . $db->quote($module_id)); $query->where('i.provider = ' . $db->quote(RokSprocket_Provider_Simple_Storage_Interface::PROVIDER_NAME)); $db->setQuery($query); $sprocket_items = $db->loadObjectList('id'); if ($error = $db->getErrorMsg()) { throw new RokSprocket_Exception($error); } /** @var $items RokSprocket_Item[] */ foreach ($items as $item_id => &$item) { list($provider, $id) = explode('-', $item_id); if (array_key_exists($id, $sprocket_items)) { $items[$item_id]->setOrder((int) $sprocket_items[$id]->order); if (null != $sprocket_items[$id]->params) { $decoded = null; try { $decoded = RokCommon_Utils_ArrayHelper::fromObject(RokCommon_JSON::decode($sprocket_items[$id]->params)); } catch (RokCommon_JSON_Exception $jse) { } $items[$item_id]->setParams($decoded); } else { $items[$item_id]->setParams(array()); } } } }
/** * @static * * @param $json * * @return bool|null|RokSprocket_Item_Image */ public static function createFromJSON($json) { $container = RokCommon_Service::getContainer(); /** @var $logger RokCommon_Logger */ $logger = $container->roksprocket_logger; $image = null; if (!empty($json)) { $image = new self(); $json_decode = null; try { $json_decode = RokCommon_JSON::decode(str_replace("'", '"', str_replace('\\', '', $json))); } catch (RokCommon_JSON_Exception $jse) { $logger->warning("Unable to decode image JSON : " . $json); } if (!$json_decode) { return false; } $image->source = $json_decode->path; $size = array(0, 0); $image_source = $json_decode->path; if (!preg_match('#^http\\w?://#i', $image_source)) { if (preg_match('#^/#', $image_source)) { if (preg_match('#^' . $container->platforminfo->getUrlBase() . '/#', $image_source)) { //its in our app size it $image_source = preg_replace('#^' . $container->platforminfo->getUrlBase() . '/#', '', $image_source); $size_check_path = $container->platforminfo->getRootPath() . '/' . $image_source; } else { $size_check_path = $image_source; } } else { $size_check_path = $container->platforminfo->getRootPath() . '/' . $image_source; } $image->filepath = $size_check_path; /// if the image source doesnt start with / assume its relative to root } else { $size_check_path = $image_source; } if (!empty($image->filepath) && file_exists($image->filepath)) { $size = @getimagesize($size_check_path); if (!empty($size)) { $size[0] = $size[0] ? $size[0] : '100%'; $size[1] = $size[1] ? $size[1] : '100%'; } $image->width = $size[0]; $image->height = $size[1]; } } return $image; }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { $app_type = $this->params->get('zoo_application_type'); //$textfield = $this->params->get('zoo_articletext_field', ''); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias($raw_item->alias); $item->setAuthor($raw_item->author_name); $item->setTitle($raw_item->title); $item->setDate($raw_item->created); $item->setPublished($raw_item->published == 1 ? true : false); $item->setCategory($raw_item->category_title); $item->setHits($raw_item->hits); $item->setRating($raw_item->rating); $item->setMetaKey(''); $item->setMetaDesc(''); $item->setMetaData(''); require_once JPATH_ADMINISTRATOR . '/components/com_zoo/config.php'; $app = App::getInstance('zoo'); $applications = $app->application->getApplications(); $application = $applications[$raw_item->application_id]; $text_ids = array(); $image_ids = array(); $link_ids = array(); $types = $application->getTypes(); foreach ($types as $type) { $elements = $type->getElements(); foreach ($elements as $element) { if ($element->config->type == 'image') { $image_ids[] = $element->identifier; } if ($element->config->type == 'link') { $link_ids[] = $element->identifier; } if ($element->config->type == 'textarea' || $element->config->type == 'text') { $text_ids[] = $element->identifier; } } } $els = json_decode($raw_item->elements); $texts = array(); $images = array(); $links = array(); foreach ($els as $ident => $el) { if (in_array($ident, $image_ids)) { $image = new RokSprocket_Item_Image(); $image->setSource($el->file); $image->setIdentifier('image_field_' . $ident); $image->setCaption(isset($el->title) ? $el->title : ''); $image->setAlttext(isset($el->title) ? $el->title : ''); $images[$image->getIdentifier()] = $image; if (isset($images['image_field_' . $ident]) && !$item->getPrimaryImage()) { $item->setPrimaryImage($image); } } if (in_array($ident, $link_ids)) { $link = new RokSprocket_Item_Link(); $link->setUrl(isset($el->url) ? $el->url : (isset($el->value) ? $el->value : '')); $link->setText(''); $link->setIdentifier('link_field_' . $ident); $links[$link->getIdentifier()] = $link; if (isset($links['link_field_' . $ident]) && !$item->getPrimaryLink()) { $item->setPrimaryLink($link); } } if (in_array($ident, $text_ids) && is_object($el)) { foreach ($el as $val) { $texts['text_field_' . $ident] = $val->value; } } else { if (in_array($ident, $text_ids) && !is_object($el)) { $texts['text_field_' . $ident] = $el->value; } } } $item->setLinks($images); $item->setLinks($links); $params = RokCommon_JSON::decode($raw_item->params); $desc = "metadata.description"; $texts['text_field_metadesc'] = $params->{$desc}; $item->setTextFields($texts); $item->setText(array_shift(array_values($texts))); $primary_link = new RokSprocket_Item_Link(); $primary_link->setUrl(JRoute::_('index.php?option=com_zoo&task=item&item_id=' . $raw_item->id, true)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); $item->setCommentCount($raw_item->comment_count); $tags = explode(',', $raw_item->tags) ? explode(',', $raw_item->tags) : array(); $item->setTags($tags); $item->setDbOrder($dborder); return $item; }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { require_once JPath::clean(JPATH_SITE . '/components/com_content/helpers/route.php'); if (file_exists(JPath::clean(JPATH_SITE . '/libraries/joomla/html/html/content.php'))) { require_once JPath::clean(JPATH_SITE . '/libraries/joomla/html/html/content.php'); } if (class_exists('JModelLegacy')) { JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel'); } //$textfield = $this->params->get('joomla_articletext_field', ''); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias($raw_item->alias); $item->setAuthor($raw_item->created_by_alias ? $raw_item->created_by_alias : $raw_item->author_name); $item->setTitle($raw_item->title); $item->setDate($raw_item->created); $item->setPublished($raw_item->state == 1 ? true : false); $item->setCategory($raw_item->category_title); $item->setHits($raw_item->hits); $item->setRating($raw_item->rating); $item->setMetaKey($raw_item->metakey); $item->setMetaDesc($raw_item->metadesc); $item->setMetaData($raw_item->metadata); $item->setPublishUp($raw_item->publish_up); $item->setPublishDown($raw_item->publish_down); $images = array(); if (isset($raw_item->images) && !empty($raw_item->images)) { try { $raw_images = RokCommon_JSON::decode($raw_item->images); if (isset($raw_images->image_intro) && !empty($raw_images->image_intro)) { $image_intro = new RokSprocket_Item_Image(); $image_intro->setSource($raw_images->image_intro); $image_intro->setIdentifier('image_intro'); $image_intro->setCaption($raw_images->image_intro_caption); $image_intro->setAlttext($raw_images->image_intro_alt); $images[$image_intro->getIdentifier()] = $image_intro; } if (isset($raw_images->image_fulltext) && !empty($raw_images->image_fulltext)) { $image_fulltext = new RokSprocket_Item_Image(); $image_fulltext->setSource($raw_images->image_fulltext); $image_fulltext->setIdentifier('image_fulltext'); $image_fulltext->setCaption($raw_images->image_fulltext_caption); $image_fulltext->setAlttext($raw_images->image_fulltext_alt); $images[$image_fulltext->getIdentifier()] = $image_fulltext; $item->setPrimaryImage($image_fulltext); } } catch (RokCommon_JSON_Exception $jse) { $this->container->roksprocket_logger->warning('Unable to decode image JSON for article ' . $item->getArticleId()); } $item->setImages($images); } $primary_link = new RokSprocket_Item_Link(); $slug = !empty($raw_item->alias) ? $raw_item->id . ':' . $raw_item->alias : $raw_item->id; $catslug = !empty($raw_item->category_alias) ? $raw_item->catid . ':' . $raw_item->category_alias : $raw_item->catid; $primary_link->setUrl(JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug), true)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); $links = array(); if (isset($raw_item->urls) && !empty($raw_item->urls)) { try { $raw_links = RokCommon_JSON::decode($raw_item->urls); if (isset($raw_links->urla)) { $linka = new RokSprocket_Item_Link(); $linka->setUrl($raw_links->urla); $linka->setText($raw_links->urlatext); $linka->setIdentifier('urla'); $links[$linka->getIdentifier()] = $linka; } if (isset($raw_links->urlb)) { $linkb = new RokSprocket_Item_Link(); $linkb->setUrl($raw_links->urlb); $linkb->setText($raw_links->urlbtext); $linkb->setIdentifier('urlb'); $links[$linkb->getIdentifier()] = $linkb; } if (isset($raw_links->urlc)) { $linkc = new RokSprocket_Item_Link(); $linkc->setUrl($raw_links->urlc); $linkc->setText($raw_links->urlctext); $linkc->setIdentifier('urlc'); $links[$linkc->getIdentifier()] = $linkc; } $item->setLinks($links); } catch (RokCommon_JSON_Exception $jse) { $this->container->roksprocket_logger->warning('Unable to decode link JSON for article ' . $item->getArticleId()); } } $texts = array(); $texts['text_introtext'] = $raw_item->introtext; $texts['text_fulltext'] = $raw_item->fulltext; $texts['text_metadesc'] = $raw_item->metadesc; $texts['text_title'] = $raw_item->title; $texts = $this->processPlugins($texts); $item->setTextFields($texts); $item->setText($texts['text_introtext']); $item->setDbOrder($dborder); // unknown joomla items $item->setCommentCount(0); if (isset($raw_item->tags) && !empty($raw_item->tags)) { $item->setTags($raw_item->tags); } else { $item->setTags(array()); } return $item; }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { //$textfield = $this->params->get('easyblog_articletext_field', ''); $provider_version = $this->providerVersion(); if ($provider_version < "5.0.0") { $helper_file = JPATH_ROOT . '/components/com_easyblog/helpers/helper.php'; $router_file = JPATH_ROOT . '/components/com_easyblog/helpers/router.php'; } elseif ($provider_version >= "5.0.0") { $helper_file = JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/easyblog.php'; $router_file = JPATH_ADMINISTRATOR . '/components/com_easyblog/includes/router.php'; } if (file_exists($helper_file)) { require_once $helper_file; } if (file_exists($router_file)) { require_once $router_file; } /* isset(require_once(JPATH_ROOT . '/components/com_easyblog/helpers/helper.php')); isset(require_once(JPATH_ROOT . '/components/com_easyblog/helpers/router.php'));*/ //suppress easyblog code errors $cfg = @EasyBlogHelper::getConfig(); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias(JApplication::stringURLSafe($raw_item->title)); $item->setAuthor($raw_item->author_name); $item->setTitle($raw_item->title); $item->setDate($raw_item->created); $item->setPublished($raw_item->published == 1 ? true : false); $item->setText($raw_item->intro); $item->setCategory($raw_item->category_title); $item->setHits($raw_item->hits); $item->setRating($raw_item->rating); $item->setMetaKey($raw_item->metakey); $item->setMetaDesc($raw_item->metadesc); if ($provider_version < "5.0.0") { $item->setMetaData(array("robots" => "'.{$raw_item->robots}.'", "author" => "'.{$raw_item->source}.'", "rights" => "'.{$raw_item->copyrights}.'", "xreference" => "")); } elseif ($provider_version >= "5.0.0") { $item->setMetaData(array("robots" => "'.{$raw_item->robots}.'", "author" => "'.{$raw_item->posttype}.'", "rights" => "'.{$raw_item->copyrights}.'", "xreference" => "")); } $item->setPublishUp($raw_item->publish_up); $item->setPublishDown($raw_item->publish_down); $images = array(); if (isset($raw_item->image) && !empty($raw_item->image)) { try { if (isset($raw_item->doctype) && !empty($raw_item->doctype)) { // EB5 // normalize blog image $image = json_decode($raw_item->image); // @legacy fix // We only want to store the URI for blog images. if (is_object($image)) { $raw_item->image = $image->place . $image->path; } // Load up the media manager library $mm = EB::mediamanager(); $url = $mm->getUrl($raw_item->image); $path = $mm->getPath($raw_item->image); if (JFile::exists($path)) { $image = EB::blogimage($path, $url); $item_image = new RokSprocket_Item_Image(); $item_image->setSource($image->getSource('medium')); $item_image->setIdentifier('image_item'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; $item->setPrimaryImage($item_image); // full image $item_image = new RokSprocket_Item_Image(); $item_image->setSource($image->getSource('large')); $item_image->setIdentifier('image_full'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; //thumbnail $item_image = new RokSprocket_Item_Image(); $item_image->setSource($image->getSource('thumbnail')); $item_image->setIdentifier('image_thumb'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; //thumbnail $item_image = new RokSprocket_Item_Image(); $item_image->setSource($image->getSource('icon')); $item_image->setIdentifier('image_icon'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; } } else { $raw_image = RokCommon_JSON::decode($raw_item->image); if (isset($raw_image) && !empty($raw_image)) { $item_image = new RokSprocket_Item_Image(); if (isset($raw_image->place) && $raw_image->place == 'shared') { $item_image->setSource(JPath::clean(JURI::root(true) . '/' . $cfg->get('main_shared_path') . $raw_image->path)); } else { $folder = explode(':', $raw_image->place); $item_image->setSource(JPath::clean(JURI::root(true) . '/' . $cfg->get('main_image_path') . $folder[1] . $raw_image->path)); } $item_image->setIdentifier('image_item'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; $item->setPrimaryImage($item_image); //full image $item_image = new RokSprocket_Item_Image(); $item_image->setSource(JPath::clean(str_replace(JURI::root(), JURI::root(true) . '/', $raw_image->url))); $item_image->setIdentifier('image_full'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; //thumbnail $item_image = new RokSprocket_Item_Image(); $item_image->setSource(JPath::clean(str_replace(JURI::root(), JURI::root(true) . '/', $raw_image->thumbnail->url))); $item_image->setIdentifier('image_thumb'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; //icon $item_image = new RokSprocket_Item_Image(); $item_image->setSource(JPath::clean(str_replace(JURI::root(), JURI::root(true) . '/', $raw_image->icon->url))); $item_image->setIdentifier('image_icon'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; } } } catch (RokCommon_JSON_Exception $jse) { $this->container->roksprocket_logger->warning('Unable to decode image JSON for article ' . $item->getArticleId()); } $item->setImages($images); } $primary_link = new RokSprocket_Item_Link(); $itemId = EasyBlogRouter::getItemIdByCategories($raw_item->category_id); $primary_link->setUrl(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $raw_item->id . '&Itemid=' . $itemId)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); $item->setPrimaryLink($primary_link); $links = array(); $link = new RokSprocket_Item_Link(); $link->setUrl(EasyBlogRouter::_('index.php?option=com_easyblog&view=entry&id=' . $raw_item->id . '&Itemid=' . $itemId)); $link->setText(''); $link->setIdentifier('article_link'); $links[$link->getIdentifier()] = $link; $item->setLinks($links); $texts = array(); $texts['text_content'] = $raw_item->content; $texts['text_intro'] = $raw_item->intro; $texts['text_excerpt'] = $raw_item->excerpt; $texts['text_title'] = $raw_item->title; $texts['text_metadesc'] = $raw_item->metadesc; $texts = $this->processPlugins($texts); $item->setTextFields($texts); if ($provider_version < "5.0.0") { $item->setText($texts['text_intro']); } elseif ($provider_version >= "5.0.0") { $item->setText($texts['text_content']); } $item->setDbOrder($dborder); // unknown joomla items $item->setCommentCount($raw_item->comment_count); if (isset($raw_item->tags)) { $tags = explode(',', $raw_item->tags) ? explode(',', $raw_item->tags) : array(); $item->setTags($tags); } return $item; }
/** * Remove an item * $params object should be a json like * <code> * { * "module_id": 5, * "provider":"simple", * "item_id": 123, * } * </code> * * @param $params * * @throws Exception * @throws RokCommon_Ajax_Exception * @return \RokCommon_Ajax_Result */ public function removeItem($params) { $result = new RokCommon_Ajax_Result(); //get the provider and id values list($provider, $item_id) = explode('-', $params->item_id); if ($params->uuid != '0') { $params->module_id = $params->uuid; } // get the provider $container = RokCommon_Service::getContainer(); $provider_class = $container->getParameter(sprintf('roksprocket.providers.registered.%s.class', strtolower($provider))); // have the provider remove the item if (call_user_func_array(array($provider_class, 'removeItem'), array($item_id, $params->module_id))) { $result->setPayload(RokCommon_JSON::encode(array('removed_item' => $params->item_id))); } return $this->getItems($params); }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { /** @var Item $raw_item*/ $app_type = $this->params->get('zoo_application_type'); //$textfield = $this->params->get('zoo_articletext_field', ''); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias($raw_item->created_by_alias ? $raw_item->created_by_alias : JFactory::getUser($raw_item->created_by)->name); $item->setAuthor(JFactory::getUser($raw_item->created_by)->name); $item->setTitle($raw_item->name); $item->setDate($raw_item->created); $item->setPublished($raw_item->state == 1 ? true : false); $category = $raw_item->getPrimaryCategory(); if ($category) { $item->setCategory($category->name); } $item->setHits($raw_item->hits); //$this->query->select('ROUND(AVG(v.value), 0) AS rating'); //$this->query->join('LEFT', '#__zoo_rating AS v ON a.id = v.item_id'); $item->setMetaKey(''); $item->setMetaDesc(''); $item->setMetaData(''); $texts = array(); $images = array(); $links = array(); /** @var Element[] $elements */ $elements = $raw_item->getElements(); $rating = 0; foreach ($elements as $element) { /** @var RokSprocket_Provider_Zoo_FieldProcessorInterface $processor */ $processor = RokSprocket_Provider_Zoo_FieldProcessorFactory::getFieldProcessor($element->getElementType()); $sprocket_type = RokSprocket_Provider_Zoo_FieldProcessorFactory::getSprocketType($element->getElementType()); switch ($sprocket_type) { case 'image': if ($processor instanceof RokSprocket_Provider_Zoo_ImageFieldProcessorInterface) { /** @var RokSprocket_Provider_Zoo_ImageFieldProcessorInterface $processor */ $image = $processor->getAsSprocketImage($element); $images[$image->getIdentifier()] = $image; if (isset($images['image_field_' . $element->identifier]) && !$item->getPrimaryImage()) { $item->setPrimaryImage($image); } } break; case 'link': if ($processor instanceof RokSprocket_Provider_Zoo_LinkFieldProcessorInterface) { /** @var RokSprocket_Provider_Zoo_LinkFieldProcessorInterface $processor */ $link = $processor->getAsSprocketLink($element); $links[$link->getIdentifier()] = $link; if (isset($links['link_field_' . $element->identifier]) && !$item->getPrimaryLink()) { $item->setPrimaryLink($link); } } break; case 'text': /** @var RokSprocket_Provider_Zoo_FieldProcessorInterface $processor */ $texts['text_field_' . $element->identifier] = $processor->getValue($element); break; default: break; } if ($element->getElementType() == 'rating') { $rating = $element->getRating(); } } $item->setRating($rating); $item->setImages($images); $item->setLinks($links); $params = RokCommon_JSON::decode($raw_item->params); $desc = "metadata.description"; $texts['text_field_metadesc'] = $params->{$desc}; $texts['text_field_name'] = $raw_item->name; $texts = $this->processPlugins($texts); $item->setTextFields($texts); $text = array_values($texts); $text = array_shift($text); $item->setText($text); $primary_link = new RokSprocket_Item_Link(); $primary_link->setUrl(JRoute::_('index.php?option=com_zoo&task=item&item_id=' . $raw_item->id, true)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); $item->setCommentCount(count($raw_item->getComments())); //$tags = (explode(',', $raw_item->tags)) ? explode(',', $raw_item->tags) : array(); $tags = $raw_item->getTags(); $item->setTags($tags); $item->setDbOrder($dborder); return $item; }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { require_once JPath::clean(JPATH_SITE . '/components/com_content/helpers/route.php'); if (file_exists(JPath::clean(JPATH_SITE . '/libraries/joomla/html/html/content.php'))) { require_once JPath::clean(JPATH_SITE . '/libraries/joomla/html/html/content.php'); } require_once JPath::clean(JPATH_SITE . '/libraries/cck/content/content.php'); //$app_type = $this->params->get('seblod_application_type'); //$textfield = $this->params->get('seblod_articletext_field', ''); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias($raw_item->alias); $item->setAuthor($raw_item->created_by_alias ? $raw_item->created_by_alias : $raw_item->author_name); $item->setTitle($raw_item->title); $item->setDate($raw_item->created); $item->setPublished($raw_item->state == 1 ? true : false); $item->setCategory($raw_item->category_title); $item->setHits($raw_item->hits); $item->setRating($raw_item->rating); $item->setMetaKey($raw_item->metakey); $item->setMetaDesc($raw_item->metadesc); $item->setMetaData($raw_item->metadata); $item->setPublishUp($raw_item->publish_up); $item->setPublishDown($raw_item->publish_down); //Set up texts array $texts = array(); if ($text_fields = self::getFieldTypes(array("textarea", "wysiwyg_editor", "text"), false)) { $text = ''; foreach ($text_fields as $field) { if ($field->storage_table == '#__cck_core') { $text = isset($field->data) ? $field->data : ''; } elseif ($field->storage_table == '#__content' && $field->storage_field == 'introtext') { $text = CCK_Content::getValue($raw_item->introtext, $field->name); } elseif ($field->storage_table == '#__content' && $field->storage_field == 'fulltext') { $text = CCK_Content::getValue($raw_item->fulltext, $field->name); } else { $text = $this->getFieldValue($raw_item->id, $field->storage_field, $field->storage_table); } $texts['text_' . $field->id] = $text; } } if (isset($raw_item->introtext) && !empty($raw_item->introtext)) { $text = ''; $introtext = CCK_Content::getValue($raw_item->introtext, 'introtext'); $fulltext = CCK_Content::getValue($raw_item->introtext, 'fulltext'); if ($introtext || $fulltext) { if ($introtext && isset($introtext)) { $texts['text_introtext'] = $introtext; } if ($fulltext && isset($fulltext)) { $texts['text_fulltext'] = $fulltext; } } else { $texts['text_introtext'] = $raw_item->introtext; $texts['text_fulltext'] = $raw_item->fulltext; $texts['text_metadesc'] = $raw_item->metadesc; $texts['text_title'] = $raw_item->title; } } $texts = $this->processPlugins($texts); $item->setTextFields($texts); $item->setText($texts['text_introtext']); //set up images array $images = array(); if ($image_fields = self::getFieldTypes("upload_image", false)) { foreach ($image_fields as $field) { $image_uri = ''; if ($field->storage_table == '#__cck_core') { $image_uri = isset($field->data) ? $field->data : ''; } elseif ($field->storage_table == '#__content' && $field->storage_field == 'introtext') { $image_uri = CCK_Content::getValue($raw_item->introtext, $field->name); } elseif ($field->storage_table == '#__content' && $field->storage_field == 'fulltext') { $image_uri = CCK_Content::getValue($raw_item->fulltext, $field->name); } else { $image_uri = $this->getFieldValue($raw_item->id, $field->storage_field, $field->storage_table); } if (JFile::exists(JPath::clean(JPATH_SITE . '/' . $image_uri))) { $image_field = new RokSprocket_Item_Image(); $image_field->setSource(JPath::clean(JURI::root(true) . '/' . $image_uri)); $image_field->setIdentifier('image_' . $field->id); $image_field->setCaption(''); $image_field->setAlttext(''); $images['image_' . $field->id] = $image_field; } } } if (isset($raw_item->images) && !empty($raw_item->images)) { try { $raw_images = RokCommon_JSON::decode($raw_item->images); if (isset($raw_images->image_intro)) { $image_intro = new RokSprocket_Item_Image(); $image_intro->setSource(JPath::clean(JURI::root(true) . '/' . $raw_images->image_intro)); $image_intro->setIdentifier('image_intro'); $image_intro->setCaption($raw_images->image_intro_caption); $image_intro->setAlttext($raw_images->image_intro_alt); $images[$image_intro->getIdentifier()] = $image_intro; } if (isset($raw_images->image_fulltext)) { $image_fulltext = new RokSprocket_Item_Image(); $image_fulltext->setSource(JPath::clean(JURI::root(true) . '/' . $raw_images->image_fulltext)); $image_fulltext->setIdentifier('image_fulltext'); $image_fulltext->setCaption($raw_images->image_fulltext_caption); $image_fulltext->setAlttext($raw_images->image_fulltext_alt); $images[$image_fulltext->getIdentifier()] = $image_fulltext; } } catch (RokCommon_JSON_Exception $jse) { //TODO log unable to get image for article } } if (isset($images['image_fulltext']) && $images['image_fulltext']) { $image_primary = $images['image_fulltext']; } else { if (isset($images['image_intro']) && $images['image_intro']) { $image_primary = $images['image_intro']; } else { if (count($images)) { $image_primary = array_shift(array_values($images)); } else { $image_primary = array(); } } } $item->setPrimaryImage($image_primary); $item->setImages($images); //set up links array $links = array(); if ($link_fields = self::getFieldTypes("link", false)) { foreach ($link_fields as $field) { $link_url = ''; if ($field->storage_table == '#_cck_core') { $link_url = isset($field->data) ? $field->data : ''; } elseif ($field->storage_table == '#_content') { $link_url = CCK_Content::getValue($raw_item->introtext, $field->name); } $link_field = new RokSprocket_Item_Link(); $link_field->setUrl($link_url); $link_field->setText(''); $links['url_' . $field->id] = $link_field; } } if (isset($raw_item->urls) && !empty($raw_item->urls)) { try { $raw_links = RokCommon_JSON::decode($raw_item->urls); if (isset($raw_links->urla)) { $linka = new RokSprocket_Item_Link(); $linka->setUrl($raw_links->urla); $linka->setText($raw_links->urlatext); $linka->setIdentifier('urla'); $links[$linka->getIdentifier()] = $linka; $item->setPrimaryLink($linka); } if (isset($raw_links->urlb)) { $linkb = new RokSprocket_Item_Link(); $linkb->setUrl($raw_links->urlb); $linkb->setText($raw_links->urlbtext); $linkb->setIdentifier('urlb'); $links[$linkb->getIdentifier()] = $linkb; } if (isset($raw_links->urlc)) { $linkc = new RokSprocket_Item_Link(); $linkc->setUrl($raw_links->urlc); $linkc->setText($raw_links->urlctext); $linkc->setIdentifier('urlc'); $links[$linkc->getIdentifier()] = $linkc; } } catch (RokCommon_JSON_Exception $jse) { //TODO log unable to get links for article } } $item->setLinks($links); $primary_link = new RokSprocket_Item_Link(); $slug = !empty($raw_item->alias) ? $raw_item->id . ':' . $raw_item->alias : $raw_item->id; $catslug = !empty($raw_item->category_alias) ? $raw_item->catid . ':' . $raw_item->category_alias : $raw_item->catid; $primary_link->setUrl(JRoute::_(ContentHelperRoute::getArticleRoute($slug, $catslug), true)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); // unknown joomla items $item->setCommentCount(0); if (isset($raw_item->tags) && !empty($raw_item->tags)) { $item->setTags($raw_item->tags); } else { $item->setTags(array()); } $item->setDbOrder($dborder); return $item; }
/** * Method to save the form data. * * @param array $data The form data. * * @return boolean True on success. * * @since 1.6 */ public function save($data) { $original_data = $data; // Initialise variables; $app = JFactory::getApplication(); $dispatcher = JDispatcher::getInstance(); $table = $this->getTable(); $pk = !empty($data['id']) ? $data['id'] : (int) $this->getState('module.id'); $isNew = true; $input = $app->input; $task = $input->get('task', null, 'cmd'); // Include the content modules for the onSave events. JPluginHelper::importPlugin('extension'); // Load the row if saving an existing record. if ($pk > 0) { $table->load($pk); $isNew = false; } // Alter the title and published state for Save as Copy if ($task == 'save2copy') { $orig_data = $input->post->get('jform', array(), 'array'); $orig_table = clone $this->getTable(); $orig_table->load((int) $orig_data['id']); if ($data['title'] == $orig_table->title) { $data['title'] .= ' ' . JText::_('JGLOBAL_COPY'); $data['published'] = 0; } } // Bind the data. if (!$table->bind($data)) { $this->setError($table->getError()); return false; } // Prepare the row for saving $this->prepareTable($table); // Check the data. if (!$table->check()) { $this->setError($table->getError()); return false; } // Trigger the onExtensionBeforeSave event. $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_modules.module', &$table, $isNew)); if (in_array(false, $result, true)) { $this->setError($table->getError()); return false; } // Store the data. if (!$table->store()) { $this->setError($table->getError()); return false; } // // Process the menu link mappings. // $assignment = isset($data['assignment']) ? $data['assignment'] : 0; // Delete old module to menu item associations // $db->setQuery( // 'DELETE FROM #__modules_menu'. // ' WHERE moduleid = '.(int) $table->id // ); $db = $this->getDbo(); $query = $db->getQuery(true); $query->delete(); $query->from('#__modules_menu'); $query->where('moduleid = ' . (int) $table->id); $db->setQuery((string) $query); $db->query(); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } // If the assignment is numeric, then something is selected (otherwise it's none). if (is_numeric($assignment)) { // Variable is numeric, but could be a string. $assignment = (int) $assignment; // Logic check: if no module excluded then convert to display on all. if ($assignment == -1 && empty($data['assigned'])) { $assignment = 0; } // Check needed to stop a module being assigned to `All` // and other menu items resulting in a module being displayed twice. if ($assignment === 0) { // assign new module to `all` menu item associations // $this->_db->setQuery( // 'INSERT INTO #__modules_menu'. // ' SET moduleid = '.(int) $table->id.', menuid = 0' // ); $query->clear(); $query->insert('#__modules_menu'); $query->columns(array($db->quoteName('moduleid'), $db->quoteName('menuid'))); $query->values((int) $table->id . ', 0'); $db->setQuery((string) $query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } } elseif (!empty($data['assigned'])) { // Get the sign of the number. $sign = $assignment < 0 ? -1 : +1; // Preprocess the assigned array. $tuples = array(); foreach ($data['assigned'] as &$pk) { $tuples[] = '(' . (int) $table->id . ',' . (int) $pk * $sign . ')'; } $this->_db->setQuery('INSERT INTO #__modules_menu (moduleid, menuid) VALUES ' . implode(',', $tuples)); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } } } // Trigger the onExtensionAfterSave event. $dispatcher->trigger('onExtensionAfterSave', array('com_modules.module', &$table, $isNew)); // Compute the extension id of this module in case the controller wants it. $query = $db->getQuery(true); $query->select('extension_id'); $query->from('#__extensions AS e'); $query->leftJoin('#__modules AS m ON e.element = m.module'); $query->where('m.id = ' . (int) $table->id); $db->setQuery($query); $extensionId = $db->loadResult(); if ($error = $db->getErrorMsg()) { JError::raiseWarning(500, $error); return; } $this->setState('module.extension_id', $extensionId); $this->setState('module.id', $table->id); // Add the per item custom settings $items = $input->post->get('items', array(), 'array'); $old_moduleid = (int) $table->id; if ($task == 'save2copy') { $old_moduleid = (int) $orig_table->id; } // get the old set of items for the module $query = $db->getQuery(true); $item_table = JTable::getInstance('Item', 'RokSprocketTable'); $query->select("*")->from("#__roksprocket_items")->where('module_id = ' . $old_moduleid); $db->setQuery((string) $query); $raw_old_items = $db->loadAssocList(); if ($db->getErrorNum()) { $this->setError($db->getErrorMsg()); return false; } $old_items = array(); foreach ($raw_old_items as $raw_old_item) { /** @var $old_item_table RokSprocketTableItem */ $old_item_table = JTable::getInstance('Item', 'RokSprocketTable'); $old_item_table->bind($raw_old_item); if (isset($old_item_table->params)) { $old_item_table->params = RokCommon_Utils_ArrayHelper::fromObject(RokCommon_JSON::decode($old_item_table->params)); } else { $old_item_table->params = array(); } $old_items[$old_item_table->provider . '-' . $old_item_table->provider_id] = $old_item_table; } $all_new_items = $this->getArticles((int) $table->id, $table->params); if ($task != 'save2copy') { // delete old items per module $query = $db->getQuery(true); $query->delete(); $query->from('#__roksprocket_items'); $query->where('module_id = ' . (int) $table->id); $db->setQuery((string) $query); if (!$db->query()) { $this->setError($db->getErrorMsg()); return false; } // Pass to addons to save if needed if (empty($original_data['id'])) { $original_data['id'] = (int) $table->id; } $event = new RokCommon_Event($this, 'roksprocket.module.save'); $this->dispatcher->filter($event, array('data' => $original_data, 'save_result' => null)); $addonreturn = $event->getReturnValue(); if ($event->isProcessed()) { if (!$addonreturn['save_result']) { return false; } } } $per_item_form = $this->getPerItemsForm(); // Save the Showing Items $last_ordernumber = 0; foreach ($items as $item_id => $item_settings) { $item_settings['module_id'] = (int) $table->id; list($item_settings['provider'], $item_settings['provider_id']) = explode('-', $item_id); /** @var $item_table RokSprocketTableItem */ $item_table = JTable::getInstance('Item', 'RokSprocketTable'); $fields = $per_item_form->getFieldsetWithGroup('peritem'); foreach ($fields as $field) { if (!array_key_exists($field->fieldname, $item_settings['params'])) { if (!empty($old_items) && isset($old_items[$item_id]) && array_key_exists($field->fieldname, $old_items[$item_id]->params)) { $item_settings['params'][$field->fieldname] = $old_items[$item_id]->params[$field->fieldname]; } else { $item_settings['params'][$field->fieldname] = $per_item_form->getFieldAttribute($field->fieldname, 'default', null, 'params'); } } } // Bind the data. if (!$item_table->bind($item_settings)) { $this->setError($item_table->getError()); return false; } // Trigger the onExtensionBeforeSave event. $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_roksprocket.module', &$item_table, true)); if (in_array(false, $result, true)) { $this->setError($item_table->getError()); return false; } // Store the data. if (!$item_table->store()) { $this->setError($item_table->getError()); return false; } $last_ordernumber = $item_table->order; if (isset($old_items[$item_id])) { unset($old_items[$item_id]); } if (isset($all_new_items[$item_id])) { unset($all_new_items[$item_id]); } } //Save the remaining items (Not Shown) foreach ($all_new_items as $item_id => $unseen_item) { $item_settings = array(); $item_settings['module_id'] = (int) $table->id; list($item_settings['provider'], $item_settings['provider_id']) = explode('-', $item_id); $item_settings['order'] = ++$last_ordernumber; if (isset($old_items[$item_id]) && $old_items[$item_id]->params != null) { $item_settings['params'] = $old_items[$item_id]->params; } elseif (isset($all_new_items[$item_id]) && $all_new_items[$item_id]->getParams() != null) { $item_settings['params'] = RokCommon_JSON::encode($all_new_items[$item_id]->getParams()); } /** @var $item_table RokSprocketTableItem */ $item_table = JTable::getInstance('Item', 'RokSprocketTable'); // Bind the data. if (!$item_table->bind($item_settings)) { $this->setError($item_table->getError()); return false; } // Trigger the onExtensionBeforeSave event. $result = $dispatcher->trigger('onExtensionBeforeSave', array('com_roksprocket.module', &$item_table, true)); if (in_array(false, $result, true)) { $this->setError($item_table->getError()); return false; } // Store the data. if (!$item_table->store()) { $this->setError($item_table->getError()); return false; } } // Clear modules cache $this->cleanCache(); // Clean module cache parent::cleanCache($table->module, $table->client_id); $app->setUserState('com_roksprocket.module_id', $table->id); return true; }
public function getJson() { $chunks = $this->root->getChunks(); return RokCommon_JSON::encode($chunks); }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { require_once JPath::clean(JPATH_SITE . '/components/com_content/helpers/route.php'); if (file_exists(JPath::clean(JPATH_SITE . '/libraries/joomla/html/html/content.php'))) { require_once JPath::clean(JPATH_SITE . '/libraries/joomla/html/html/content.php'); } if (class_exists('JModelLegacy')) { JModelLegacy::addIncludePath(JPATH_SITE . '/components/com_content/models', 'ContentModel'); } //$textfield = $this->params->get('contentbuilder_articletext_field', ''); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias($raw_item->alias); $item->setAuthor($raw_item->created_by_alias ? $raw_item->created_by_alias : $raw_item->author_name); $item->setTitle($raw_item->title); $item->setDate($raw_item->created); $item->setPublished($raw_item->state == 1 ? true : false); $item->setCategory($raw_item->category_title); $item->setHits($raw_item->hits); $item->setRating($raw_item->rating); $item->setMetaKey($raw_item->metakey); $item->setMetaDesc($raw_item->metadesc); $item->setMetaData($raw_item->metadata); $item->setPublishUp($raw_item->publish_up); $item->setPublishDown($raw_item->publish_down); $texts = array(); if ($text_fields = self::getFieldTypes(array("textarea", "text"))) { foreach ($text_fields as $field) { $text = $this->getFieldValue($raw_item->id, $field->id); $texts['text_' . $field->id] = $text; } } $texts['text_introtext'] = $raw_item->introtext; $texts['text_fulltext'] = $raw_item->fulltext; $texts['text_metadesc'] = $raw_item->metadesc; $texts['text_title'] = $raw_item->title; $texts = $this->processPlugins($texts); $texts = $this->processPlugins($texts); $item->setTextFields($texts); $item->setText($texts['text_introtext']); $images = array(); if (isset($raw_item->images) && !empty($raw_item->images)) { try { $raw_images = RokCommon_JSON::decode($raw_item->images); if (isset($raw_images->image_intro) && !empty($raw_images->image_intro)) { $image_intro = new RokSprocket_Item_Image(); $image_intro->setSource($raw_images->image_intro); $image_intro->setIdentifier('image_intro'); $image_intro->setCaption($raw_images->image_intro_caption); $image_intro->setAlttext($raw_images->image_intro_alt); $images[$image_intro->getIdentifier()] = $image_intro; } if (isset($raw_images->image_fulltext) && !empty($raw_images->image_fulltext)) { $image_fulltext = new RokSprocket_Item_Image(); $image_fulltext->setSource($raw_images->image_fulltext); $image_fulltext->setIdentifier('image_fulltext'); $image_fulltext->setCaption($raw_images->image_fulltext_caption); $image_fulltext->setAlttext($raw_images->image_fulltext_alt); $images[$image_fulltext->getIdentifier()] = $image_fulltext; $item->setPrimaryImage($image_fulltext); } } catch (RokCommon_JSON_Exception $jse) { $this->container->roksprocket_logger->warning('Unable to decode image JSON for article ' . $item->getArticleId()); } } if ($image_fields = self::getFieldTypes("upload")) { foreach ($image_fields as $field) { $image_uri = $this->getFieldValue($raw_item->record_id, $field->storage_field, $field->storage_table); if (JFile::exists(JPath::clean(JPATH_SITE . '/' . $image_uri)) && is_file(JPath::clean(JPATH_SITE . '/' . $image_uri))) { $image_field = new RokSprocket_Item_Image(); $image_field->setSource(JPath::clean(JURI::root(true) . '/' . $image_uri)); $image_field->setIdentifier('image_' . $field->id); $image_field->setCaption(''); $image_field->setAlttext(''); $images['image_' . $field->id] = $image_field; } } } $item->setImages($images); $primary_link = new RokSprocket_Item_Link(); $primary_link->setUrl(JRoute::_('index.php?option=com_contentbuilder&title=list-view-easyblog&controller=details&id=' . $raw_item->form_id . '&record_id=' . $raw_item->record_id)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); $links = array(); if (isset($raw_item->urls) && !empty($raw_item->urls)) { try { $raw_links = RokCommon_JSON::decode($raw_item->urls); if (isset($raw_links->urla)) { $linka = new RokSprocket_Item_Link(); $linka->setUrl($raw_links->urla); $linka->setText($raw_links->urlatext); $linka->setIdentifier('urla'); $links[$linka->getIdentifier()] = $linka; } if (isset($raw_links->urlb)) { $linkb = new RokSprocket_Item_Link(); $linkb->setUrl($raw_links->urlb); $linkb->setText($raw_links->urlbtext); $linkb->setIdentifier('urlb'); $links[$linkb->getIdentifier()] = $linkb; } if (isset($raw_links->urlc)) { $linkc = new RokSprocket_Item_Link(); $linkc->setUrl($raw_links->urlc); $linkc->setText($raw_links->urlctext); $linkc->setIdentifier('urlc'); $links[$linkc->getIdentifier()] = $linkc; } } catch (RokCommon_JSON_Exception $jse) { $this->container->roksprocket_logger->warning('Unable to decode link JSON for article ' . $item->getArticleId()); } } if ($link_fields = self::getFieldTypes("text", false)) { foreach ($link_fields as $field) { $raw_link = $this->getFieldValue($raw_item->record_id, $field->storage_field, $field->storage_table); if (filter_var($raw_link, FILTER_VALIDATE_URL)) { $link_field = new RokSprocket_Item_Link(); $link_field->setUrl($raw_link); $link_field->setText(null); $link_field->setIdentifier('url_' . $field->id); $links[$link_field->getIdentifier()] = $link_field; } } } $item->setLinks($links); $item->setDbOrder($dborder); // unknown joomla items $item->setCommentCount(0); $item->setTags(array()); return $item; }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { $item = new RokSprocket_Item(); $item->setProvider(RokSprocket_Provider_Simple_Storage_Interface::PROVIDER_NAME); $item->setId($raw_item->id); $params = RokCommon_JSON::decode($raw_item->params, null, true); if ($params !== false && is_array($params) && array_key_exists('_article_title', $params)) { $item->setTitle($params['_article_title']); } else { $item->setTitle('Simple Item'); } return $item; }
/** * @param $raw_item * @param int $dborder * * @return \RokSprocket_Item */ protected function convertRawToItem($raw_item, $dborder = 0) { //$textfield = $this->params->get('easyblog_articletext_field', ''); $item = new RokSprocket_Item(); $item->setProvider($this->provider_name); $item->setId($raw_item->id); $item->setAlias(JApplication::stringURLSafe($raw_item->title)); $item->setAuthor($raw_item->author_name); $item->setTitle($raw_item->title); $item->setDate($raw_item->created); $item->setPublished($raw_item->published == 1 ? true : false); $item->setText($raw_item->intro); $item->setCategory($raw_item->category_title); $item->setHits($raw_item->hits); $item->setRating($raw_item->rating); $item->setMetaKey($raw_item->metakey); $item->setMetaDesc($raw_item->metadesc); $item->setMetaData(array("robots" => "'.{$raw_item->robots}.'", "author" => "'.{$raw_item->source}.'", "rights" => "'.{$raw_item->copyrights}.'", "xreference" => "")); $item->setPublishUp($raw_item->publish_up); $item->setPublishDown($raw_item->publish_down); $images = array(); if (isset($raw_item->image) && !empty($raw_item->image)) { try { $raw_image = RokCommon_JSON::decode($raw_item->image); if (isset($raw_image) && !empty($raw_image)) { $item_image = new RokSprocket_Item_Image(); $folder = explode(':', $raw_image->place); $item_image->setSource(JPath::clean(JURI::root(true) . '/images/easyblog_images/' . $folder[1] . $raw_image->path)); $item_image->setIdentifier('image_item'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; $item->setPrimaryImage($item_image); //full image $item_image = new RokSprocket_Item_Image(); $item_image->setSource(JPath::clean(str_replace(JURI::root(), JURI::root(true) . '/', $raw_image->url))); $item_image->setIdentifier('image_full'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; //thumbnail $item_image = new RokSprocket_Item_Image(); $item_image->setSource(JPath::clean(str_replace(JURI::root(), JURI::root(true) . '/', $raw_image->thumbnail->url))); $item_image->setIdentifier('image_thumb'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; //icon $item_image = new RokSprocket_Item_Image(); $item_image->setSource(JPath::clean(str_replace(JURI::root(), JURI::root(true) . '/', $raw_image->icon->url))); $item_image->setIdentifier('image_icon'); $item_image->setCaption(null); $item_image->setAlttext(null); $images[$item_image->getIdentifier()] = $item_image; } } catch (RokCommon_JSON_Exception $jse) { $this->container->roksprocket_logger->warning('Unable to decode image JSON for article ' . $item->getArticleId()); } $item->setImages($images); } $primary_link = new RokSprocket_Item_Link(); $primary_link->setUrl(JRoute::_('index.php?option=com_easyblog&view=entry&id=' . $raw_item->id)); $primary_link->getIdentifier('article_link'); $item->setPrimaryLink($primary_link); $item->setPrimaryLink($primary_link); $links = array(); $link = new RokSprocket_Item_Link(); $link->setUrl(JRoute::_('index.php?option=com_easyblog&view=entry&id=' . $raw_item->id)); $link->setText(''); $link->setIdentifier('article_link'); $links[$link->getIdentifier()] = $link; $item->setLinks($links); $texts = array(); $texts['text_content'] = $raw_item->content; $texts['text_intro'] = $raw_item->intro; $texts['text_excerpt'] = $raw_item->excerpt; $texts['text_metadesc'] = $raw_item->metadesc; $item->setTextFields($texts); $item->setText($texts['text_intro']); $item->setDbOrder($dborder); // unknown joomla items $item->setCommentCount($raw_item->comment_count); if (isset($raw_item->tags)) { $tags = explode(',', $raw_item->tags) ? explode(',', $raw_item->tags) : array(); $item->setTags($tags); } return $item; }