public function prepareAudio($data, $file = null, $_copy = false) { $copy = $_copy; if ($this->tztask) { $copy = true; } if ($data) { if (isset($data['jform'])) { $data = $data['jform']; } if ($data['audio_soundcloud_id']) { $fileTypes = array('image/jpeg', 'image/jpg', 'image/bmp', 'image/gif', 'image/png', 'image/ico'); $params = $this->getState('params'); $_data = null; $_data = $this->_db->quote($data['audio_soundcloud_id']); $id = $this->getState($this->getName() . '.id'); if (!$id) { $id = $data['id']; } // Create folder to save thumb if this folder isn't created. $audioPath = $this->imageUrl . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . 'thumbnail' . DIRECTORY_SEPARATOR . $this->audioFolder; if (!JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . $audioPath)) { JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . $audioPath); } if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . $audioPath)) { if (!JFile::exists(JPATH_SITE . DIRECTORY_SEPARATOR . $audioPath . DIRECTORY_SEPARATOR . 'index.html')) { JFile::write(JPATH_SITE . DIRECTORY_SEPARATOR . $audioPath . DIRECTORY_SEPARATOR . 'index.html', htmlspecialchars_decode('<!DOCTYPE html><title></title>')); } } // Check and set chmod folder again $chmodFolder = JPath::getPermissions($audioPath); if ($chmodFolder != 'rwxrwxrwx' || $chmodFolder != 'rwxr-xr-x') { JPath::setPermissions($audioPath); } // Prepare data (Return string to save the database) //// Delete old thumbnail if delete checkbox input is checked if ($data['audio_soundcloud_delete_image'] && ($hiddenImage = $data['audio_soundcloud_hidden_image'])) { $this->deleteThumb(null, $hiddenImage); // // Delete old original thumbnail // $org_path = JPATH_SITE.DIRECTORY_SEPARATOR.$org_audioPath.DIRECTORY_SEPARATOR // .JFile::getName($data['audio_soundcloud_hidden_image']); // if(JFile::exists($org_path)){ // JFile::delete($org_path); // } } if ($file && !empty($file['name'])) { // If choose thumbnail from client $destName = (!$data['alias'] ? uniqid() . 'tz_portfolio_' . time() : $data['alias']) . '-' . $id . '.' . JFile::getExt($file['name']); $image = $this->uploadImageClient($file, $destName, $audioPath, $fileTypes, $this->_getImageSizes($params), $data['audio_soundcloud_hidden_image']); } elseif (!empty($data['audio_soundcloud_image_server'])) { // If choose thumbnail from server $destName = (!$data['alias'] ? uniqid() . 'tz_portfolio_' . time() : $data['alias']) . '-' . $id . '.' . JFile::getExt($data['audio_soundcloud_image_server']); $image = $this->uploadImageServer($data['audio_soundcloud_image_server'], $destName, $audioPath, $this->_getImageSizes($params), $data['audio_soundcloud_hidden_image'], $copy); } else { // Get thumbnail from soundcloud page if ($data['audio_soundcloud_delete_image'] && ($hiddenImage = $data['audio_soundcloud_hidden_image'])) { $data['audio_soundcloud_hidden_image'] = ''; } if (!isset($data['audio_soundcloud_hidden_image']) || empty($data['audio_soundcloud_hidden_image'])) { if ($client_id = $params->get('soundcloud_client_id', '4a24c193db998e3b88c34cad41154055')) { // Register fetch object $fetch = new Services_Yadis_PlainHTTPFetcher(); $url = 'http://api.soundcloud.com/tracks/' . $data['audio_soundcloud_id'] . '.json?client_id=' . $client_id; if ($content = $fetch->get($url)) { $content = json_decode($content->body); $thumbUrl = null; if ($content->artwork_url && !empty($content->artwork_url)) { $thumbUrl = $content->artwork_url; } else { $audioUser = $content->user; if ($audioUser->avatar_url && !empty($audioUser->avatar_url)) { $thumbUrl = $audioUser->avatar_url; } } if ($thumbUrl) { if (JString::strrpos($thumbUrl, '-', 0) != false) { $thumbUrl = JString::substr($thumbUrl, 0, JString::strrpos($thumbUrl, '-', 0) + 1) . 't500x500.' . JFile::getExt($thumbUrl); } // Create folder tmp if not exists if (!JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $this->tzfolder)) { JFolder::create(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $this->tzfolder); } if (JFolder::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $this->tzfolder)) { if (!JFile::exists(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $this->tzfolder . 'index.html')) { JFile::write(JPATH_SITE . DIRECTORY_SEPARATOR . 'media' . DIRECTORY_SEPARATOR . $this->tzfolder . 'index.html', htmlspecialchars_decode('<!DOCTYPE html><title></title>')); } } // Save image from other server to this server (temp file) $fetch2 = new Services_Yadis_PlainHTTPFetcher(); $audioTempPath = null; if ($audioTemp = $fetch2->get($thumbUrl)) { if (in_array($audioTemp->headers['Content-Type'], $fileTypes)) { $audioType = JFile::getExt($thumbUrl); if (preg_match('/(.*)(\\|\\/|\\:|\\*|\\?|\\"|\\<|\\>|\\|.*?)/i', $audioType, $match)) { $audioType = $match[1]; } $audioTempPath = 'media' . DIRECTORY_SEPARATOR . $this->tzfolder . DIRECTORY_SEPARATOR . uniqid() . time() . '.' . $audioType; JFile::write(JPATH_SITE . DIRECTORY_SEPARATOR . $audioTempPath, $audioTemp->body); } } if ($audioTempPath) { $destName = (!$data['alias'] ? uniqid() . 'tz_portfolio_' . time() : $data['alias']) . '-' . $id . '.' . JFile::getExt($audioTempPath); $image = $this->uploadImageServer($audioTempPath, $destName, $audioPath, $this->_getImageSizes($params)); if (JFile::exists(JPATH_SITE . DIRECTORY_SEPARATOR . $audioTempPath)) { JFile::delete(JPATH_SITE . DIRECTORY_SEPARATOR . $audioTempPath); } } } } } } else { $image = $data['audio_soundcloud_hidden_image']; } } $_data .= ','; if ($image) { $_data .= $this->_db->quote($image); } else { $_data .= $this->_db->quote(''); } $_data .= ','; if ($data['audio_soundcloud_title']) { $_data .= $this->_db->quote($data['audio_soundcloud_title']); } else { $_data .= $this->_db->quote(''); } return $_data; } if ($data['audio_soundcloud_hidden_image']) { $this->deleteThumb(null, $data['audio_soundcloud_hidden_image']); } return $this->_db->quote('') . ',' . $this->_db->quote('') . ',' . $this->_db->quote(''); } return $this->_db->quote('') . ',' . $this->_db->quote('') . ',' . $this->_db->quote(''); }
function display($tpl = null) { $doc = JFactory::getDocument(); $menus = JMenu::getInstance('site'); $active = $menus->getActive(); $state = $this->get('State'); $params = $state->params; if ($params->get('fields_option_order')) { switch ($params->get('fields_option_order')) { case 'alpha': $fieldsOptionOrder = 't.value ASC'; break; case 'ralpha': $fieldsOptionOrder = 't.value DESC'; break; case 'ordering': $fieldsOptionOrder = 't.ordering ASC'; break; } if (isset($fieldsOptionOrder)) { $this->extraFields->setState('filter.option.order', $fieldsOptionOrder); } } // Set value again for option tz_portfolio_redirect if ($params->get('tz_portfolio_redirect') == 'default') { $params->set('tz_portfolio_redirect', 'article'); } $list = $this->get('Items'); $csscompress = null; if ($params->get('css_compression', 0)) { $csscompress = '.min'; } $jscompress = new stdClass(); $jscompress->extfile = null; $jscompress->folder = null; if ($params->get('js_compression', 1)) { $jscompress->extfile = '.min'; $jscompress->folder = '/packed'; } if ($list) { $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); if ($params->get('comment_function_type', 'default') != 'js') { // Compute the article slugs and prepare introtext (runs content plugins). if ($params->get('tz_show_count_comment', 1) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $fetch = new Services_Yadis_PlainHTTPFetcher(); } $threadLink = null; $comments = null; if ($list) { foreach ($list as $key => $item) { if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread[]=link:' . $item->fullLink; } elseif ($params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&urls[]=' . $item->fullLink; } } } //End Foreach } // Endif // Get comment counts for all items(articles) if ($params->get('tz_show_count_comment', 1) == 1) { // From Disqus if ($params->get('tz_comment_type', 'disqus') == 'disqus') { if ($threadLink) { $url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open'; $content = $fetch->get($url); if ($content) { if ($body = json_decode($content->body)) { if ($responses = $body->response) { if (!is_array($responses)) { JError::raiseNotice('300', JText::_('COM_TZ_PORTFOLIO_DISQUS_INVALID_SECRET_KEY')); } if (is_array($responses) && count($responses)) { foreach ($responses as $response) { $comments[$response->link] = $response->posts; } } } } } } } // From Facebook if ($params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink; $content = $fetch->get($url); if ($content) { if ($bodies = $content->body) { if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) { if (isset($matches[1]) && !empty($matches[1])) { foreach ($matches[1] as $val) { $match = null; if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) { if (isset($match[1]) && isset($match[2])) { $comments[$match[1]] = $match[2]; } } } } } } } } } } // End Get comment counts for all items(articles) } else { // Add facebook script api if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'facebook') { $doc->addScriptDeclaration(' (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\')); '); } // Add disqus script api if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $doc->addScriptDeclaration(' /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = \'templazatoturials\'; // required: replace example with your forum shortname /* * * DON\'T EDIT BELOW THIS LINE * * */ (function () { var s = document.createElement(\'script\'); s.async = true; s.type = \'text/javascript\'; s.src = \'http://\' + disqus_shortname + \'.disqus.com/count.js\'; (document.getElementsByTagName(\'HEAD\')[0] || document.getElementsByTagName(\'BODY\')[0]).appendChild(s); }()); '); $doc->addCustomTag(' <script type="text/javascript"> window.addEvent("load",function(){ var a=document.getElementsByTagName("A"); for(var h=0;h<a.length;h++){ if(a[h].href.indexOf("#disqus_thread")>=0){ var span = document.createElement("span"); span.innerHTML = a[h].innerHTML; a[h].parentNode.appendChild(span); a[h].remove(); } } }); </script> '); } } } $content_ids = array(); if ($list) { for ($i = 0, $n = count($list); $i < $n; $i++) { $content_ids[] = $list[$i]->id; } } $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $m_tag = JModelLegacy::getInstance('Tag', 'TZ_PortfolioModel', array('ignore_request' => true)); $m_tag->setState('params', $params); $m_tag->setState('article.id', $content_ids); $m_tag->setState('list.ordering', 'x.contentid'); $tags = $m_tag->getArticleTags(); } foreach ($list as &$row) { if ($tags && count($tags) && isset($tags[$row->id])) { $row->tags = $tags[$row->id]; } if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus' || $params->get('tz_comment_type', 'disqus') == 'facebook') { if ($comments) { if (array_key_exists($row->fullLink, $comments)) { $row->commentCount = $comments[$row->fullLink]; } else { $row->commentCount = 0; } } else { $row->commentCount = 0; } } } } else { $row->commentCount = 0; } // Compute the asset access permissions. // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$guest) { $asset = 'com_tz_portfolio.article.' . $row->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $row->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $row->created_by) { $row->params->set('access-edit', true); } } } // Old plugins: Ensure that text property is available if (!isset($row->text)) { $row->text = $row->introtext; } if (version_compare(COM_TZ_PORTFOLIO_VERSION, '3.1.7', '<')) { $row->text = null; if ($params->get('show_intro', 1)) { $row->text = $row->introtext; } } JPluginHelper::importPlugin('content'); $dispatcher = JDispatcher::getInstance(); // // Process the content plugins. // $row->event = new stdClass(); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.users', &$row, &$params, $state->get('offset'))); $row->introtext = $row->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.users', &$row, &$params, $state->get('offset'))); $row->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.users', &$row, &$params, $state->get('offset'))); $row->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.users', &$row, &$params, $state->get('offset'))); $row->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.users', &$row, &$params, $state->get('offset'))); $row->event->TZPortfolioVote = trim(implode("\n", $results)); //Get plugin Params for this article $pmodel->setState('filter.contentid', $row->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $row->pluginparams = clone $pluginParams; JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.users', &$row, &$params, &$pluginParams, $state->get('offset'))); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.users', &$row, &$params, &$pluginParams, $state->get('offset'))); $row->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.users', &$row, &$params, &$pluginParams, $state->get('offset'))); $row->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.users', &$row, &$params, &$pluginParams, $state->get('offset'))); $row->event->TZafterDisplayContent = trim(implode("\n", $results)); } } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); if ($active) { $params->def('page_heading', $params->get('page_title', $active->title)); } else { $params->def('page_heading', JText::_('JGLOBAL_ARTICLES')); } $this->assign('listsUsers', $list); $this->assign('authorParams', $params); $this->assign('params', $params); $this->assign('mediaParams', $params); $this->assign('pagination', $this->get('Pagination')); $author = JModelLegacy::getInstance('User', 'TZ_PortfolioModel'); $author = $author->getUserId(JRequest::getInt('created_by')); $this->assign('listAuthor', $author); $params = $this->get('state')->params; $model = JModelLegacy::getInstance('Portfolio', 'TZ_PortfolioModel', array('ignore_request' => true)); $model->setState('params', $params); $model->setState('filter.userId', $state->get('users.id')); $this->assign('char', $state->get('char')); $this->assign('availLetter', $model->getAvailableLetter()); if ($params->get('tz_use_image_hover', 1) == 1) { $doc->addStyleDeclaration(' .tz_image_hover{ opacity: 0; position: absolute; top:0; left: 0; transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; -moz-transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; -webkit-transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; } .tz_image_hover:hover{ opacity: 1; margin: 0; } '); } if ($params->get('tz_use_lightbox', 1) == 1) { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js' . '/jquery.fancybox.pack.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio/css/fancybox.min.css'); $width = null; $height = null; $autosize = null; if ($params->get('tz_lightbox_width')) { if (preg_match('/%|px/', $params->get('tz_lightbox_width'))) { $width = 'width:\'' . $params->get('tz_lightbox_width') . '\','; } else { $width = 'width:' . $params->get('tz_lightbox_width') . ','; } } if ($params->get('tz_lightbox_height')) { if (preg_match('/%|px/', $params->get('tz_lightbox_height'))) { $height = 'height:\'' . $params->get('tz_lightbox_height') . '\','; } else { $height = 'height:' . $params->get('tz_lightbox_height') . ','; } } if ($width || $height) { $autosize = 'fitToView: false,autoSize: false,'; } $scrollHidden = null; if ($params->get('use_custom_scrollbar', 1)) { $scrollHidden = ',scrolling: "no" ,iframe: { scrolling : "no", }'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(\'.fancybox\').fancybox({ type:\'iframe\', openSpeed:' . $params->get('tz_lightbox_speed', 350) . ', openEffect: "' . $params->get('tz_lightbox_transition', 'elastic') . '", ' . $width . $height . $autosize . ' helpers: { title : { type : "inside" }, overlay : { css : {background: "rgba(0,0,0,' . $params->get('tz_lightbox_opacity', 0.75) . ')"} } }' . $scrollHidden . ' }); </script> '); } $doc->addStyleSheet('components/com_tz_portfolio/css/tzportfolio.min.css'); $this->_prepareDocument(); // Add feed links if ($params->get('show_feed_link', 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $doc->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $doc->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } parent::display($tpl); }
public function display($tpl = null) { $app = JFactory::getApplication(); $user = JFactory::getUser(); $doc = JFactory::getDocument(); // Get some data from the models $state = $this->get('State'); $params = $state->params; if ($params->get('fields_option_order')) { switch ($params->get('fields_option_order')) { case 'alpha': $fieldsOptionOrder = 't.value ASC'; break; case 'ralpha': $fieldsOptionOrder = 't.value DESC'; break; case 'ordering': $fieldsOptionOrder = 't.ordering ASC'; break; } if (isset($fieldsOptionOrder)) { $this->extraFields->setState('filter.option.order', $fieldsOptionOrder); } } // Set value again for option tz_portfolio_redirect if ($params->get('tz_portfolio_redirect') == 'default') { $params->set('tz_portfolio_redirect', 'article'); } $csscompress = null; if ($params->get('css_compression', 0)) { $csscompress = '.min'; } $jscompress = new stdClass(); $jscompress->extfile = null; $jscompress->folder = null; if ($params->get('js_compression', 1)) { $jscompress->extfile = '.min'; $jscompress->folder = '/packed'; } $items = $this->get('Items'); $parent = $this->get('Parent'); $pagination = $this->get('Pagination'); if (!COM_TZ_PORTFOLIO_JVERSION_COMPARE) { $pagination->pagesTotal = $pagination->getPagesCounter(); } // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseError(500, implode("\n", $errors)); return false; } // Check whether category access level allows access. $user = JFactory::getUser(); $groups = $user->getAuthorisedViewLevels(); // PREPARE THE DATA // Get the metrics for the structural page layout. $numLeading = $params->def('num_leading_articles', 1); $numIntro = $params->def('num_intro_articles', 4); $numLinks = $params->def('num_links', 4); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); $categories = JCategories::getInstance('Content'); if ($params->get('comment_function_type', 'default') != 'js') { // Compute the article slugs and prepare introtext (runs content plugins). if ($params->get('tz_show_count_comment', 1) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $fetch = new Services_Yadis_PlainHTTPFetcher(); } $threadLink = null; $comments = null; if ($items) { foreach ($items as $key => &$item) { $slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; /*** New source ***/ //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($slug, $item->catid), true, -1); } else { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread[]=link:' . $contentUrl; } elseif ($params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&urls[]=' . $contentUrl; } } } } // Get comment counts for all items(articles) if ($params->get('tz_show_count_comment', 1) == 1) { // From Disqus if ($params->get('tz_comment_type', 'disqus') == 'disqus') { if ($threadLink) { $url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open'; $content = $fetch->get($url); if ($content) { if ($body = json_decode($content->body)) { if ($responses = $body->response) { if (!is_array($responses)) { JError::raiseNotice('300', JText::_('COM_TZ_PORTFOLIO_DISQUS_INVALID_SECRET_KEY')); } if (is_array($responses) && count($responses)) { foreach ($responses as $response) { $comments[$response->link] = $response->posts; } } } } } } } // From Facebook if ($params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink; $content = $fetch->get($url); if ($content) { if ($bodies = $content->body) { if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) { if (isset($matches[1]) && !empty($matches[1])) { foreach ($matches[1] as $val) { $match = null; if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) { if (isset($match[1]) && isset($match[2])) { $comments[$match[1]] = $match[2]; } } } } } } } } } } // End Get comment counts for all items(articles) } else { // Add facebook script api if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'facebook') { $doc->addScriptDeclaration(' (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\')); '); } // Add disqus script api if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $doc->addScriptDeclaration(' /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = \'templazatoturials\'; // required: replace example with your forum shortname /* * * DON\'T EDIT BELOW THIS LINE * * */ (function () { var s = document.createElement(\'script\'); s.async = true; s.type = \'text/javascript\'; s.src = \'http://\' + disqus_shortname + \'.disqus.com/count.js\'; (document.getElementsByTagName(\'HEAD\')[0] || document.getElementsByTagName(\'BODY\')[0]).appendChild(s); }()); '); $doc->addCustomTag(' <script type="text/javascript"> window.addEvent("load",function(){ var a=document.getElementsByTagName("A"); for(var h=0;h<a.length;h++){ if(a[h].href.indexOf("#disqus_thread")>=0){ var span = document.createElement("span"); span.innerHTML = a[h].innerHTML; a[h].parentNode.appendChild(span); a[h].remove(); } } }); </script> '); } } } $content_ids = array(); if ($items) { for ($i = 0, $n = count($items); $i < $n; $i++) { $content_ids[] = $items[$i]->id; } } $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $m_tag = JModelLegacy::getInstance('Tag', 'TZ_PortfolioModel', array('ignore_request' => true)); $m_tag->setState('params', $params); $m_tag->setState('article.id', $content_ids); $m_tag->setState('list.ordering', 'x.contentid'); $tags = $m_tag->getArticleTags(); } $_params = null; for ($i = 0, $n = count($items); $i < $n; $i++) { $item =& $items[$i]; if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; /*** New source ***/ $tmpl = null; if ($item->params->get('tz_use_lightbox', 1) == 1) { $tmpl = '&tmpl=component'; } //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } else { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus' || $params->get('tz_comment_type', 'disqus') == 'facebook') { if ($comments) { if (array_key_exists($item->fullLink, $comments)) { $item->commentCount = $comments[$item->fullLink]; } else { $item->commentCount = 0; } } else { $item->commentCount = 0; } } } } else { $item->commentCount = 0; } // No link for ROOT category if ($item->parent_alias == 'root') { $item->parent_slug = null; } $item->event = new stdClass(); $dispatcher = JDispatcher::getInstance(); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; // Ignore content plugins on links. if ($i < $numLeading + $numIntro) { // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } //Call trigger in group content JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.date', &$item, &$params, 0)); $item->introtext = $item->text; $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.date', &$item, &$item->params, 0)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.date', &$item, &$item->params, 0)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.date', &$item, &$item->params, 0)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.date', &$item, &$item->params, 0)); $item->event->TZPortfolioVote = trim(implode("\n", $results)); //Call trigger in group tz_portfolio JPluginHelper::importPlugin('tz_portfolio'); $item->introtext = JHtml::_('article.tzprepare', $item->introtext, '', $pluginParams, 'com_tz_portfolio.category'); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.article', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.article', &$item, &$params, &$pluginParams, 0)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.article', &$item, &$params, &$pluginParams, 0)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); } } // For blog layouts, preprocess the breakdown of leading, intro and linked articles. // This makes it much easier for the designer to just interrogate the arrays. $max = count($items); // The first group is the leading articles. $limit = $numLeading; for ($i = 0; $i < $limit && $i < $max; $i++) { $this->lead_items[$i] =& $items[$i]; if ($items[$i]->params->get('article_leading_image_size')) { $items[$i]->params->set('article_leading_image_resize', $items[$i]->params->get('article_leading_image_size', 'L')); } if ($items[$i]->params->get('article_leading_image_gallery_size')) { $items[$i]->params->set('article_leading_image_gallery_resize', $items[$i]->params->get('article_leading_image_gallery_size', 'L')); } } // The second group is the intro articles. $limit = $numLeading + $numIntro; // Order articles across, then down (or single column mode) for ($i = $numLeading; $i < $limit && $i < $max; $i++) { $this->intro_items[$i] =& $items[$i]; if ($items[$i]->params->get('article_secondary_image_size')) { $items[$i]->params->set('article_secondary_image_resize', $items[$i]->params->get('article_secondary_image_size', 'M')); } if ($items[$i]->params->get('article_secondary_image_gallery_size')) { $items[$i]->params->set('article_secondary_image_gallery_resize', $items[$i]->params->get('article_secondary_image_gallery_size', 'M')); } } $this->columns = max(1, $params->def('num_columns', 1)); $order = $params->def('multi_column_order', 1); if ($order == 0 && $this->columns > 1) { // call order down helper $this->intro_items = TZ_PortfolioHelperQuery::orderDownColumns($this->intro_items, $this->columns); } $limit = $numLeading + $numIntro + $numLinks; // The remainder are the links. for ($i = $numLeading + $numIntro; $i < $limit && $i < $max; $i++) { $this->link_items[$i] =& $items[$i]; } //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($params->get('pageclass_sfx')); $this->assign('state', $state); $this->assign('items', $items); // $this->assign('category', $category); // $this->assignRef('children', $children); $this->assignRef('params', $params); // $this->assignRef('parent', $parent); $this->assignRef('pagination', $pagination); $this->assignRef('user', $user); $this->assign('listImage', $this->get('CatImages')); $model = JModelLegacy::getInstance('Portfolio', 'TZ_PortfolioModel', array('ignore_request' => true)); $pParams = clone $params; $pParams->set('tz_catid', $params->get('tz_catid', array())); $model->setState('params', $pParams); $model->setState('filter.year', $state->get('filter.year')); $model->setState('filter.month', $state->get('filter.month')); $this->assign('char', $state->get('char')); $this->assign('availLetter', $model->getAvailableLetter()); // $catParams = $category -> params; // $params -> merge($catParams); $this->assign('mediaParams', $params); if ($params->get('tz_use_image_hover', 1) == 1) { $doc->addStyleDeclaration(' .tz_image_hover{ opacity: 0; position: absolute; top:0; left: 0; transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; -moz-transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; -webkit-transition: opacity ' . $params->get('tz_image_timeout', 0.35) . 's ease-in-out; } .tz_image_hover:hover{ opacity: 1; margin: 0; } '); } if ($params->get('tz_use_lightbox', 1) == 1) { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js' . $jscompress->folder . '/jquery.fancybox.pack.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio/css/fancybox.min.css'); $width = null; $height = null; $autosize = null; if ($params->get('tz_lightbox_width')) { if (preg_match('/%|px/', $params->get('tz_lightbox_width'))) { $width = 'width:\'' . $params->get('tz_lightbox_width') . '\','; } else { $width = 'width:' . $params->get('tz_lightbox_width') . ','; } } if ($params->get('tz_lightbox_height')) { if (preg_match('/%|px/', $params->get('tz_lightbox_height'))) { $height = 'height:\'' . $params->get('tz_lightbox_height') . '\','; } else { $height = 'height:' . $params->get('tz_lightbox_height') . ','; } } if ($width || $height) { $autosize = 'fitToView: false,autoSize: false,'; } $scrollHidden = null; if ($params->get('use_custom_scrollbar', 1)) { $scrollHidden = ',scrolling: "no" ,iframe: { scrolling : "no", }'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(\'.fancybox\').fancybox({ type:\'iframe\', openSpeed:' . $params->get('tz_lightbox_speed', 350) . ', openEffect: "' . $params->get('tz_lightbox_transition', 'elastic') . '", ' . $width . $height . $autosize . ' helpers: { title : { type : "inside" }, overlay : { css : {background: "rgba(0,0,0,' . $params->get('tz_lightbox_opacity', 0.75) . ')"} } }' . $scrollHidden . ' }); </script> '); } $doc->addStyleSheet('components/com_tz_portfolio/css/tzportfolio.min.css'); // $this->_prepareDocument(); // Add feed links if ($this->params->get('show_feed_link', 1)) { $link = '&format=feed&limitstart='; $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0'); $this->document->addHeadLink(JRoute::_($link . '&type=rss'), 'alternate', 'rel', $attribs); $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0'); $this->document->addHeadLink(JRoute::_($link . '&type=atom'), 'alternate', 'rel', $attribs); } parent::display($tpl); }
public function getItems() { if ($items = parent::getItems()) { $user = JFactory::getUser(); $userId = $user->get('id'); $guest = $user->get('guest'); $params = $this->getState('params'); $contentId = array(); $tzDate = array(); $content_ids = array(); $_params = null; $categories = JCategories::getInstance('Content'); $threadLink = null; $comments = null; foreach ($items as &$item) { $content_ids[] = $item->id; $_params = clone $params; $temp = clone $params; // Get the global params $globalParams = JComponentHelper::getParams('com_tz_portfolio', true); /*** New source ***/ $category = $categories->get($item->catid); $catParams = new JRegistry($category->params); if ($this->parameter_merge_fields) { foreach ($this->parameter_merge_fields as $value) { if ($catParams->get($value) != '') { $_params->set($value, $catParams->get($value)); } } } $item->params = clone $_params; $articleParams = new JRegistry(); $articleParams->loadString($item->attribs); // create an array of just the params set to 'use_article' $menuParamsArray = $temp->toArray(); $articleArray = array(); foreach ($menuParamsArray as $key => $value) { if ($value === 'use_article') { // if the article has a value, use it if ($articleParams->get($key) != '') { // get the value from the article $articleArray[$key] = $articleParams->get($key); } else { if ($_params->get($key) != '') { $articleArray[$key] = $_params->get($key); } else { if (!$_params->get($key) || $_params->get($key) == '') { // otherwise, use the global value $articleArray[$key] = $globalParams->get($key); } } } if (count($this->parameter_fields)) { $parameter_fields = $this->parameter_fields; if (in_array($key, array_keys($this->parameter_fields))) { if (count($parameter_fields[$key])) { foreach ($parameter_fields[$key] as $value_field) { $articleArray[$value_field] = $articleParams->get($value_field); } } } } } } // merge the selected article params if (count($articleArray) > 0) { $articleParams = new JRegistry(); $articleParams->loadArray($articleArray); $item->params->merge($articleParams); } if ($params->get('comment_function_type', 'default') != 'js') { /*** New source ***/ //Check redirect to view article if ($item->params->get('tz_portfolio_redirect', 'p_article') == 'article') { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } else { $contentUrl = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread[]=link:' . $contentUrl; } elseif ($params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&urls[]=' . $contentUrl; } } } } if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $fetch = new Services_Yadis_PlainHTTPFetcher(); } // Get comment counts for all items(articles) if ($params->get('tz_show_count_comment', 1) == 1) { // From Disqus if ($params->get('tz_comment_type', 'disqus') == 'disqus') { if ($threadLink) { $url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open'; $content = $fetch->get($url); if ($content) { if ($body = json_decode($content->body)) { if ($responses = $body->response) { if (!is_array($responses)) { JError::raiseNotice('300', JText::_('COM_TZ_PORTFOLIO_DISQUS_INVALID_SECRET_KEY')); } if (is_array($responses) && count($responses)) { foreach ($responses as $response) { $comments[$response->link] = $response->posts; } } } } } } } // From Facebook if ($params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink; $content = $fetch->get($url); if ($content) { if ($bodies = $content->body) { if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) { if (isset($matches[1]) && !empty($matches[1])) { foreach ($matches[1] as $val) { $match = null; if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) { if (isset($match[1]) && isset($match[2])) { $comments[$match[1]] = $match[2]; } } } } } } } } } } // End Get comment counts for all items(articles) } $tags = null; if (count($content_ids) && $params->get('show_tags', 1)) { $m_tag = JModelLegacy::getInstance('Tag', 'TZ_PortfolioModel', array('ignore_request' => true)); $m_tag->setState('params', $params); $m_tag->setState('article.id', $content_ids); $m_tag->setState('list.ordering', 'x.contentid'); $tags = $m_tag->getArticleTags(); } //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); foreach ($items as $i => &$item) { if ($tags && count($tags) && isset($tags[$item->id])) { $item->tags = $tags[$item->id]; } /*** Start New Source ***/ $tmpl = null; if ($item->params->get('tz_use_lightbox', 1) == 1) { $tmpl = '&tmpl=component'; } //Check redirect to view article if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid), true, -1); } else { $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); } /*** End New Source ***/ if ($params->get('comment_function_type', 'default') != 'js') { if ($params->get('tz_show_count_comment', 1) == 1) { if ($params->get('tz_comment_type', 'disqus') == 'disqus' || $params->get('tz_comment_type', 'disqus') == 'facebook') { if ($comments) { if (array_key_exists($item->fullLink, $comments)) { $item->commentCount = $comments[$item->fullLink]; } else { $item->commentCount = 0; } } else { $item->commentCount = 0; } } } } else { $item->commentCount = 0; } // Compute the asset access permissions. // Technically guest could edit an article, but lets not check that to improve performance a little. if (!$guest) { $asset = 'com_content.article.' . $item->id; // Check general edit permission first. if ($user->authorise('core.edit', $asset)) { $item->params->set('access-edit', true); } elseif (!empty($userId) && $user->authorise('core.edit.own', $asset)) { // Check for a valid user and that they are the owner. if ($userId == $item->created_by) { $item->params->set('access-edit', true); } } } //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; // Add feed links if (!JRequest::getCmd('format', null) and !JRequest::getCmd('type', null)) { $dispatcher = JDispatcher::getInstance(); // Old plugins: Ensure that text property is available if (!isset($item->text)) { $item->text = $item->introtext; } // // Process the content plugins. // JPluginHelper::importPlugin('content'); $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->introtext = $item->text; $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.timeline', &$item, &$params, $this->getState('list.start'))); $item->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.timeline', &$item, &$params, 0)); $item->event->TZPortfolioVote = trim(implode("\n", $results)); JPluginHelper::importPlugin('tz_portfolio'); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.timeline', &$item, &$this->params, &$pluginParams, $this->getState('list.start'))); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.timeline', &$item, &$params, &$pluginParams, $this->getState('list.start'))); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.timeline', &$item, &$params, &$pluginParams, $this->getState('list.start'))); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.timeline', &$item, &$params, &$pluginParams, $this->getState('list.start'))); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); } if ($introLimit = $params->get('tz_article_intro_limit')) { $text = new AutoCutText($item->introtext, $introLimit); $item->introtext = $text->getIntro(); } $this->articles[] = $item->id; $model = null; if (!empty($item->tagName)) { $contentId[] = $item->id; if ($tagsName = $this->getTagName($item->id)) { $item->tagName = $tagsName; } } //Get Catid $this->categories[] = $item->catid; if ($model = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel')) { if ($media = $model->getMedia($item->id)) { if ($media[0]->type != 'video' && $media[0]->type != 'audio') { if ($params->get('portfolio_image_size', 'M')) { } if (!empty($media[0]->images)) { $item->tz_image = JURI::root() . str_replace('.' . JFile::getExt($media[0]->images), '_' . $params->get('portfolio_image_size', 'M') . '.' . JFile::getExt($media[0]->images), $media[0]->images); $item->tz_image_title = $media[0]->imagetitle; } else { $item->tz_image = null; } } else { if (!empty($media[0]->thumb)) { $item->tz_image = JURI::root() . str_replace('.' . JFile::getExt($media[0]->thumb), '_' . $params->get('portfolio_image_size', 'M') . '.' . JFile::getExt($media[0]->thumb), $media[0]->thumb); $item->tz_image_title = $media[0]->imagetitle; } else { $item->tz_image = null; } } } else { $item->tz_image = null; } } if ($params->get('tz_filter_type', 'tags') == 'tags') { $item->allTags = $this->_getAllTags($item->created); } } $this->_getTags($contentId); return $items; } return false; }
function display($tpl = null) { // Initialise variables. $app = JFactory::getApplication(); $doc = JFactory::getDocument(); $tmpl = JRequest::getString('tmpl'); if ($tmpl) { JHtml::_('bootstrap.framework'); JHtml::_('jquery.framework'); } $media = JModelLegacy::getInstance('Media', 'TZ_PortfolioModel'); $listMedia = $media->getMedia(); $attach = JModelLegacy::getInstance('Attachments', 'TZ_PortfolioModel'); $tzUser = JModelLegacy::getInstance('User', 'TZ_PortfolioModel'); $tzTags = JModelLegacy::getInstance('Tag', 'TZ_PortfolioModel'); $this->assign('listMedia', $listMedia); $this->assign('listAttach', $attach->getAttachments()); $this->assign('listAuthor', $tzUser->getUser()); $this->assign('listTags', $tzTags->getTag()); $user = JFactory::getUser(); $userId = $user->get('id'); $dispatcher = JDispatcher::getInstance(); $this->item = $this->get('Item'); $this->itemMore = $this->get('ItemRelated'); $this->print = $app->input->getBool('print'); $this->state = $this->get('State'); $this->user = $user; // Check for errors. if (count($errors = $this->get('Errors'))) { JError::raiseWarning(500, implode("\n", $errors)); return false; } // Create a shortcut for $item. $item =& $this->item; // Add router helpers. $item->slug = $item->alias ? $item->id . ':' . $item->alias : $item->id; $item->catslug = $item->category_alias ? $item->catid . ':' . $item->category_alias : $item->catid; $item->parent_slug = $item->category_alias ? $item->parent_id . ':' . $item->parent_alias : $item->parent_id; // TODO: Change based on shownoauth $item->readmore_link = null; // Merge article params. If this is single-article view, menu params override article params // Otherwise, article params override menu item params $this->params = $this->state->get('params'); $csscompress = null; if ($this->params->get('css_compression', 0)) { $csscompress = '.min'; } $jscompress = new stdClass(); $jscompress->extfile = null; $jscompress->folder = null; if ($this->params->get('js_compression', 1)) { $jscompress->extfile = '.min'; $jscompress->folder = '/packed'; } $active = $app->getMenu()->getActive(); $temp = clone $this->params; // $item -> params -> merge($active -> params); // Check to see which parameters should take priority if ($active) { $currentLink = $active->link; // If the current view is the active item and an article view for this article, then the menu item params take priority if (strpos($currentLink, 'view=article') && strpos($currentLink, '&id=' . (string) $item->id)) { // $item->params are the article params, $temp are the menu item params // Merge so that the menu item params take priority $item->params->merge($temp); // Load layout from active query (in case it is an alternative menu item) if (isset($active->query['layout'])) { $this->setLayout($active->query['layout']); } } else { // Current view is not a single article, so the article params take priority here // Merge the menu item params with the article params so that the article params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-article menu item) // Single-article menu item layout takes priority over alt layout for an article if ($layout = $item->params->get('article_layout')) { $this->setLayout($layout); } } } else { // Merge so that article params take priority $temp->merge($item->params); $item->params = $temp; // Check for alternative layouts (since we are not in a single-article menu item) // Single-article menu item layout takes priority over alt layout for an article if ($layout = $item->params->get('article_layout')) { $this->setLayout($layout); } } // Create "link" and "fullLink" for article object $tmpl = null; if ($item->params->get('tz_use_lightbox', 1) == 1) { $tmpl = '&tmpl=component'; } $item->link = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl, true, -1); $item->fullLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid), true, -1); $item->parent_link = JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($item->parent_slug)); $item->category_link = JRoute::_(TZ_PortfolioHelperRoute::getCategoryRoute($item->catslug)); if ($item->params->get('tz_portfolio_redirect') == 'p_article') { $configLink = JRoute::_(TZ_PortfolioHelperRoute::getPortfolioArticleRoute($item->slug, $item->catid) . $tmpl, true, -1); } else { $configLink = JRoute::_(TZ_PortfolioHelperRoute::getArticleRoute($item->slug, $item->catid) . $tmpl, true, -1); } // Compare current link and config link to redirect if ($item->link != $configLink) { JFactory::getApplication()->redirect($configLink); } $url = JURI::getInstance()->toString(); $this->assign('linkCurrent', $url); $offset = $this->state->get('list.offset'); // Check the view access to the article (the model has already computed the values). if ($item->params->get('access-view') != true && ($item->params->get('show_noauth') != true && $user->get('guest'))) { JError::raiseWarning(403, JText::_('JERROR_ALERTNOAUTHOR')); return; } if ($item->params->get('show_intro', '1') == '1') { $item->text = $item->introtext . ' ' . $item->fulltext; } elseif ($item->fulltext) { $item->text = $item->fulltext; } else { $item->text = $item->introtext; } $item->commentCount = 0; if ($item->params->get('comment_function_type', 'default') != 'js') { // Compute the article slugs and prepare introtext (runs content plugins). if ($item->params->get('tz_show_count_comment', 1) == 1) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $fetch = new Services_Yadis_PlainHTTPFetcher(); } $threadLink = null; $comments = null; if ($item) { if ($item->params->get('tz_show_count_comment', 1) == 1) { if ($item->params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread=link:' . $item->fullLink; } elseif ($item->params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&ids=' . $item->fullLink; } } } // Get comment counts for all items(articles) if ($item->params->get('tz_show_count_comment', 1) == 1) { // From Disqus if ($item->params->get('tz_comment_type', 'disqus') == 'disqus') { if ($threadLink) { $url = 'https://disqus.com/api/3.0/threads/listPosts.json?api_secret=' . $item->params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $item->params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=approved'; $content = $fetch->get($url); if ($content) { if ($body = json_decode($content->body)) { if ($responses = $body->response) { $comments = count($responses); } } } } } // From Facebook if ($item->params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://graph.facebook.com/?ids=' . $threadLink; $content = $fetch->get($url); $contentUrl = $item->fullLink; if ($content) { if ($body = $content->body) { if (isset($body->{$contentUrl}->comments)) { $comments = $body->{$contentUrl}->comments; } } } } } } // End Get comment counts for all items(articles) if ($comments) { $item->commentCount = $comments; } } else { // Add facebook script api if ($item->params->get('tz_show_count_comment', 1) == 1) { if ($item->params->get('tz_comment_type', 'disqus') == 'facebook') { $doc->addScriptDeclaration(' (function(d, s, id) { var js, fjs = d.getElementsByTagName(s)[0]; if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = "//connect.facebook.net/en_GB/all.js#xfbml=1"; fjs.parentNode.insertBefore(js, fjs); }(document, \'script\', \'facebook-jssdk\')); '); } // Add disqus script api if ($item->params->get('tz_comment_type', 'disqus') == 'disqus') { $doc->addScriptDeclaration(' /* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */ var disqus_shortname = \'templazatoturials\'; // required: replace example with your forum shortname /* * * DON\'T EDIT BELOW THIS LINE * * */ (function () { var s = document.createElement(\'script\'); s.async = true; s.type = \'text/javascript\'; s.src = \'http://\' + disqus_shortname + \'.disqus.com/count.js\'; (document.getElementsByTagName(\'HEAD\')[0] || document.getElementsByTagName(\'BODY\')[0]).appendChild(s); }()); '); $doc->addCustomTag(' <script type="text/javascript"> window.addEvent("load",function(){ var a=document.getElementsByTagName("A"); for(var h=0;h<a.length;h++){ if(a[h].href.indexOf("#disqus_thread")>=0){ var span = document.createElement("span"); span.innerHTML = a[h].innerHTML; a[h].parentNode.appendChild(span); a[h].remove(); } } }); </script> '); } } } // // Process the content plugins. // JPluginHelper::importPlugin('content'); JPluginHelper::importPlugin('tz_portfolio'); //Get Plugins Model $pmodel = JModelLegacy::getInstance('Plugins', 'TZ_PortfolioModel', array('ignore_request' => true)); //Get plugin Params for this article $pmodel->setState('filter.contentid', $item->id); $pluginItems = $pmodel->getItems(); $pluginParams = $pmodel->getParams(); $item->pluginparams = clone $pluginParams; if ($item->params->get('show_intro', '1') == '1') { $text = $item->introtext . ' ' . $item->fulltext; } elseif ($item->fulltext) { $text = $item->fulltext; } else { $text = $item->introtext; } if ($item->introtext && !empty($item->introtext)) { $item->text = $item->introtext; $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); // $results = $dispatcher->trigger('onTZPortfolioCommentDisplay', array('com_tz_portfolio.article', &$item, &$item->params, $offset)); // $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.article', &$item, &$item->params, $offset)); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $item->introtext = $item->text; } if ($item->fulltext && !empty($item->fulltext)) { $item->text = $item->fulltext; $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); // $results = $dispatcher->trigger('onTZPortfolioCommentDisplay', array('com_tz_portfolio.article', &$item, &$item->params, $offset)); // $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.article', &$item, &$item->params, $offset)); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $item->fulltext = $item->text; } $item->text = $text; $results = $dispatcher->trigger('onContentPrepare', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $item->event = new stdClass(); $results = $dispatcher->trigger('onContentAfterTitle', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $item->event->afterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $item->event->beforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentAfterDisplay', array('com_tz_portfolio.article', &$item, &$this->params, $offset)); $item->event->afterDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPortfolioCommentDisplay', array('com_tz_portfolio.article', &$item, &$item->params, $offset)); $item->event->onTZPortfolioCommentDisplay = trim(implode("\n", $results)); $results = $dispatcher->trigger('onContentTZPortfolioVote', array('com_tz_portfolio.article', &$item, &$item->params, $offset)); $item->event->TZPortfolioVote = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginPrepare', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $results = $dispatcher->trigger('onTZPluginAfterTitle', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $item->event->TZafterDisplayTitle = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginBeforeDisplay', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $item->event->TZbeforeDisplayContent = trim(implode("\n", $results)); $results = $dispatcher->trigger('onTZPluginAfterDisplay', array('com_tz_portfolio.article', &$item, &$item->params, &$pluginParams, $offset)); $item->event->TZafterDisplayContent = trim(implode("\n", $results)); // Increment the hit counter of the article. if (!$this->params->get('intro_only') && $offset == 0) { $model = $this->getModel(); $model->hit(); } if ($_SERVER) { if (isset($_SERVER['HTTP_REFERER'])) { $referLink = $_SERVER['HTTP_REFERER']; if (!empty($referLink)) { $router = JSite::getRouter(); $url = JURI::getInstance($referLink); if ($url != JUri::root() && JRequest::getCmd('tmpl')) { $parseUrl = $router->parse($url); if ($parseUrl) { if ($parseUrl['option'] == 'com_tz_portfolio') { if (isset($parseUrl['view'])) { $view = $parseUrl['view']; } if ($view == 'users' || $view == 'tags') { $this->state->set('article.catid', $this->item->catid); $itemId = $this->get('FindItemId'); $menu = $app->getMenu('site'); $mParams = $menu->getParams($itemId); if ($mParams->get('fields_order')) { $item->params->set('fields_order', $mParams->get('fields_order')); } } } } } } } } $extraFields = JModelLegacy::getInstance('ExtraFields', 'TZ_PortfolioModel', array('ignore_request' => true)); $extraFields->setState('article.id', JRequest::getInt('id')); if ($item->params->get('fields_option_order')) { switch ($item->params->get('fields_option_order')) { case 'alpha': $fieldsOptionOrder = 't.value ASC'; break; case 'ralpha': $fieldsOptionOrder = 't.value DESC'; break; case 'ordering': $fieldsOptionOrder = 't.ordering ASC'; break; } if (isset($fieldsOptionOrder)) { $extraFields->setState('filter.option.order', $fieldsOptionOrder); } } $extraFields->setState('params', $item->params); $extraFields->setState('orderby', $item->params->get('fields_order')); $this->assign('blogFields', $extraFields->getExtraFields()); $params = $media->getCatParams($item->catid); if ($listMedia) { if ($listMedia[0]->type == 'image') { if ($params->get('detail_article_image_size')) { $params->set('article_image_resize', strtolower($params->get('detail_article_image_size'))); } } if ($listMedia[0]->type == 'imagegallery') { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js' . '/jquery.flexslider-min.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio/css/flexslider.min.css'); if ($params->get('detail_article_image_gallery_size')) { $params->set('article_image_gallery_resize', strtolower($params->get('detail_article_image_gallery_size'))); } if ($item->params->get('tz_image_gallery_crop')) { $params->set('article_image_gallery_crop', $params->get('tz_image_gallery_crop')); } } } if ($item->params->get('useCloudZoom', 1) == 1) { $doc->addStyleSheet('components/com_tz_portfolio/css/cloud-zoom.min.css'); $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js' . '/cloud-zoom.1.0.3.min.js"></script>'); } if ($item->params->get('tz_use_lightbox', 1) == 1 and !$tmpl) { $doc->addCustomTag('<script type="text/javascript" src="components/com_tz_portfolio/js' . '/jquery.fancybox.pack.js"></script>'); $doc->addStyleSheet('components/com_tz_portfolio/css/fancybox.min.css'); $width = null; $height = null; $autosize = null; if ($item->params->get('tz_lightbox_width')) { if (preg_match('/%|px/', $item->params->get('tz_lightbox_width'))) { $width = 'width:\'' . $item->params->get('tz_lightbox_width') . '\','; } else { $width = 'width:' . $item->params->get('tz_lightbox_width') . ','; } } if ($item->params->get('tz_lightbox_height')) { if (preg_match('/%|px/', $item->params->get('tz_lightbox_height'))) { $height = 'height:\'' . $item->params->get('tz_lightbox_height') . '\','; } else { $height = 'height:' . $item->params->get('tz_lightbox_height') . ','; } } if ($width || $height) { $autosize = 'fitToView: false,autoSize: false,'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(\'.fancybox\').fancybox({ type:\'iframe\', openSpeed:' . $item->params->get('tz_lightbox_speed', 350) . ', openEffect: "' . $item->params->get('tz_lightbox_transition', 'elastic') . '", ' . $width . $height . $autosize . ' helpers: { title : { type : "inside" }, overlay : { css : {background: "rgba(0,0,0,' . $item->params->get('tz_lightbox_opacity', 0.75) . ')"} } } }); </script> '); } /* Add scrollbar script */ if ($item->params->get('use_custom_scrollbar', 1) && JRequest::getString('tmpl') == 'component' && !$this->print) { $doc->addStyleSheet('components/com_tz_portfolio/css/jquery.mCustomScrollbar.min.css'); $doc->addCustomTag('<script src="components/com_tz_portfolio/js' . '/jquery.mCustomScrollbar.min.js"></script>'); if ($item->params->get('horizontalScroll', 0)) { $horizontalScroll = 'true'; } else { $horizontalScroll = 'false'; } if ($item->params->get('mouseWheel', 1)) { $mouseWheel = 'true'; } else { $mouseWheel = 'false'; } if ($item->params->get('autoDraggerLength', 1)) { $autoDraggerLength = 'true'; } else { $autoDraggerLength = 'false'; } if ($item->params->get('autoHideScrollbar', 0)) { $autoHideScrollbar = 'true'; } else { $autoHideScrollbar = 'false'; } if ($item->params->get('scrollButtons_enable', 1)) { $scrollButtons_enable = 'true'; } else { $scrollButtons_enable = 'false'; } if ($item->params->get('advanced_updateOnBrowserResize', 1)) { $advanced_updateOnBrowserResize = 'true'; } else { $advanced_updateOnBrowserResize = 'false'; } if ($item->params->get('advanced_updateOnContentResize', 0)) { $advanced_updateOnContentResize = 'true'; } else { $advanced_updateOnContentResize = 'false'; } if ($item->params->get('advanced_autoExpandHorizontalScroll', 0)) { $advanced_autoExpandHorizontalScroll = 'true'; } else { $advanced_autoExpandHorizontalScroll = 'false'; } if ($item->params->get('advanced_autoScrollOnFocus', 1)) { $advanced_autoScrollOnFocus = 'true'; } else { $advanced_autoScrollOnFocus = 'false'; } if ($item->params->get('advanced_normalizeMouseWheelDelta', 0)) { $advanced_normalizeMouseWheelDelta = 'true'; } else { $advanced_normalizeMouseWheelDelta = 'false'; } if ($item->params->get('contentTouchScroll', 1)) { $contentTouchScroll = 'true'; } else { $contentTouchScroll = 'false'; } $doc->addCustomTag('<script type="text/javascript"> jQuery(document).ready(function(){ jQuery(".TzItemPage").height(jQuery(window).height()).mCustomScrollbar({ set_width:' . ($item->params->get('set_width') ? $item->params->get('set_width') : 'false') . ', /*optional element width: boolean, pixels, percentage*/ set_height:' . ($item->params->get('set_height') ? $item->params->get('set_height') : 'false') . ', /*optional element height: boolean, pixels, percentage*/ horizontalScroll:' . $horizontalScroll . ', /*scroll horizontally: boolean*/ scrollInertia:' . $item->params->get('scrollInertia', 40) . ', /*scrolling inertia: integer (milliseconds)*/ mouseWheel: ' . $mouseWheel . ', /*mousewheel support: boolean*/ mouseWheelPixels:' . ($params->get('mouseWheelPixels') ? $params->get('mouseWheelPixels') : '"auto"') . ', /*mousewheel pixels amount: integer, "auto"*/ autoDraggerLength:' . $autoDraggerLength . ', /*auto-adjust scrollbar dragger length: boolean*/ autoHideScrollbar: ' . $autoHideScrollbar . ', /*auto-hide scrollbar when idle*/ snapAmount:' . ($item->params->get('snapAmount') ? $item->params->get('snapAmount') : 'null') . ', /* optional element always snaps to a multiple of this number in pixels */ snapOffset:' . ($item->params->get('snapOffset') ? $item->params->get('snapOffset') : 0) . ', /* when snapping, snap with this number in pixels as an offset */ scrollButtons:{ /*scroll buttons*/ enable: ' . $scrollButtons_enable . ', /*scroll buttons support: boolean*/ scrollType:"' . ($item->params->get('scrollButtons_snapOffset') ? $item->params->get('scrollButtons_snapOffset') : 'continuous') . '", /*scroll buttons scrolling type: "continuous", "pixels"*/ scrollSpeed:' . ($item->params->get('scrollButtons_scrollSpeed') ? $item->params->get('scrollButtons_scrollSpeed') : '"auto"') . ', /*scroll buttons continuous scrolling speed: integer, "auto"*/ scrollAmount:' . ($item->params->get('scrollButtons_scrollAmount') ? $item->params->get('scrollButtons_scrollAmount') : 100) . ' /*scroll buttons pixels scroll amount: integer (pixels)*/ }, advanced:{ updateOnBrowserResize: ' . $advanced_updateOnBrowserResize . ', /*update scrollbars on browser resize (for layouts based on percentages): boolean*/ updateOnContentResize: ' . $advanced_updateOnContentResize . ', /*auto-update scrollbars on content resize (for dynamic content): boolean*/ autoExpandHorizontalScroll: ' . $advanced_autoExpandHorizontalScroll . ', /*auto-expand width for horizontal scrolling: boolean*/ autoScrollOnFocus: ' . $advanced_autoScrollOnFocus . ', /*auto-scroll on focused elements: boolean*/ normalizeMouseWheelDelta: ' . $advanced_normalizeMouseWheelDelta . ' /*normalize mouse-wheel delta (-1/1)*/ }, contentTouchScroll: ' . $contentTouchScroll . ', /*scrolling by touch-swipe content: boolean*/ callbacks:{ onScrollStart:function(){}, /*user custom callback function on scroll start event*/ onScroll:function(){}, /*user custom callback function on scroll event*/ onTotalScroll:function(){}, /*user custom callback function on scroll end reached event*/ onTotalScrollBack:function(){}, /*user custom callback function on scroll begin reached event*/ onTotalScrollOffset:0, /*scroll end reached offset: integer (pixels)*/ onTotalScrollBackOffset:0, /*scroll begin reached offset: integer (pixels)*/ whileScrolling:function(){} /*user custom callback function on scrolling event*/ }, theme:"' . $item->params->get('scrollbar_theme', 'dark-thick') . '" }); }); jQuery(window).resize(function(){ jQuery(".TzItemPage").height(jQuery(this).height()) });; </script>'); } /* End add scrollbar script */ if ($item->params->get('show_video', 1)) { $doc->addCustomTag('<script src="components/com_tz_portfolio/js' . '/fluidvids.min.js" type="text/javascript"></script>'); $doc->addCustomTag('<script type="text/javascript"> jQuery(document).ready(function(){ fluidvids.init({ selector: [\'.TzArticleMedia iframe\'], players: [\'www.youtube.com\', \'player.vimeo.com\'] }); }); </script>'); } $params->merge($temp); $params->merge($item->params); $this->assign('mediaParams', $params); $this->assign('authorParams', $params); $extraFields = JModelLegacy::getInstance('ExtraFields', 'TZ_PortfolioModel', array('ignore_request' => true)); $extraFields->setState('article.id', JRequest::getInt('id')); $extraFields->setState('params', $params); $this->assign('listFields', $extraFields->getExtraFields()); $doc->addStyleSheet('components/com_tz_portfolio/css/tzportfolio.min.css'); //Escape strings for HTML output $this->pageclass_sfx = htmlspecialchars($this->item->params->get('pageclass_sfx')); $this->_prepareDocument(); $this->generateLayout($item, $params, $dispatcher, $csscompress); parent::display($tpl); // if($this -> item -> params -> get('show_vote',1)){ // if($this -> item -> rating){ // echo $this -> _addRichSnippets(); // } // } }
/** * Method get the title,keywords,description image url. */ function getWebsite() { require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'readfile.php'; $link_url = strip_tags(htmlspecialchars($_POST['link'])); $link_url = trim($link_url); if (isset($link_url) && !empty($link_url)) { $data = $link_url; $content = array(); $check_text = array("\\", "?", "~", "+", "-", "\$", "#", "\"", "=", "/"); $docUrl = new Services_Yadis_PlainHTTPFetcher(); if ($contentURL = $docUrl->get($data)) { if (empty($content['title'])) { if (preg_match('/<title>(.*?)<\\/title>/i', $contentURL->body, $match)) { // get title $title_url = str_replace($check_text, '', $match[1]); $content['title'] = $this->length_character($title_url, $this->getState('max_text_title')); } } if (preg_match('/<meta.*?name="description".*?\\/>/i', $contentURL->body, $match)) { // get description if (preg_match_all('/content="(.*?)"/', $match[0], $_match)) { $introtext = array_pop($_match[0]); } $key_woards = explode("=", $introtext); $introtext_url = str_replace($check_text, '', $key_woards[1]); $content['introtext'] = $this->length_character($introtext_url, $this->getState('max_text_descript')); } if (preg_match('/<meta.*?name="keywords".*?\\/>/i', $contentURL->body, $_match)) { // get keywords if (preg_match_all('/content="(.*?)"/', $_match[0], $key)) { $arr_s_key = array_pop($key[0]); $key_woards = explode("=", $arr_s_key); $keyword_url = str_replace($check_text, '', $key_woards[1]); $content['keywoa'] = $this->length_character($keyword_url, $this->getState('max_text_keyword')); } } // get host name $referer = parse_url($link_url); $url_return = $referer['scheme'] . '://' . $referer['host']; $content['url'] = $url_return; // get host name 2 $slash = strrpos($link_url, '/') + 1; $link_url = substr($link_url, 0, $slash); $content['url2'] = $link_url; if (preg_match('/<meta\\s*?property="og:image".*?content="(.*?)">/i', $contentURL->body, $match_img)) { // get img meta $aar_icon = array(); $aar_icon[] = $match_img[1]; } if (preg_match_all('/<img.*?src="(.*?)".*?/i', $contentURL->body, $match)) { // get img $arr = array(); $arr = $match[1]; } else { return 'notimage'; } if (!empty($aar_icon)) { $new_arr = array(); $new_arr = array_merge($aar_icon, $arr); $content['img'] = $new_arr; } else { $content['img'] = $arr; } if (preg_match('/<meta\\s*?property="og:video".*?content="(.*?)">/i', $contentURL->body, $match_v)) { // get img meta $content['video'] = $match_v[1]; } return $content; } } }
public function ajaxComments() { $data = json_decode(base64_decode(JRequest::getString('url'))); $id = json_decode(base64_decode(JRequest::getString('id'))); if ($data) { require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'HTTPFetcher.php'; require_once JPATH_COMPONENT_ADMINISTRATOR . DIRECTORY_SEPARATOR . 'libraries' . DIRECTORY_SEPARATOR . 'readfile.php'; $params = JComponentHelper::getParams('com_tz_portfolio'); $Itemid = JRequest::getInt('Itemid'); $menu = JMenu::getInstance('site'); $menuParams = $menu->getParams($Itemid); $params->merge($menuParams); $threadLink = null; $_id = null; if (is_array($data) && count($data)) { foreach ($data as $i => &$contentUrl) { if (!preg_match('/http\\:\\/\\//i', $contentUrl)) { $uri = JUri::getInstance(); $contentUrl = $uri->getScheme() . '://' . $uri->getHost() . $contentUrl; } if (preg_match('/(.*?)(\\?tmpl\\=component)|(\\&tmpl\\=component)/i', $contentUrl)) { $contentUrl = preg_replace('/(.*?)(\\?tmpl\\=component)|(\\&tmpl\\=component)/i', '$1', $contentUrl); } $_id[$contentUrl] = $id[$i]; if ($params->get('tz_comment_type', 'disqus') == 'facebook') { $threadLink .= '&urls[]=' . $contentUrl; } elseif ($params->get('tz_comment_type', 'disqus') == 'disqus') { $threadLink .= '&thread[]=link:' . $contentUrl; } } } if (!is_array($data)) { $threadLink = $data; } $fetch = new Services_Yadis_PlainHTTPFetcher(); $comments = null; if ($params->get('tz_show_count_comment', 1) == 1) { // From Facebook if ($params->get('tz_comment_type', 'disqus') == 'facebook') { if ($threadLink) { $url = 'http://api.facebook.com/restserver.php?method=links.getStats' . $threadLink; $content = $fetch->get($url); if ($content) { if ($bodies = $content->body) { if (preg_match_all('/\\<link_stat\\>(.*?)\\<\\/link_stat\\>/ims', $bodies, $matches)) { if (isset($matches[1]) && !empty($matches[1])) { foreach ($matches[1] as $val) { $match = null; if (preg_match('/\\<url\\>(.*?)\\<\\/url\\>.*?\\<comment_count\\>(.*?)\\<\\/comment_count\\>/msi', $val, $match)) { if (isset($match[1]) && isset($match[2])) { if (in_array($match[1], $data)) { $comments[$_id[$match[1]]] = $match[2]; } } } } } } } } } } // Disqus Comment count if ($params->get('tz_comment_type', 'disqus') == 'disqus') { $url = 'https://disqus.com/api/3.0/threads/list.json?api_secret=' . $params->get('disqusApiSecretKey', '4sLbLjSq7ZCYtlMkfsG7SS5muVp7DsGgwedJL5gRsfUuXIt6AX5h6Ae6PnNREMiB') . '&forum=' . $params->get('disqusSubDomain', 'templazatoturials') . $threadLink . '&include=open'; if ($_content = $fetch->get($url)) { $body = json_decode($_content->body); if (isset($body->response)) { if ($responses = $body->response) { foreach ($responses as $response) { if (in_array($response->link, $data)) { $comments[$_id[$response->link]] = $response->posts; } } } } } } if ($comments) { if (is_array($comments)) { return json_encode($comments); } return 0; } return 0; } } }