PageRenderTime 64ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/components/com_k2/models/item.php

https://bitbucket.org/colegatron/k2-calendar-w-subcategories
PHP | 1468 lines | 1200 code | 203 blank | 65 comment | 365 complexity | eff4db884801187bea7d85436cd8c884 MD5 | raw file

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * @version $Id: item.php 1577 2012-05-09 12:40:54Z lefteris.kavadas $
  4. * @package K2
  5. * @author JoomlaWorks http://www.joomlaworks.net
  6. * @copyright Copyright (c) 2006 - 2012 JoomlaWorks Ltd. All rights reserved.
  7. * @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
  8. */
  9. // no direct access
  10. defined('_JEXEC') or die('Restricted access');
  11. jimport('joomla.application.component.model');
  12. JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
  13. class K2ModelItem extends JModel
  14. {
  15. function getData()
  16. {
  17. $mainframe = &JFactory::getApplication();
  18. $id = JRequest::getInt('id');
  19. $db = &JFactory::getDBO();
  20. $query = "SELECT * FROM #__k2_items WHERE id={$id}";
  21. if (K2_JVERSION == '16')
  22. {
  23. $languageFilter = $mainframe->getLanguageFilter();
  24. if ($languageFilter)
  25. {
  26. $languageTag = JFactory::getLanguage()->getTag();
  27. $query .= " AND language IN (".$db->Quote($languageTag).",".$db->Quote('*').")";
  28. }
  29. }
  30. $db->setQuery($query, 0, 1);
  31. $row = $db->loadObject();
  32. return $row;
  33. }
  34. function prepareItem($item, $view, $task)
  35. {
  36. jimport('joomla.filesystem.file');
  37. JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
  38. $limitstart = JRequest::getInt('limitstart');
  39. //Initialize params
  40. if ($view != 'item')
  41. {
  42. $component = JComponentHelper::getComponent('com_k2');
  43. $params = new JParameter($component->params);
  44. $itemid = JRequest::getInt('Itemid');
  45. if ($itemid)
  46. {
  47. $menu = JSite::getMenu();
  48. $menuparams = $menu->getParams($itemid);
  49. $params->merge($menuparams);
  50. }
  51. }
  52. else
  53. {
  54. $params = &K2HelperUtilities::getParams('com_k2');
  55. }
  56. //Category
  57. $db = &JFactory::getDBO();
  58. $category = &JTable::getInstance('K2Category', 'Table');
  59. $category->load($item->catid);
  60. $item->category = $category;
  61. $item->category->link = urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($category->id.':'.urlencode($category->alias))));
  62. //Read more link
  63. $link = K2HelperRoute::getItemRoute($item->id.':'.urlencode($item->alias), $item->catid.':'.urlencode($item->category->alias));
  64. $item->link = urldecode(JRoute::_($link));
  65. //Print link
  66. $item->printLink = urldecode(JRoute::_($link.'&tmpl=component&print=1'));
  67. //Params
  68. $cparams = new JParameter($category->params);
  69. $iparams = new JParameter($item->params);
  70. $item->params = $params;
  71. if ($cparams->get('inheritFrom'))
  72. {
  73. $masterCategoryID = $cparams->get('inheritFrom');
  74. $masterCategory = &JTable::getInstance('K2Category', 'Table');
  75. $masterCategory->load((int)$masterCategoryID);
  76. $cparams = new JParameter($masterCategory->params);
  77. }
  78. $item->params->merge($cparams);
  79. $item->params->merge($iparams);
  80. //Edit link
  81. if (K2HelperPermissions::canEditItem($item->created_by, $item->catid))
  82. $item->editLink = JRoute::_('index.php?option=com_k2&view=item&task=edit&cid='.$item->id.'&tmpl=component');
  83. //Tags
  84. if (($view == 'item' && ($item->params->get('itemTags') || $item->params->get('itemRelated'))) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemTags')) || ($view == 'itemlist' && $task == 'user' && $item->params->get('userItemTags')) || ($view == 'latest' && $params->get('latestItemTags')))
  85. {
  86. $tags = K2ModelItem::getItemTags($item->id);
  87. for ($i = 0; $i < sizeof($tags); $i++)
  88. {
  89. $tags[$i]->link = JRoute::_(K2HelperRoute::getTagRoute($tags[$i]->name));
  90. }
  91. $item->tags = $tags;
  92. }
  93. //Image
  94. $item->imageXSmall = '';
  95. $item->imageSmall = '';
  96. $item->imageMedium = '';
  97. $item->imageLarge = '';
  98. $item->imageXLarge = '';
  99. $date = &JFactory::getDate($item->modified);
  100. $timestamp = '?t='.$date->toUnix();
  101. if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XS.jpg'))
  102. {
  103. $item->imageXSmall = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_XS.jpg';
  104. if ($params->get('imageTimestamp'))
  105. {
  106. $item->imageXSmall .= $timestamp;
  107. }
  108. }
  109. if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_S.jpg'))
  110. {
  111. $item->imageSmall = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_S.jpg';
  112. if ($params->get('imageTimestamp'))
  113. {
  114. $item->imageSmall .= $timestamp;
  115. }
  116. }
  117. if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_M.jpg'))
  118. {
  119. $item->imageMedium = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_M.jpg';
  120. if ($params->get('imageTimestamp'))
  121. {
  122. $item->imageMedium .= $timestamp;
  123. }
  124. }
  125. if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_L.jpg'))
  126. {
  127. $item->imageLarge = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_L.jpg';
  128. if ($params->get('imageTimestamp'))
  129. {
  130. $item->imageLarge .= $timestamp;
  131. }
  132. }
  133. if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_XL.jpg'))
  134. {
  135. $item->imageXLarge = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_XL.jpg';
  136. if ($params->get('imageTimestamp'))
  137. {
  138. $item->imageXLarge .= $timestamp;
  139. }
  140. }
  141. if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_Generic.jpg'))
  142. {
  143. $item->imageGeneric = JURI::base(true).'/media/k2/items/cache/'.md5("Image".$item->id).'_Generic.jpg';
  144. if ($params->get('imageTimestamp'))
  145. {
  146. $item->imageGeneric .= $timestamp;
  147. }
  148. }
  149. //Extra fields
  150. if (($view == 'item' && $item->params->get('itemExtraFields')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields')) || ($view == 'itemlist' && $task == 'tag' && $item->params->get('tagItemExtraFields')) || ($view == 'itemlist' && ($task == 'search' || $task == 'date') && $item->params->get('genericItemExtraFields')))
  151. {
  152. $item->extra_fields = K2ModelItem::getItemExtraFields($item->extra_fields);
  153. }
  154. //Attachments
  155. if (($view == 'item' && $item->params->get('itemAttachments')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemAttachments')))
  156. {
  157. $item->attachments = K2ModelItem::getItemAttachments($item->id);
  158. }
  159. //Rating
  160. if (($view == 'item' && $item->params->get('itemRating')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemRating')))
  161. {
  162. $item->votingPercentage = K2ModelItem::getVotesPercentage($item->id);
  163. $item->numOfvotes = K2ModelItem::getVotesNum($item->id);
  164. }
  165. //Filtering
  166. if ($params->get('introTextCleanup'))
  167. {
  168. $filterTags = preg_split('#[,\s]+#', trim($params->get('introTextCleanupExcludeTags')));
  169. $filterAttrs = preg_split('#[,\s]+#', trim($params->get('introTextCleanupTagAttr')));
  170. $filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
  171. $item->introtext = $filter->clean($item->introtext);
  172. }
  173. if ($params->get('fullTextCleanup'))
  174. {
  175. $filterTags = preg_split('#[,\s]+#', trim($params->get('fullTextCleanupExcludeTags')));
  176. $filterAttrs = preg_split('#[,\s]+#', trim($params->get('fullTextCleanupTagAttr')));
  177. $filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
  178. $item->fulltext = $filter->clean($item->fulltext);
  179. }
  180. if ($item->params->get('catItemIntroTextWordLimit') && $task == 'category')
  181. {
  182. $item->introtext = K2HelperUtilities::wordLimit($item->introtext, $item->params->get('catItemIntroTextWordLimit'));
  183. }
  184. $item->cleanTitle = $item->title;
  185. $item->title = htmlspecialchars($item->title, ENT_QUOTES);
  186. $item->image_caption = htmlspecialchars($item->image_caption, ENT_QUOTES);
  187. //Author
  188. if (($view == 'item' && ($item->params->get('itemAuthorBlock') || $item->params->get('itemAuthor'))) || ($view == 'itemlist' && ($task == '' || $task == 'category') && ($item->params->get('catItemAuthorBlock') || $item->params->get('catItemAuthor'))) || ($view == 'itemlist' && $task == 'user') || ($view == 'relatedByTag'))
  189. {
  190. if (!empty($item->created_by_alias))
  191. {
  192. $item->author->name = $item->created_by_alias;
  193. $item->author->avatar = K2HelperUtilities::getAvatar('alias');
  194. $item->author->link = JURI::root();
  195. }
  196. else
  197. {
  198. $author = &JFactory::getUser($item->created_by);
  199. $item->author = $author;
  200. $item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
  201. $item->author->profile = K2ModelItem::getUserProfile($item->created_by);
  202. $item->author->avatar = K2HelperUtilities::getAvatar($author->id, $author->email, $params->get('userImageWidth'));
  203. }
  204. if (!isset($item->author->profile) || is_null($item->author->profile))
  205. {
  206. $item->author->profile = new JObject;
  207. $item->author->profile->gender = NULL;
  208. }
  209. }
  210. //Num of comments
  211. $user = JFactory::getUser();
  212. if (!$user->guest && $user->id == $item->created_by && $params->get('inlineCommentsModeration'))
  213. {
  214. $item->numOfComments = K2ModelItem::countItemComments($item->id, false);
  215. }
  216. else
  217. {
  218. $item->numOfComments = K2ModelItem::countItemComments($item->id);
  219. }
  220. return $item;
  221. }
  222. function prepareFeedItem(&$item)
  223. {
  224. JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
  225. $params = &K2HelperUtilities::getParams('com_k2');
  226. $limitstart = 0;
  227. //Category
  228. $category = &JTable::getInstance('K2Category', 'Table');
  229. $category->load($item->catid);
  230. $item->category = $category;
  231. //Read more link
  232. $item->link = urldecode(JRoute::_(K2HelperRoute::getItemRoute($item->id.':'.$item->alias, $item->catid.':'.urlencode($item->category->alias))));
  233. //Filtering
  234. if ($params->get('introTextCleanup'))
  235. {
  236. $filterTags = preg_split('#[,\s]+#', trim($params->get('introTextCleanupExcludeTags')));
  237. $filterAttrs = preg_split('#[,\s]+#', trim($params->get('introTextCleanupTagAttr')));
  238. $filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
  239. $item->introtext = $filter->clean($item->introtext);
  240. }
  241. if ($params->get('fullTextCleanup'))
  242. {
  243. $filterTags = preg_split('#[,\s]+#', trim($params->get('fullTextCleanupExcludeTags')));
  244. $filterAttrs = preg_split('#[,\s]+#', trim($params->get('fullTextCleanupTagAttr')));
  245. $filter = new JFilterInput($filterTags, $filterAttrs, 0, 1);
  246. $item->fulltext = $filter->clean($item->fulltext);
  247. }
  248. //Description
  249. $item->description = '';
  250. //Item image
  251. if ($params->get('feedItemImage') && JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$item->id).'_'.$params->get('feedImgSize').'.jpg'))
  252. {
  253. $item->description .= '<div class="K2FeedImage"><img src="'.JURI::base(true).'/media/k2/items/cache/'.md5('Image'.$item->id).'_'.$params->get('feedImgSize').'.jpg" alt="'.$item->title.'" /></div>';
  254. }
  255. //Item Introtext
  256. if ($params->get('feedItemIntroText'))
  257. {
  258. //Introtext word limit
  259. if ($params->get('feedTextWordLimit') && $item->introtext)
  260. {
  261. $item->introtext = K2HelperUtilities::wordLimit($item->introtext, $params->get('feedTextWordLimit'));
  262. }
  263. $item->description .= '<div class="K2FeedIntroText">'.$item->introtext.'</div>';
  264. }
  265. //Item Fulltext
  266. if ($params->get('feedItemFullText') && $item->fulltext)
  267. {
  268. $item->description .= '<div class="K2FeedFullText">'.$item->fulltext.'</div>';
  269. }
  270. //Item Tags
  271. if ($params->get('feedItemTags'))
  272. {
  273. $tags = K2ModelItem::getItemTags($item->id);
  274. if (count($tags))
  275. {
  276. $item->description .= '<div class="K2FeedTags"><ul>';
  277. foreach ($tags as $tag)
  278. {
  279. $item->description .= '<li>'.$tag->name.'</li>';
  280. }
  281. $item->description .= '<ul></div>';
  282. }
  283. }
  284. //Item Video
  285. if ($params->get('feedItemVideo') && $item->video)
  286. {
  287. if (!empty($item->video) && JString::substr($item->video, 0, 1) !== '{')
  288. {
  289. $item->description .= '<div class="K2FeedVideo">'.$item->video.'</div>';
  290. }
  291. else
  292. {
  293. $params->set('vfolder', 'media/k2/videos');
  294. $params->set('afolder', 'media/k2/audio');
  295. if (JString::strpos($item->video, 'remote}'))
  296. {
  297. preg_match("#}(.*?){/#s", $item->video, $matches);
  298. if (!JString::strpos($matches[1], 'http://}'))
  299. $item->video = str_replace($matches[1], JURI::root().$matches[1], $item->video);
  300. }
  301. $dispatcher = &JDispatcher::getInstance();
  302. JPluginHelper::importPlugin('content');
  303. $item->text = $item->video;
  304. $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
  305. $item->description .= '<div class="K2FeedVideo">'.$item->text.'</div>';
  306. }
  307. }
  308. //Item gallery
  309. if ($params->get('feedItemGallery') && $item->gallery)
  310. {
  311. $params->set('galleries_rootfolder', 'media/k2/galleries');
  312. $params->set('enabledownload', '0');
  313. $dispatcher = &JDispatcher::getInstance();
  314. JPluginHelper::importPlugin('content');
  315. $item->text = $item->gallery;
  316. $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
  317. $item->description .= '<div class="K2FeedGallery">'.$item->text.'</div>';
  318. }
  319. //Item attachments
  320. if ($params->get('feedItemAttachments'))
  321. {
  322. $attachments = K2ModelItem::getItemAttachments($item->id);
  323. if (count($attachments))
  324. {
  325. $item->description .= '<div class="K2FeedAttachments"><ul>';
  326. foreach ($attachments as $attachment)
  327. {
  328. $item->description .= '<li><a title="'.htmlentities($attachment->titleAttribute, ENT_QUOTES, 'UTF-8').'" href="'.$attachment->link.'">'.$attachment->title.'</a></li>';
  329. }
  330. $item->description .= '<ul></div>';
  331. }
  332. }
  333. //Author
  334. if (!empty($item->created_by_alias))
  335. {
  336. $item->author->name = $item->created_by_alias;
  337. $item->author->email = '';
  338. }
  339. else
  340. {
  341. $author = &JFactory::getUser($item->created_by);
  342. $item->author = $author;
  343. $item->author->link = JRoute::_(K2HelperRoute::getUserRoute($item->created_by));
  344. $item->author->profile = K2ModelItem::getUserProfile($item->created_by);
  345. }
  346. return $item;
  347. }
  348. function prepareJSONItem($item)
  349. {
  350. $row = new JObject();
  351. unset($row->_errors);
  352. $row->id = $item->id;
  353. $row->title = $item->title;
  354. $row->alias = $item->alias;
  355. $row->link = $item->link;
  356. $row->catid = $item->catid;
  357. $row->introtext = $item->introtext;
  358. $row->fulltext = $item->fulltext;
  359. $row->extra_fields = $item->extra_fields;
  360. $row->created = $item->created;
  361. //$row->created_by = $item->created_by;
  362. $row->created_by_alias = $item->created_by_alias;
  363. $row->modified = $item->modified;
  364. //$row->modified_by = $item->modified_by;
  365. $row->featured = $item->featured;
  366. //$row->ordering = $item->ordering;
  367. //$row->featured_ordering = $item->featured_ordering;
  368. $row->image = isset($item->image) ? $item->image : '';
  369. $row->imageWidth = isset($item->imageWidth) ? $item->imageWidth : '';
  370. $row->image_caption = $item->image_caption;
  371. $row->image_credits = $item->image_credits;
  372. $row->imageXSmall = $item->imageXSmall;
  373. $row->imageSmall = $item->imageSmall;
  374. $row->imageMedium = $item->imageMedium;
  375. $row->imageLarge = $item->imageLarge;
  376. $row->imageXLarge = $item->imageXLarge;
  377. $row->video = $item->video;
  378. $row->video_caption = $item->video_caption;
  379. $row->video_credits = $item->video_credits;
  380. $row->gallery = $item->gallery;
  381. $row->hits = $item->hits;
  382. //$row->plugins = $item->plugins;
  383. $row->category->id = $item->category->id;
  384. $row->category->name = $item->category->name;
  385. $row->category->alias = $item->category->alias;
  386. $row->category->link = $item->category->link;
  387. $row->category->description = $item->category->description;
  388. $row->category->image = $item->category->image;
  389. $row->category->ordering = $item->category->ordering;
  390. //$row->category->plugins = $item->category->plugins;
  391. $row->tags = isset($item->tags) ? $item->tags : array();
  392. $row->attachments = isset($item->attachments) ? $item->attachments : array();
  393. $row->votingPercentage = isset($item->votingPercentage) ? $item->votingPercentage : '';
  394. $row->numOfvotes = isset($item->numOfvotes) ? $item->numOfvotes : '';
  395. if (isset($item->author))
  396. {
  397. //$row->author->id = $item->author->id;
  398. $row->author->name = $item->author->name;
  399. //$row->author->username = $item->author->username;
  400. $row->author->link = $item->author->link;
  401. $row->author->avatar = $item->author->avatar;
  402. if(isset($item->author->profile))
  403. {
  404. unset($item->author->profile->plugins);
  405. }
  406. $row->author->profile = $item->author->profile;
  407. }
  408. $row->numOfComments = $item->numOfComments;
  409. $row->events = $item->event;
  410. return $row;
  411. }
  412. function execPlugins($item, $view, $task)
  413. {
  414. $params = &K2HelperUtilities::getParams('com_k2');
  415. $limitstart = JRequest::getInt('limitstart');
  416. //Import plugins
  417. $dispatcher = &JDispatcher::getInstance();
  418. JPluginHelper::importPlugin('content');
  419. //Gallery
  420. if (($view == 'item' && $item->params->get('itemImageGallery')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemImageGallery')) || ($view == 'relatedByTag'))
  421. {
  422. if ($item->gallery)
  423. {
  424. if (JString::strpos($item->gallery, 'flickr.com') === false)
  425. {
  426. $item->gallery = "{gallery}{$item->id}{/gallery}";
  427. if (!JFolder::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'galleries'.DS.$item->id))
  428. {
  429. $item->gallery = null;
  430. }
  431. }
  432. $params->set('galleries_rootfolder', 'media/k2/galleries');
  433. $item->text = $item->gallery;
  434. $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
  435. $item->gallery = $item->text;
  436. }
  437. }
  438. //Video
  439. if (($view == 'item' && $item->params->get('itemVideo')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemVideo')) || ($view == 'latest' && $item->params->get('latestItemVideo')) || ($view == 'relatedByTag'))
  440. {
  441. if (!empty($item->video) && JString::substr($item->video, 0, 1) !== '{')
  442. {
  443. $item->video = $item->video;
  444. $item->videoType = 'embedded';
  445. }
  446. else
  447. {
  448. $item->videoType = 'allvideos';
  449. $params->set('afolder', 'media/k2/audio');
  450. $params->set('vfolder', 'media/k2/videos');
  451. if (JString::strpos($item->video, 'remote}'))
  452. {
  453. preg_match("#}(.*?){/#s", $item->video, $matches);
  454. if (JString::substr($matches[1], 0, 7) != 'http://')
  455. $item->video = str_replace($matches[1], JURI::root().$matches[1], $item->video);
  456. }
  457. if ($view == 'item')
  458. {
  459. $params->set('vwidth', $item->params->get('itemVideoWidth'));
  460. $params->set('vheight', $item->params->get('itemVideoHeight'));
  461. $params->set('autoplay', $item->params->get('itemVideoAutoPlay'));
  462. }
  463. else if ($view == 'latest')
  464. {
  465. $params->set('vwidth', $item->params->get('latestItemVideoWidth'));
  466. $params->set('vheight', $item->params->get('latestItemVideoHeight'));
  467. $params->set('autoplay', $item->params->get('latestItemVideoAutoPlay'));
  468. }
  469. else
  470. {
  471. $params->set('vwidth', $item->params->get('catItemVideoWidth'));
  472. $params->set('vheight', $item->params->get('catItemVideoHeight'));
  473. $params->set('autoplay', $item->params->get('catItemVideoAutoPlay'));
  474. }
  475. $item->text = $item->video;
  476. $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
  477. $item->video = $item->text;
  478. }
  479. }
  480. //Plugins
  481. $item->text = '';
  482. $params->set('vfolder', NULL);
  483. $params->set('afolder', NULL);
  484. $params->set('vwidth', NULL);
  485. $params->set('vheight', NULL);
  486. $params->set('autoplay', NULL);
  487. $params->set('galleries_rootfolder', NULL);
  488. $params->set('enabledownload', NULL);
  489. if ($view == 'item')
  490. {
  491. if ($item->params->get('itemIntroText'))
  492. $item->text .= $item->introtext;
  493. if ($item->params->get('itemFullText'))
  494. $item->text .= '{K2Splitter}'.$item->fulltext;
  495. }
  496. else
  497. {
  498. switch($task)
  499. {
  500. case '' :
  501. case 'category' :
  502. if ($item->params->get('catItemIntroText'))
  503. $item->text .= $item->introtext;
  504. break;
  505. case 'user' :
  506. if ($item->params->get('userItemIntroText'))
  507. $item->text .= $item->introtext;
  508. break;
  509. case 'tag' :
  510. if ($item->params->get('tagItemIntroText'))
  511. $item->text .= $item->introtext;
  512. break;
  513. default :
  514. if ($item->params->get('genericItemIntroText'))
  515. $item->text .= $item->introtext;
  516. break;
  517. }
  518. }
  519. if (K2_JVERSION == '16')
  520. {
  521. $item->event->BeforeDisplay = '';
  522. $item->event->AfterDisplay = '';
  523. $dispatcher->trigger('onContentPrepare', array('com_k2.'.$view, &$item, &$params, $limitstart));
  524. $results = $dispatcher->trigger('onContentAfterTitle', array('com_k2.'.$view, &$item, &$params, $limitstart));
  525. $item->event->AfterDisplayTitle = trim(implode("\n", $results));
  526. $results = $dispatcher->trigger('onContentBeforeDisplay', array('com_k2.'.$view, &$item, &$params, $limitstart));
  527. $item->event->BeforeDisplayContent = trim(implode("\n", $results));
  528. $results = $dispatcher->trigger('onContentAfterDisplay', array('com_k2.'.$view, &$item, &$params, $limitstart));
  529. $item->event->AfterDisplayContent = trim(implode("\n", $results));
  530. }
  531. else
  532. {
  533. $results = $dispatcher->trigger('onBeforeDisplay', array(&$item, &$params, $limitstart));
  534. $item->event->BeforeDisplay = trim(implode("\n", $results));
  535. $results = $dispatcher->trigger('onAfterDisplay', array(&$item, &$params, $limitstart));
  536. $item->event->AfterDisplay = trim(implode("\n", $results));
  537. $results = $dispatcher->trigger('onAfterDisplayTitle', array(&$item, &$params, $limitstart));
  538. $item->event->AfterDisplayTitle = trim(implode("\n", $results));
  539. $results = $dispatcher->trigger('onBeforeDisplayContent', array(&$item, &$params, $limitstart));
  540. $item->event->BeforeDisplayContent = trim(implode("\n", $results));
  541. $results = $dispatcher->trigger('onAfterDisplayContent', array(&$item, &$params, $limitstart));
  542. $item->event->AfterDisplayContent = trim(implode("\n", $results));
  543. $dispatcher->trigger('onPrepareContent', array(&$item, &$params, $limitstart));
  544. }
  545. //K2 plugins
  546. $item->event->K2BeforeDisplay = '';
  547. $item->event->K2AfterDisplay = '';
  548. $item->event->K2AfterDisplayTitle = '';
  549. $item->event->K2BeforeDisplayContent = '';
  550. $item->event->K2AfterDisplayContent = '';
  551. if (($view == 'item' && $item->params->get('itemK2Plugins')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemK2Plugins')) || ($view == 'itemlist' && $task == 'user' && $item->params->get('userItemK2Plugins')))
  552. {
  553. JPluginHelper::importPlugin('k2');
  554. $results = $dispatcher->trigger('onK2BeforeDisplay', array(&$item, &$params, $limitstart));
  555. $item->event->K2BeforeDisplay = trim(implode("\n", $results));
  556. $results = $dispatcher->trigger('onK2AfterDisplay', array(&$item, &$params, $limitstart));
  557. $item->event->K2AfterDisplay = trim(implode("\n", $results));
  558. $results = $dispatcher->trigger('onK2AfterDisplayTitle', array(&$item, &$params, $limitstart));
  559. $item->event->K2AfterDisplayTitle = trim(implode("\n", $results));
  560. $results = $dispatcher->trigger('onK2BeforeDisplayContent', array(&$item, &$params, $limitstart));
  561. $item->event->K2BeforeDisplayContent = trim(implode("\n", $results));
  562. $results = $dispatcher->trigger('onK2AfterDisplayContent', array(&$item, &$params, $limitstart));
  563. $item->event->K2AfterDisplayContent = trim(implode("\n", $results));
  564. $dispatcher->trigger('onK2PrepareContent', array(&$item, &$params, $limitstart));
  565. }
  566. if ($view == 'item')
  567. {
  568. @list($item->introtext, $item->fulltext) = explode('{K2Splitter}', $item->text);
  569. }
  570. else
  571. {
  572. $item->introtext = $item->text;
  573. }
  574. // Extra fields plugins
  575. if (($view == 'item' && $item->params->get('itemExtraFields')) || ($view == 'itemlist' && ($task == '' || $task == 'category') && $item->params->get('catItemExtraFields')))
  576. {
  577. if (count($item->extra_fields))
  578. {
  579. foreach ($item->extra_fields as $key => $extraField)
  580. {
  581. if ($extraField->type == 'textarea' || $extraField->type == 'textfield')
  582. {
  583. $tmp = new JObject();
  584. $tmp->text = $extraField->value;
  585. if (K2_JVERSION == '16')
  586. {
  587. $dispatcher->trigger('onContentPrepare', array('com_k2.'.$view, &$tmp, &$params, $limitstart));
  588. }
  589. else
  590. {
  591. $dispatcher->trigger('onPrepareContent', array(&$tmp, &$params, $limitstart));
  592. }
  593. $dispatcher->trigger('onK2PrepareContent', array(&$tmp, &$params, $limitstart));
  594. $extraField->value = $tmp->text;
  595. }
  596. }
  597. }
  598. }
  599. return $item;
  600. }
  601. function hit($id)
  602. {
  603. $row = &JTable::getInstance('K2Item', 'Table');
  604. $row->hit($id);
  605. }
  606. function vote()
  607. {
  608. $mainframe = &JFactory::getApplication();
  609. JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
  610. //Get item
  611. $item = &JTable::getInstance('K2Item', 'Table');
  612. $item->load(JRequest::getInt('itemID'));
  613. //Get category
  614. $category = &JTable::getInstance('K2Category', 'Table');
  615. $category->load($item->catid);
  616. //Access check
  617. $user = JFactory::getUser();
  618. if (K2_JVERSION == '16')
  619. {
  620. if (!in_array($item->access, $user->authorisedLevels()) || !in_array($category->access, $user->authorisedLevels()))
  621. {
  622. JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
  623. }
  624. }
  625. else
  626. {
  627. if ($item->access > $user->get('aid', 0) || $category->access > $user->get('aid', 0))
  628. {
  629. JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
  630. }
  631. }
  632. //Published check
  633. if (!$item->published || $item->trash)
  634. {
  635. JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
  636. }
  637. if (!$category->published || $category->trash)
  638. {
  639. JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
  640. }
  641. $rate = JRequest::getVar('user_rating', 0, '', 'int');
  642. if ($rate >= 1 && $rate <= 5)
  643. {
  644. $db = &JFactory::getDBO();
  645. $userIP = $_SERVER['REMOTE_ADDR'];
  646. $query = "SELECT * FROM #__k2_rating WHERE itemID =".(int)$item->id;
  647. $db->setQuery($query);
  648. $rating = $db->loadObject();
  649. if (!$rating)
  650. {
  651. $query = "INSERT INTO #__k2_rating ( itemID, lastip, rating_sum, rating_count ) VALUES ( ".(int)$item->id.", ".$db->Quote($userIP).", {$rate}, 1 )";
  652. $db->setQuery($query);
  653. $db->query();
  654. echo JText::_('K2_THANKS_FOR_RATING');
  655. }
  656. else
  657. {
  658. if ($userIP != ($rating->lastip))
  659. {
  660. $query = "UPDATE #__k2_rating"." SET rating_count = rating_count + 1, rating_sum = rating_sum + {$rate}, lastip = ".$db->Quote($userIP)." WHERE itemID = {$item->id}";
  661. $db->setQuery($query);
  662. $db->query();
  663. echo JText::_('K2_THANKS_FOR_RATING');
  664. }
  665. else
  666. {
  667. echo JText::_('K2_YOU_HAVE_ALREADY_RATED_THIS_ITEM');
  668. }
  669. }
  670. }
  671. $mainframe->close();
  672. }
  673. function getRating($id)
  674. {
  675. $id = (int)$id;
  676. static $K2RatingsInstances = array();
  677. if (array_key_exists($id, $K2RatingsInstances))
  678. {
  679. return $K2RatingsInstances[$id];
  680. }
  681. $db = &JFactory::getDBO();
  682. $query = "SELECT * FROM #__k2_rating WHERE itemID = ".$id;
  683. $db->setQuery($query);
  684. $vote = $db->loadObject();
  685. $K2RatingsInstances[$id] = $vote;
  686. return $K2RatingsInstances[$id];
  687. }
  688. function getVotesNum($itemID = NULL)
  689. {
  690. $mainframe = &JFactory::getApplication();
  691. $user = JFactory::getUser();
  692. $xhr = false;
  693. if (is_null($itemID))
  694. {
  695. $itemID = JRequest::getInt('itemID');
  696. $xhr = true;
  697. }
  698. $vote = K2ModelItem::getRating($itemID);
  699. if (!is_null($vote))
  700. $rating_count = intval($vote->rating_count);
  701. else
  702. $rating_count = 0;
  703. if ($rating_count != 1)
  704. {
  705. $result = "(".$rating_count." ".JText::_('K2_VOTES').")";
  706. }
  707. else
  708. {
  709. $result = "(".$rating_count." ".JText::_('K2_VOTE').")";
  710. }
  711. if ($xhr)
  712. {
  713. echo $result;
  714. $mainframe->close();
  715. }
  716. else
  717. return $result;
  718. }
  719. function getVotesPercentage($itemID = NULL)
  720. {
  721. $mainframe = &JFactory::getApplication();
  722. $user = JFactory::getUser();
  723. $db = &JFactory::getDBO();
  724. $xhr = false;
  725. $result = 0;
  726. if (is_null($itemID))
  727. {
  728. $itemID = JRequest::getInt('itemID');
  729. $xhr = true;
  730. }
  731. $vote = K2ModelItem::getRating($itemID);
  732. if (!is_null($vote) && $vote->rating_count != 0)
  733. {
  734. $result = number_format(intval($vote->rating_sum) / intval($vote->rating_count), 2) * 20;
  735. }
  736. if ($xhr)
  737. {
  738. echo $result;
  739. $mainframe->close();
  740. }
  741. else
  742. return $result;
  743. }
  744. function comment()
  745. {
  746. $mainframe = &JFactory::getApplication();
  747. jimport('joomla.mail.helper');
  748. JTable::addIncludePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables');
  749. $params = &K2HelperUtilities::getParams('com_k2');
  750. $user = JFactory::getUser();
  751. $config = &JFactory::getConfig();
  752. JLoader::register('Services_JSON', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'JSON.php');
  753. $json = new Services_JSON;
  754. $response = new JObject();
  755. //Get item
  756. $item = &JTable::getInstance('K2Item', 'Table');
  757. $item->load(JRequest::getInt('itemID'));
  758. //Get category
  759. $category = &JTable::getInstance('K2Category', 'Table');
  760. $category->load($item->catid);
  761. //Access check
  762. if (K2_JVERSION == '16')
  763. {
  764. if (!in_array($item->access, $user->authorisedLevels()) || !in_array($category->access, $user->authorisedLevels()))
  765. {
  766. JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
  767. }
  768. }
  769. else
  770. {
  771. if ($item->access > $user->get('aid', 0) || $category->access > $user->get('aid', 0))
  772. {
  773. JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
  774. }
  775. }
  776. //Published check
  777. if (!$item->published || $item->trash)
  778. {
  779. JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
  780. }
  781. if (!$category->published || $category->trash)
  782. {
  783. JError::raiseError(404, JText::_('K2_ITEM_NOT_FOUND'));
  784. }
  785. //Check permissions
  786. if ((($params->get('comments') == '2') && ($user->id > 0) && K2HelperPermissions::canAddComment($item->catid)) || ($params->get('comments') == '1'))
  787. {
  788. $row = &JTable::getInstance('K2Comment', 'Table');
  789. if (!$row->bind(JRequest::get('post')))
  790. {
  791. $response->message($row->getError());
  792. echo $json->encode($response);
  793. $mainframe->close();
  794. }
  795. $row->commentText = JRequest::getString('commentText', '', 'default');
  796. $row->commentText = strip_tags($row->commentText);
  797. //Strip a tags since all urls will be converted to links automatically on runtime.
  798. //Additionaly strip tables to avoid layout issues.
  799. //Also strip all attributes except src, alt and title.
  800. //$filter = new JFilterInput(array('a', 'table'), array('src', 'alt', 'title'), 1);
  801. //$row->commentText = $filter->clean( $row->commentText );
  802. //Clean vars
  803. $filter = &JFilterInput::getInstance();
  804. $row->userName = $filter->clean($row->userName, 'username');
  805. if ($row->commentURL && preg_match('/^((http|https|ftp):\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,6}((:[0-9]{1,5})?\/.*)?$/i', $row->commentURL))
  806. {
  807. $url = preg_replace('|[^a-z0-9-~+_.?#=&;,/:]|i', '', $row->commentURL);
  808. $url = str_replace(';//', '://', $url);
  809. if ($url != '')
  810. {
  811. $url = (!strstr($url, '://')) ? 'http://'.$url : $url;
  812. $url = preg_replace('/&([^#])(?![a-z]{2,8};)/', '&#038;$1', $url);
  813. $row->commentURL = $url;
  814. }
  815. }
  816. else
  817. {
  818. $row->commentURL = '';
  819. }
  820. $datenow = &JFactory::getDate();
  821. $row->commentDate = $datenow->toMySQL();
  822. if (!$user->guest)
  823. {
  824. $row->userID = $user->id;
  825. $row->commentEmail = $user->email;
  826. $row->userName = $user->name;
  827. }
  828. $userName = trim($row->userName);
  829. $commentEmail = trim($row->commentEmail);
  830. $commentText = trim($row->commentText);
  831. $commentURL = trim($row->commentURL);
  832. if (empty($userName) || $userName == JText::_('K2_ENTER_YOUR_NAME') || empty($commentText) || $commentText == JText::_('K2_ENTER_YOUR_MESSAGE_HERE') || empty($commentEmail) || $commentEmail == JText::_('K2_ENTER_YOUR_EMAIL_ADDRESS'))
  833. {
  834. $response->message = JText::_('K2_YOU_NEED_TO_FILL_IN_ALL_REQUIRED_FIELDS', true);
  835. echo $json->encode($response);
  836. $mainframe->close();
  837. }
  838. if (!JMailHelper::isEmailAddress($commentEmail))
  839. {
  840. $response->message = JText::_('K2_INVALID_EMAIL_ADDRESS', true);
  841. echo $json->encode($response);
  842. $mainframe->close();
  843. }
  844. if ($user->guest)
  845. {
  846. $db = &JFactory::getDBO();
  847. $query = "SELECT COUNT(*) FROM #__users WHERE name=".$db->Quote($userName)." OR email=".$db->Quote($commentEmail);
  848. $db->setQuery($query);
  849. $result = $db->loadresult();
  850. if ($result > 0)
  851. {
  852. $response->message = JText::_('K2_THE_NAME_OR_EMAIL_ADDRESS_YOU_TYPED_IS_ALREADY_IN_USE', true);
  853. echo $json->encode($response);
  854. $mainframe->close();
  855. }
  856. }
  857. if ($params->get('recaptcha') && $user->guest)
  858. {
  859. require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'recaptchalib.php');
  860. $privatekey = $params->get('recaptcha_private_key');
  861. $recaptcha_challenge_field = isset($_POST["recaptcha_challenge_field"]) ? $_POST["recaptcha_challenge_field"] : '';
  862. $recaptcha_response_field = isset($_POST["recaptcha_response_field"]) ? $_POST["recaptcha_response_field"] : '';
  863. $resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $recaptcha_challenge_field, $recaptcha_response_field);
  864. if (!$resp->is_valid)
  865. {
  866. $response->message = JText::_('K2_THE_WORDS_YOU_TYPED_DID_NOT_MATCH_THE_ONES_DISPLAYED_PLEASE_TRY_AGAIN', true);
  867. echo $json->encode($response);
  868. $mainframe->close();
  869. }
  870. }
  871. if ($commentURL == JText::_('K2_ENTER_YOUR_SITE_URL') || $commentURL == "")
  872. {
  873. $row->commentURL = NULL;
  874. }
  875. else
  876. {
  877. if (substr($commentURL, 0, 7) != 'http://')
  878. {
  879. $row->commentURL = 'http://'.$commentURL;
  880. }
  881. }
  882. if ($params->get('commentsPublishing'))
  883. {
  884. $row->published = 1;
  885. }
  886. else
  887. {
  888. $row->published = 0;
  889. // Auto publish comments for users with administrative permissions
  890. if (K2_JVERSION == '16')
  891. {
  892. if ($user->authorise('core.admin'))
  893. {
  894. $row->published = 1;
  895. }
  896. }
  897. else
  898. {
  899. if ($user->gid > 23)
  900. {
  901. $row->published = 1;
  902. }
  903. }
  904. }
  905. if (!$row->store())
  906. {
  907. $response->message = $row->getError();
  908. echo $json->encode($response);
  909. $mainframe->close();
  910. }
  911. if ($row->published)
  912. {
  913. if ($config->getValue('config.caching') && $user->guest)
  914. {
  915. $response->message = JText::_('K2_THANK_YOU_YOUR_COMMENT_WILL_BE_PUBLISHED_SHORTLY', true);
  916. echo $json->encode($response);
  917. }
  918. else
  919. {
  920. $response->message = JText::_('K2_COMMENT_ADDED_REFRESHING_PAGE', true);
  921. $response->refresh = 1;
  922. echo $json->encode($response);
  923. }
  924. }
  925. else
  926. {
  927. $response->message = JText::_('K2_COMMENT_ADDED_AND_WAITING_FOR_APPROVAL', true);
  928. echo $json->encode($response);
  929. }
  930. }
  931. $mainframe->close();
  932. }
  933. function getItemTags($itemID)
  934. {
  935. $itemID = (int)$itemID;
  936. static $K2ItemTagsInstances = array();
  937. if (isset($K2ItemTagsInstances[$itemID]))
  938. {
  939. return $K2ItemTagsInstances[$itemID];
  940. }
  941. $db = &JFactory::getDBO();
  942. $query = "SELECT tag.*
  943. FROM #__k2_tags AS tag
  944. JOIN #__k2_tags_xref AS xref ON tag.id = xref.tagID
  945. WHERE tag.published=1
  946. AND xref.itemID = ".(int)$itemID." ORDER BY xref.id ASC";
  947. $db->setQuery($query);
  948. $rows = $db->loadObjectList();
  949. $K2ItemTagsInstances[$itemID] = $rows;
  950. return $K2ItemTagsInstances[$itemID];
  951. }
  952. function getItemExtraFields($itemExtraFields)
  953. {
  954. static $K2ItemExtraFieldsInstances = array();
  955. if (isset($K2ItemExtraFieldsInstances[$itemExtraFields]))
  956. {
  957. return $K2ItemExtraFieldsInstances[$itemExtraFields];
  958. }
  959. jimport('joomla.filesystem.file');
  960. $db = &JFactory::getDBO();
  961. require_once (JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'JSON.php');
  962. $json = new Services_JSON;
  963. $jsonObjects = $json->decode($itemExtraFields);
  964. $imgExtensions = array('jpg', 'jpeg', 'gif', 'png');
  965. $params = &K2HelperUtilities::getParams('com_k2');
  966. if (count($jsonObjects) < 1)
  967. {
  968. return NULL;
  969. }
  970. foreach ($jsonObjects as $object)
  971. {
  972. $extraFieldsIDs[] = $object->id;
  973. }
  974. JArrayHelper::toInteger($extraFieldsIDs);
  975. $condition = @implode(',', $extraFieldsIDs);
  976. $query = "SELECT * FROM #__k2_extra_fields WHERE published=1 AND id IN ({$condition}) ORDER BY ordering ASC";
  977. $db->setQuery($query);
  978. $rows = $db->loadObjectList();
  979. $size = count($rows);
  980. for ($i = 0; $i < $size; $i++)
  981. {
  982. $value = '';
  983. $values = array();
  984. foreach ($jsonObjects as $object)
  985. {
  986. if ($rows[$i]->id == $object->id)
  987. {
  988. if ($rows[$i]->type == 'textfield' || $rows[$i]->type == 'textarea' || $rows[$i]->type == 'date')
  989. {
  990. $value = $object->value;
  991. if ($rows[$i]->type == 'date' && $value)
  992. {
  993. $offset = (K2_JVERSION == '16') ? null : 0;
  994. $value = JHTML::_('date', $value, JText::_('K2_DATE_FORMAT_LC'), $offset);
  995. }
  996. }
  997. else if ($rows[$i]->type == 'labels')
  998. {
  999. $labels = explode(',', $object->value);
  1000. if (!is_array($labels))
  1001. {
  1002. $labels = (array)$labels;
  1003. }
  1004. $value = '';
  1005. foreach ($labels as $label)
  1006. {
  1007. $label = JString::trim($label);
  1008. $label = str_replace('-', ' ', $label);
  1009. $value .= '<a href="'.JRoute::_('index.php?option=com_k2&view=itemlist&task=search&searchword='.urlencode($label)).'">'.$label.'</a> ';
  1010. }
  1011. }
  1012. else if ($rows[$i]->type == 'select' || $rows[$i]->type == 'radio')
  1013. {
  1014. foreach ($json->decode($rows[$i]->value) as $option)
  1015. {
  1016. if ($option->value == $object->value)
  1017. {
  1018. $value .= $option->name;
  1019. }
  1020. }
  1021. }
  1022. else if ($rows[$i]->type == 'multipleSelect')
  1023. {
  1024. foreach ($json->decode($rows[$i]->value) as $option)
  1025. {
  1026. if (@in_array($option->value, $object->value))
  1027. {
  1028. $values[] = $option->name;
  1029. }
  1030. }
  1031. $value = @implode(', ', $values);
  1032. }
  1033. else if ($rows[$i]->type == 'csv')
  1034. {
  1035. $array = $object->value;
  1036. if (count($array))
  1037. {
  1038. $value .= '<table cellspacing="0" cellpadding="0" class="csvTable">';
  1039. foreach ($array as $key => $row)
  1040. {
  1041. $value .= '<tr>';
  1042. foreach ($row as $cell)
  1043. {
  1044. $value .= ($key > 0) ? '<td>'.$cell.'</td>' : '<th>'.$cell.'</th>';
  1045. }
  1046. $value .= '</tr>';
  1047. }
  1048. $value .= '</table>';
  1049. }
  1050. }
  1051. else
  1052. {
  1053. switch ($object->value[2])
  1054. {
  1055. case 'same' :
  1056. default :
  1057. $attributes = '';
  1058. break;
  1059. case 'new' :
  1060. $attributes = 'target="_blank"';
  1061. break;
  1062. case 'popup' :
  1063. $attributes = 'class="classicPopup" rel="{\'x\':'.$params->get('linkPopupWidth').',\'y\':'.$params->get('linkPopupHeight').'}"';
  1064. break;
  1065. case 'lightbox' :
  1066. $filename = @basename($object->value[1]);
  1067. $extension = JFile::getExt($filename);
  1068. if (!empty($extension) && in_array($extension, $imgExtensions))
  1069. {
  1070. $attributes = 'class="modal"';
  1071. }
  1072. else
  1073. {
  1074. $attributes = 'class="modal" rel="{handler:\'iframe\',size:{x:'.$params->get('linkPopupWidth').',y:'.$params->get('linkPopupHeight').'}}"';
  1075. }
  1076. break;
  1077. }
  1078. $object->value[0] = JString::trim($object->value[0]);
  1079. $object->value[1] = JString::trim($object->value[1]);
  1080. if ($object->value[1] && ($object->value[1] != 'http://' || $object->value[1] != 'https://'))
  1081. {
  1082. if ($object->value[0] == '')
  1083. {
  1084. $object->value[0] = $object->value[1];
  1085. }
  1086. $value = '<a href="'.$object->value[1].'" '.$attributes.'>'.$object->value[0].'</a>';
  1087. }
  1088. else
  1089. {
  1090. $value = false;
  1091. }
  1092. }
  1093. }
  1094. }
  1095. if ($value)
  1096. {
  1097. $rows[$i]->value = $value;
  1098. }
  1099. else
  1100. {
  1101. unset($rows[$i])

Large files files are truncated, but you can click here to view the full file