Keyword

Advanced Search

Search Results (Searched for: How do I check K2 version)

  • Tristan
  • Tristan's Avatar
05 Jun 2014 08:23

Extra Fields Default Value not working

Category: English K2 Community

Hello all. I've got a small problem with K2 that I'm hoping someone can help with.

I'm using K2 version 2.6.8 on Joomla 3.3.0. What I'm trying to do is put an Extra Field in for images - specifically for film cover art images. I've set everything up and it's working fine except for one issue. I've set the "Default Value" to a placeholder image that says "No Cover Available", but when I add a new article and check the Extra Fields tab, the box is empty. Then if I save the article and load the page, there's no placeholder and the area is blank. However, if I set the image manually in the article editor, it does work.

Is there something I need to do to get the default value working for Extra Field images?

Thanks.
  • Daniel J. Eller
  • Daniel J. Eller's Avatar
03 Jun 2014 16:36
Replied by Daniel J. Eller on topic I am getting hacked continuoulsy from the K2 addon

I am getting hacked continuoulsy from the K2 addon

Category: English K2 Community

coolrushband.net/index.php/component/k2/item/11-cool-rush-at-the-downtown-cafe-in-el-cajon-on-april-11th/11-cool-rush-at-the-downtown-cafe-in-el-cajon-on-april-11th?limitstart=0&post=00061

I am getting the above visitors to my site from K2 items specifically that are driving the CPU usage of the server way up. I am getting hundreds a day. My other sites are not getting this and for every IP address I block, another one comes up from various other countries, mostly Japan and China.

How can I get these items they are going to, that have supposedly been deleted, gone? Are these items "stored" somewhere else in the config files or something. My web server calls them "hacks". Below is a partial email I have received from them:


Hi Dan,

You’ve had an enormous amount of hack attempts today. We noticed that your CPU had gone crazy this morning and wondered why since there’s an email alert the server staff and I get that a user may be sending spam, being spammed, hack attempts, etc. As it turns out there’s obviously no spam being sent but your website is being spammed from various points in the U.S., China, Germany and other areas several times an hour for evidently no reason. I checked into the bug and it was evident in older versions of Joomla for awhile then supposedly fixed. This must be a new one. It’s directly related to a security breach in your configuration with commands taken from this plugin and others:

coolrushband.net/index.php/component/k2/item/11-cool-rush-at-the-downtown-cafe-in-el-cajon-on-april-11th/11-cool-rush-at-the-downtown-cafe-in-el-cajon-on-april-11th?limitstart=0&con=195

There are several more. We may have to block various IP’s not only making attempts to enter your web folders for reasons unknown since there doesn’t appear to be any shopping carts or anything that would store credit card numbers, but also for your own protection of anything on the website that may be valuable to a hacker. Your domain, coolrushband.net username:coolrsh2 is the only account being targeted. Several website forums state that sometimes there are disgruntled employees or someone trying to highjack a website for some reason and then they give or sell your Joomla security breaches to hundreds of users who then access your files using one of the Joomla plugins mentioned. I can send you others if you want so that you can get rid of these pages that are letting the hackers in.

The opening index.php is not the culprit but various Joomla plugins it connects to that have the security bug are letting these hackers in by the dozens. They are not visitors since visitors don’t normally login over and over again with hack attempts to your files and folders. They are most likely using a hacking software of some kind since the usernames and passwords they’re trying to gain entrance to your website with come within only a few seconds of each other and nobody can type that fast.
  • จจจจจอออออห์นนนนนน
  • จจจจจอออออห์นนนนนน's Avatar
21 May 2014 13:08 - 21 May 2014 20:52
[Problem] K2 Item Images Not Show and Disappear was created by จจจจจอออออห์นนนนนน

[Problem] K2 Item Images Not Show and Disappear

Category: English K2 Community

* sorry for my English :(


Joomla version 2.5.8
Template : green_machine (Default)
K2 Version 2.5.7


I'm having a problem assigning images at the K2 Item.

Today I added new item in K2 and I notice at image at K2 items in old item I've added is disappear.
All of item I've added not show in website and administrator site.

Example.
New item I added today (image is show) Click

Old item I've added image is disappear. Click

But when I re-check in FTP all image in K2 item are stored in two folders :
/media/k2/items/cache (all generated sizes)
/media/k2/items/src (original image)

And I trying to add new image in K2 item (replaced old image is disappear) it can show normally.

Please advise me on :
How I can do anything to bring image in K2 item back to show again.
Without re-upload all image in K2 item again. :( (more 750++ pics :sick: )

Or advise me for this problem pls.
  • Lefteris
  • Lefteris's Avatar
16 May 2014 18:46
Replied by Lefteris on topic Creating new article does not show category

Creating new article does not show category

Category: English K2 Community

Of course, the category is is available in the category.php layout. The variable that holds the id is:
<?php $this->category->id; ?>
Regarding your second question, the browser is refreshing the page when you close the modal. If the item is published you should see it. If it does not refresh at all then check that:
1. You are using the latest version of K2.
2. Check the browser console for javascript errors.
  • Jany Enseñat
  • Jany Enseñat's Avatar
07 May 2014 17:39
K2 does not resize the images was created by Jany Enseñat

K2 does not resize the images

Category: English K2 Community

Hello everyone !

I use the K2 version 2.6.8, and I've updated my Joomla´s version to 2.5.19, after the update I thought everything was fine until the module Mini K2 Content that I use to display the news on my front side , has begun to show super large images. I have checked the ftp and K2 continues generating all its pictures XS , S , M , L , XL and Generic but I 've noticed that not resize it, all pictures have the same size . What can be happening? The configuration is well, has well-defined size I want for the images , however does not keep them as such.

PS: There is something weird,I have the same local site and everything works perfect , but the site online that not work in the same way.

Strongly need a help ..... thanks in advance ! !
  • Tue
  • Tue's Avatar
06 May 2014 20:36 - 06 May 2014 20:36

Automatically set first item image to k2 image

Category: English K2 Community

Thanks Lefteris.
I have installed but seem that the plugin is not working with either my template or the latest version of K2??
All settings in the plugin are left blank by default.
I have also tried to remove all items in K2 and redo the "Import from Joomla".
My template is Gavick Pro News 2 (april 2014)

Are there any other setting or setup that I have missed?

Check this link. evergreen.vn/index.php?option=com_k2&view=itemlist&layout=category&task=category&id=68&Itemid=1044
The 2 images shown are added manually by me.
  • Lefteris
  • Lefteris's Avatar
30 Apr 2014 12:29

tamplate System check shows potential issues in k2

Category: English K2 Community

Hi. I don't know where you got this message but K2 is not loading multiple jQuery instances. It has a setting for choosing which jQuery version you want to load. But the files should be there to allow you to choose a different version. You can always see what is loaded on your page using your browser's developer tools.
  • kiemthu123
  • kiemthu123's Avatar
07 Apr 2014 17:51
Replied by kiemthu123 on topic Show featured items only in menu page

Show featured items only in menu page

Category: English K2 Community

Actually I recheck everything and it does not work, I hope next version of K2 will fix this problem.

I found another solution by modifying the 'latest' view and the itemlist view in this topic getk2.org/community/English-K2-Community/152649-How-Fix---Introtext---Word-limit-for-multiple-categories#152652
  • matt
  • matt's Avatar
24 Mar 2014 17:43 - 24 Mar 2014 21:21
Replied by matt on topic k2 Category description search

k2 Category description search

Category: English K2 Community

Hi,

OK, am still not getting anything to show up. I changed the code in plugins/search/k2_category_search/k2cat.php to the following:

// no direct access
defined('_JEXEC') or die ;

jimport('joomla.plugin.plugin');
jimport('joomla.html.parameter');

class plgSearchK2 extends JPlugin
{

function onContentSearchAreas()
{
return $this->onSearchAreas();
}

function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
return $this->onSearch($text, $phrase, $ordering, $areas);
}

function onSearchAreas()
{
JPlugin::loadLanguage('plg_search_k2', JPATH_ADMINISTRATOR);
static $areas = array('k2' => 'K2_CATEGORIES');
return $areas;
}

function onSearch($text, $phrase = '', $ordering = '', $areas = null)
{
JPlugin::loadLanguage('plg_search_k2', JPATH_ADMINISTRATOR);
jimport('joomla.html.parameter');
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();

$nullDate = $db->getNullDate();
$user = JFactory::getUser();
if (K2_JVERSION != '15')
{
$accessCheck = " IN(".implode(',', $user->getAuthorisedViewLevels()).") ";
}
else
{
$aid = $user->get('aid');
$accessCheck = " <= {$aid} ";
}
$tagIDs = array();
$itemIDs = array();

require_once (JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_search'.DS.'helpers'.DS.'search.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php');

$searchText = $text;
if (is_array($areas))
{
if (!array_intersect($areas, array_keys($this->onSearchAreas())))
{
return array();
}
}

$plugin = JPluginHelper::getPlugin('search', 'k2_Category_Search');
$pluginParams = class_exists('JParameter') ? new JParameter($plugin->params) : new JRegistry($plugin->params);

$limit = $pluginParams->def('search_limit', 50);

$text = JString::trim($text);
if ($text == '')
{
return array();
}

$rows = array();

if ($limit > 0)
{

if ($phrase == 'exact')
{
$text = JString::trim($text, '"');
$escaped = K2_JVERSION == '15' ? $db->getEscaped($text, true) : $db->escape($text, true);
$quoted = $db->Quote($escaped);
$where = " ( LOWER(c.name) = ".$quoted." OR LOWER(c.description) = ".$quoted.") ";
}
else
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($text, true) : $db->escape($text, true);
$quoted = $db->Quote('%'.$escaped.'%', false);
$where = " ( LOWER(c.name) LIKE ".$quoted." OR LOWER(c.description) LIKE ".$quoted.") ";
}

if ($pluginParams->get('search_tags') && count($itemIDs))
{
JArrayHelper::toInteger($itemIDs);
$where .= " OR c.id IN (".implode(',', $itemIDs);
}
$query = "
SELECT c.name AS title,
c.description AS text,
c.id
c.alias,
c.created,
CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as catslug
FROM #__k2_categories AS c
WHERE (".$where.")
AND c.published = 1
AND c.access {$accessCheck}
AND c.trash = 0
";
if (K2_JVERSION != '15' && $mainframe->isSite() && $mainframe->getLanguageFilter())
{
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND c.language IN (".$db->Quote($languageTag).", ".$db->Quote('*').")";
}
$query .= " GROUP BY c.id ";

switch ($ordering)
{
case 'oldest' :
$query .= 'ORDER BY c.created ASC';
break;


case 'alpha' :
$query .= 'ORDER BY c.name ASC';
break;


case 'newest' :
default :
$query .= 'ORDER BY c.created DESC';
break;
}

$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list))
{
foreach ($list as $key => $item)
{
$list[$key]->href = JRoute::_(K2HelperRoute::getItemRoute($item->slug, $item->catslug));

}
}
$rows[] = $list;
}

$results = array();
if (count($rows))
{
foreach ($rows as $row)
{
$new_row = array();
foreach ($row as $key => $item)
{
$item->browsernav = '';
$item->tag = $searchText;
if (searchHelper::checkNoHTML($item, $searchText, array('text', 'title')))
{
$new_row[] = $item;
}
}
$results = array_merge($results, (array)$new_row);
}
}

return $results;
}

}
  • guido
  • guido's Avatar
21 Mar 2014 21:15
Security Issue with SecurityCheck was created by guido

Security Issue with SecurityCheck

Category: English K2 Community

Hello, I developed my website with K2 and miniK2.
Recently I discovered how new users were created, and used the domain to spam through mail, as I receive returned unknown mails...

I installed SecurityCheck, and at the first scan I see a lot of issues, mostly XSS (possible) attacks...
they all refer to /index.php and module com_k2.

Is there a safe way to delete all these attacks?
Should I remove k2 and reinstall it?? As the web site is strongly based on k2, uninstalling this module would require to recreate all the modules based on k2 content/items??
Should just upgrade to the new version resolve the issue??

I really have few knowledge of xss attacks, and how to eliminate them...

Thank you in advance
  • matt
  • matt's Avatar
20 Mar 2014 15:02
Replied by matt on topic k2 Category description search

k2 Category description search

Category: English K2 Community

I'm sorry. I should have been more specific and clarified. I modified your k2 search plugin and reinstalled it as a separate plugin. However I can not get the default Joomla search to search category titles, category description, or category image captions and I need it to. here's the modified php plugin:

Is it my query that's wrong?



<?php
/**
* @version $Id: k2.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: www.gnu.org/copyleft/gpl.html
* @modified Jeno Kovacs - Offlajn Store This email address is being protected from spambots. You need JavaScript enabled to view it.
*/

// no direct access
defined('_JEXEC') or die ;

jimport('joomla.plugin.plugin');
jimport('joomla.html.parameter');

class plgSearchK2Category extends JPlugin
{

function onContentSearchAreas()
{
return $this->onSearchAreas();
}

function onContentSearch($text, $phrase = '', $ordering = '', $areas = null)
{
return $this->onSearch($text, $phrase, $ordering, $areas);
}

function onSearchAreas()
{
JPlugin::loadLanguage('plg_search_k2', JPATH_ADMINISTRATOR);
static $areas = array('k2' => 'K2_ITEMS');
return $areas;
}

function onSearch($text, $phrase = '', $ordering = '', $areas = null)
{
JPlugin::loadLanguage('plg_search_k2', JPATH_ADMINISTRATOR);
jimport('joomla.html.parameter');
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$jnow = JFactory::getDate();
$now = K2_JVERSION == '15' ? $jnow->toMySQL() : $jnow->toSql();

$nullDate = $db->getNullDate();
$user = JFactory::getUser();
if (K2_JVERSION != '15')
{
$accessCheck = " IN(".implode(',', $user->getAuthorisedViewLevels()).") ";
}
else
{
$aid = $user->get('aid');
$accessCheck = " <= {$aid} ";
}
$tagIDs = array();
$catIDs = array();

require_once (JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_search'.DS.'helpers'.DS.'search.php');
require_once (JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'route.php');

$searchText = $text;
if (is_array($areas))
{
if (!array_intersect($areas, array_keys($this->onSearchAreas())))
{
return array();
}
}

$plugin = JPluginHelper::getPlugin('search', 'k2');
$pluginParams = class_exists('JParameter') ? new JParameter($plugin->params) : new JRegistry($plugin->params);

$limit = $pluginParams->def('search_limit', 50);

$text = JString::trim($text);
if ($text == '')
{
return array();
}

$rows = array();

if ($limit > 0)
{

if ($pluginParams->get('search_tags'))
{
$tagQuery = JString::str_ireplace('*', '', $text);
$words = explode(' ', $tagQuery);
for ($i = 0; $i < count($words); $i++)
{
$words[$i] .= '*';
}
$tagQuery = implode(' ', $words);
$escaped = K2_JVERSION == '15' ? $db->getEscaped($tagQuery, true) : $db->escape($tagQuery, true);
$tagQuery = $db->Quote($escaped, false);

$query = "SELECT id FROM #__k2_tags WHERE MATCH(name) AGAINST ({$tagQuery} IN BOOLEAN MODE) AND published=1";
$db->setQuery($query);
$tagIDs = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();

if (count($tagIDs))
{
JArrayHelper::toInteger($tagIDs);
$query = "SELECT itemID FROM #__k2_tags_xref WHERE tagID IN (".implode(',', $tagIDs).")";
$db->setQuery($query);
$catIDs = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
}
}

if ($phrase == 'exact')
{
$text = JString::trim($text, '"');
$escaped = K2_JVERSION == '15' ? $db->getEscaped($text, true) : $db->escape($text, true);
$text = $db->Quote('"'.$db->getEscaped($text, true).'"', false);
}
else
{
$text = JString::str_ireplace('*', '', $text);
$words = explode(' ', $text);
for ($i = 0; $i < count($words); $i++)
{
if ($phrase == 'all')
$words[$i] = '+'.$words[$i];
$words[$i] .= '*';
}
$text = implode(' ', $words);
$escaped = K2_JVERSION == '15' ? $db->getEscaped($text, true) : $db->escape($text, true);
$text = $db->Quote($escaped, false);
}
//Category Exclusion Developed By: Offlajn Team
$categoryExc = "";
if ($pluginParams->get('excludecats')) {
$categoryExc = " AND i.catid NOT IN (".implode(",", $pluginParams->get('excludecats')).") ";
}

//Item Exclusion Developed By: Offlajn Team
$catExc = "";
if ($pluginParams->get('excludeitems')) {
$catExc = " AND i.id NOT IN (".$pluginParams->get('excludeitems').") ";
}

$query = "
SELECT c.id,c.title AS title,
c.name as section,
c.image_caption,
c.image_credits,
c.created,
c.description,
CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(':', c.id, c.alias) ELSE c.id END as catslug
FROM #__k2_categories AS c
INNER JOIN #__k2_categories AS c ON c.id=i.catid AND c.access {$accessCheck}
WHERE (";
if ($pluginParams->get('search_tags') && count($catIDs))
{
JArrayHelper::toInteger($catIDs);
$query .= " c.id IN (".implode(',', $catIDs).") OR ";
}



$query .= "MATCH(c.title, c.image_caption, c.image_credits, c.name, c.description) AGAINST ({$text} IN BOOLEAN MODE)
)
AND c.published = 1
AND c.access {$accessCheck}
AND c.trash = 0";
if (K2_JVERSION != '15' && $mainframe->isSite() && $mainframe->getLanguageFilter())
{
$languageTag = JFactory::getLanguage()->getTag();
$query .= " AND c.language IN (".$db->Quote($languageTag).", ".$db->Quote('*').") ";
}

$query .= $catExc; //Items Exclusion
$query .= $categoryExc; //Category Exclusion

$query .= " GROUP BY i.id ";

switch ($ordering)
{
case 'oldest' :
$query .= 'ORDER BY c.created ASC';
break;

case 'popular' :
$query .= 'ORDER BY c.hits DESC';
break;

case 'alpha' :
$query .= 'ORDER BY c.title ASC';
break;

case 'category' :
$query .= 'ORDER BY c.name ASC, c.title ASC';
break;

case 'newest' :
default :
$query .= 'ORDER BY c.created DESC';
break;
}


$db->setQuery($query, 0, $limit);
$list = $db->loadObjectList();
$limit -= count($list);
if (isset($list))
{
foreach ($list as $key => $cat)
{
$list[$key]->href = JRoute::_(K2HelperRoute::getItemRoute($cat->slug, $cat->catslug));

}
}
$rows[] = $list;
}

$results = array();
if (count($rows))
{
foreach ($rows as $row)
{
$new_row = array();
foreach ($row as $key => $cat)
{
if (JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$cat->id).'_L.jpg')) {
$cat->image = 'media/k2/items/cache/'.md5("Image".$cat->id).'_L.jpg';
} else if(JFile::exists(JPATH_SITE.DS.'media'.DS.'k2'.DS.'items'.DS.'cache'.DS.md5("Image".$cat->id).'_L.png')) {
$cat->image = 'media/k2/items/cache/'.md5("Image".$cat->id).'_L.png';
}
$cat->browsernav = '';
$cat->tag = $searchText;
if (searchHelper::checkNoHTML($cat, $searchText, array('text', 'title')))
{
$new_row[] = $cat;
}
}
$results = array_merge($results, (array)$new_row);
}
}

return $results;
}

}
  • Lefteris
  • Lefteris's Avatar
18 Mar 2014 12:19

100's of none working URLs with itemlist/tag in it

Category: English K2 Community

The Joomla! redirect component just shows there requests to your server that gave a 404 error. This does not mean that your site has broken links. This seems to me like a spam attack since older versions of K2 would display a page even if the tag in the URL didn't exists. Since you have updated to latest K2 version such pages should return a 404 error. I don't think you should worry. The only thing you need to check again is that there are no broken links in your site.
  • Lefteris
  • Lefteris's Avatar
12 Mar 2014 12:19 - 12 Mar 2014 12:21
Replied by Lefteris on topic Featured items not showing in category view

Featured items not showing in category view

Category: English K2 Community

Hi. K2 2.6.2 is a really old version. Check your template overrides ( if any ). Do you have any third-party K2 related extensions installed in your system ? Finally, a link to your site would be very helpful.
  • Lefteris
  • Lefteris's Avatar
07 Mar 2014 18:06
Replied by Lefteris on topic Duplicate Content - Where is the problem?

Duplicate Content - Where is the problem?

Category: English K2 Community

I don't know how you get this 404 error. K2 only raises a 404 error when an item is not found. So probably this is done by SH404SEF and K2 has nothing to do with that. Check that SH404SEF configuration is identical in both sites. Do the same for K2 settings also ( SH404SEF and advanced SEF sections ). Finally ensure that both K2 and SH404SEF are at the same version on both sites. If none of the above helps i suggest to ask for help at SH404SEF website.
  • Randy
  • Randy's Avatar
28 Feb 2014 06:57

K2 Add/Edit Item not showing K2 tool buttons

Category: English K2 Community

Thanks, Kanna. I guess in the newer Joomla/K2 versions some of the tool buttons have been eliminated such as "styles" and "spellcheck". I was relying on my memories of Joomla 2.5/K2 and thought K2 offered many more text options than did the Joomla article editor. Perhaps there was another extension that was installed that expanded k2's text options - I really can't remember. I expected to see a "format Font" button in the new K2 but I guess there isn't one. In order to change font, font size and font color do you have to rely on the template's CSS to do that? If not, how is it done?
  • Lefteris
  • Lefteris's Avatar
27 Feb 2014 16:20
Replied by Lefteris on topic [SOLVED] reCaptcha does not show

[SOLVED] reCaptcha does not show

Category: English K2 Community

Hi. Try to:

1. Check your page for Javascript errors.
2. Use another browser.
3. Update your K2 installation to the current stable version.
  • Jackson
  • Jackson's Avatar
27 Feb 2014 03:50 - 27 Feb 2014 03:53
Replied by Jackson on topic [SOLVED] SQL syntax error

[SOLVED] SQL syntax error

Category: English K2 Community

I'm having this issue too.

It happens when the plugin renders the HTML for an item in the admin page. If one's being added, it will fetch the current K2 item categories to show. But it doesn't realise it's being added, and there is no K2 item ID yet.

I've made a fix where it checks for the item id, and if it's null, then it doesn't bother fetching the categories.

Hopefully it works for others!

I can't seem to attach the file... it goes in k2/k2additionalcategories/k2additionalcategories.php

<?php
/**
* @version 1.0.1
* @package Additional Categories for K2 (plugin)
* @author Thodoris Bgenopoulos <This email address is being protected from spambots. You need JavaScript enabled to view it.>
* @link www.netpin.gr
* @copyright Copyright (c) 2012 netpin.gr
* @license GNU/GPL license: www.gnu.org/copyleft/gpl.html
*/


// no direct access
defined('_JEXEC') or die ('Restricted access');


// Load the K2 Plugin API
JLoader::register('K2Plugin', JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'lib'.DS.'k2plugin.php');

// Initiate class to hold plugin events
class plgK2k2additonalcategories extends K2Plugin {


/**
* Constructor
*
* For php4 compatability we must not use the __constructor as a constructor for plugins
* because func_get_args ( void ) returns a copy of all passed arguments NOT references.
* This causes problems with cross-referencing necessary for the observer design pattern.
*
* @param object $subject The object to observe
* @param object $params The object that holds the plugin parameters
* @since 1.5
*/
function plgK2k2additonalcategories( & $subject, $params) {
parent::__construct($subject, $params);
}


/**
* Modify the k2 query(items) before being executed in order to count or return additional items.
*
*
* @param string The query.
* @return string
*/
function onK2BeforeSetQuery(&$query)
{

$mainframe = &JFactory::getApplication();
$query_parts=explode('WHERE',$query);

//admin backend area
if($mainframe->isAdmin())
{
//filter by category
if (preg_match("/i.catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);

}
//filter by category count results
if (preg_match("/ catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{

$catids_in=trim($matches[0][0]);
$add_catids_in=str_replace('catid IN','ca.`catid` IN',$catids_in);
$catids_in_add_pref=str_replace('catid IN','i.`catid` IN',$catids_in);
$all_catids='('. $catids_in_add_pref .' OR '. $add_catids_in .')';

$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[1]=str_replace('trash','i.`trash`',$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";

$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);

}

}


//frontend area
if($mainframe->isSite())
{

$task = JRequest::getCmd('task');
$view= JRequest::getCmd('view');
$layout= JRequest::getCmd('layout');
$category_id= JRequest::getInt('id');

//user blog layout
if($task=='user' && $view=='itemlist')
{

if (preg_match("/i.catid IN\([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);

}

//k2 2.6.3 +
if (preg_match("/c.id IN\([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{

$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);


}

}
//one category id
if($task=='category' && $view=='itemlist' && $category_id > 0)
{
if (preg_match("/c.id IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);


}

//catalog mode
if (preg_match("/c.id\=[\d]+/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{

$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id','ca.`catid`',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);

}

}

//multiple category ids
if($layout=='category' && $view=='itemlist' && $category_id==0)
{
if (preg_match("/i.catid IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('i.catid IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);

}

//k2 2.6.3 +
if (preg_match("/c.id IN \([\d,]+\)/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{

$catids_in=$matches[0][0];
$add_catids_in=str_replace('c.id IN','ca.`catid` IN',$catids_in);
$all_catids='('. $catids_in .' OR '. $add_catids_in .')';
$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);

$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";
$query_parts[0]=str_replace('i.*','DISTINCT i.`id`,i.*',$query_parts[0]);

//case count
$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);

$query=implode(' WHERE ',$query_parts);



}

}

}

}


/**
* Brings the GUI of plugin in the content tab of the k2 item.
*
* @param object The k2 item.
* @param string The view.
* @param string The tab for assign the plugin.
* @return object
*/
function onRenderAdminForm(&$item, $type, $tab='')
{
if($type=='item' && $tab=='content')
{

$plugin = new JObject;
$language = JFactory::getLanguage();
$language->load('com_k2additionalcategories');
$plugin->set('name', JText::_( 'COM_K2ADDITIONALCATEGORIES_LBL' ));
$db = &JFactory::getDBO();
$query = 'SELECT m.* FROM #__k2_categories AS m WHERE m.`trash` = 0 ORDER BY `parent`, `ordering`';
$db->setQuery( $query );
$mitems = $db->loadObjectList();
$children = array();
if ($mitems)
{
foreach ( $mitems as $v )
{
if(K2_JVERSION!='15')
{
$v->title = $v->name;
$v->parent_id = $v->parent;
}
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push( $list, $v );
$children[$pt] = $list;
}
}
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 );
$mitems = array();

foreach ( $list as $i )
{
$i->treename = JString::str_ireplace('&#160;', '- ', $i->treename);
$mitems[] = JHTML::_('select.option', $i->id, ' '.$i->treename );
}

// New item, item ID not set yet
if ($item->id === null) {
$fields=JHTML::_('select.genericlist', $mitems,'itm_add_catids[]', 'class="inputbox" style="width:100%;" multiple="multiple" size="10"', 'value', 'text', '' );

$plugin->set('fields', $fields);
return $plugin;
}

$query = "SELECT `catid` FROM #__k2_additional_categories WHERE `itemID` = {intval($item->id)}";
$db->setQuery( $query );
if (version_compare(JVERSION, '1.6.0', '<'))
{
$sel_value = $db->loadResultArray();
}
else
{
$sel_value = $db->loadColumn();
}


$fields=JHTML::_('select.genericlist', $mitems,'itm_add_catids[]', 'class="inputbox" style="width:100%;" multiple="multiple" size="10"', 'value', 'text', $sel_value );

$plugin->set('fields', $fields);
return $plugin;

}

}


/**
* Saves data in db after apply or save.
*
* @param object The updated or new k2 item.
* @param boolean Flag setting if the item is new or not.
* @return void
*/
function onAfterK2Save(&$row, $isNew)
{

$add_catids = JRequest::getVar('itm_add_catids','',array());
$db = &JFactory::getDBO();
$query ="DELETE FROM #__k2_additional_categories WHERE `itemID`= {intval($row->id)}";
$db->setQuery($query);
$db->query();
if(is_array($add_catids) && count($add_catids) > 0)
{
foreach($add_catids as $k=>$v)
{

$v=intval($v);
if($v > 0)
{
$query = "INSERT INTO #__k2_additional_categories (`id`, `catid`, `itemID`) VALUES(NULL, '$v', {intval($row->id)})";
$db->setQuery($query);
$db->query();
}

}

}

}


/**
* Custom trigger (not k2 core). Count the active or trash item the category has.Category list on backend.
*
* @param string The k2 query.
* @return string
*
* @deprecated
*/
function onK2BeforeCountCategoryItemsQuery(&$query)
{

$query_parts=explode('WHERE',$query);
if (preg_match("/catid\=[\d]+/",$query_parts[1], $matches, PREG_OFFSET_CAPTURE) > 0)
{
$catids_in=$matches[0][0];
$add_catids_in=str_replace('catid','ca.`catid`',$catids_in);
$catids_in_add_pref=str_replace('catid','i.`catid`',$catids_in);
$all_catids='('. $catids_in_add_pref .' OR '. $add_catids_in .')';

$query_parts[1]=str_replace($catids_in,$all_catids,$query_parts[1]);
$query_parts[1]=str_replace('trash','i.`trash`',$query_parts[1]);
$query_parts[0].=" LEFT JOIN #__k2_additional_categories AS ca ON ca.`itemID` = i.`id`";

$query_parts[0]=str_replace('COUNT(*)','COUNT(DISTINCT i.`id`)',$query_parts[0]);
$query_parts[0]=str_replace('FROM #__k2_items','FROM #__k2_items AS i',$query_parts[0]);
$query=implode(' WHERE ',$query_parts);
}

}


/**
* Custom trigger (not k2 core). Count the active or trash item the category has.Category list on backend.
*
* @param string The k2 query.
* @return string
*
* @since 1.0.1
*/
function onK2BeforeCountCategoryItemsAdmin(&$result,$catid,$trash)
{

$db = &JFactory::getDBO();
$query = "SELECT COUNT(ca.`itemID`) FROM #__k2_items AS i,#__k2_additional_categories AS ca WHERE ca.`catid`={intval($catid)} AND i.`trash`={intval($trash)} AND i.`id`=ca.`itemID`";

$db->setQuery($query);
$total_additional = $db->loadResult();
$result=$result+$total_additional;

}


/**
* Custom trigger (not k2 core). Delete the k2 item entry from #__k2_additional_categories when
* item removed from k2.
*
* @param object The k2 item.
* @return void
*/
function onK2AfterDeleteItem($row)
{
$db = &JFactory::getDBO();
$query ="DELETE FROM #__k2_additional_categories WHERE `itemID`= {intval($row->id)}";
$db->setQuery($query);
$db->query();
}




// Events to display (in the frontend)




/**
* Custom trigger (not k2 core). Generate link and title of additional catecories if exists.
*
* @param int The id of k2 item.
* @return array
*/
function onK2AfterLinkCategoryPublish($itemID) {

$itemID=intval($itemID);
$output='';
if($itemID > 0)
{

$db = &JFactory::getDBO();
$query = "SELECT c.`id`,c.`name`,c.`alias` FROM #__k2_additional_categories AS ca, #__k2_categories AS c WHERE ca.`itemID` ='$itemID' AND c.`id`=ca.`catid`";
$db->setQuery( $query );
$sel_value = $db->loadObjectList();

foreach($sel_value as $k=>$v)
{
$link= urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($v->id.':'.urlencode($v->alias))));
$output.=', <span class="add_cat_link"><a href="'.$link.'">'.$v->name.'</a></span>';
}
}
return $output;
}


/**
* Custom trigger (not k2 core). Add additional category items to the count of current category subcategories.
*
* @param int The count of items that subcategory have.
* @param int The subcategory id.
* @param object The subcategories data.
* @return int
*/
function onK2BeforeSetCountCategoryQuery(&$total, &$id, &$categories)
{

$mainframe = &JFactory::getApplication();
$user = &JFactory::getUser();
$aid = (int) $user->get('aid');
$id = (int) $id;
$db = &JFactory::getDBO();

$jnow = &JFactory::getDate();
$now = $jnow->toMySQL();
$nullDate = $db->getNullDate();

$query = "SELECT COUNT(ca.`itemID`) FROM #__k2_items AS i,#__k2_additional_categories AS ca WHERE ca.`catid` IN (".implode(',', $categories).") AND i.`published`=1 AND i.`trash`=0 AND i.`id`=ca.`itemID`";

if(K2_JVERSION!='15')
{
$query .= " AND i.access IN(".implode(',', $user->authorisedLevels()).") ";
if($mainframe->getLanguageFilter())
{
$query.= " AND i.`language` IN(".$db->Quote(JFactory::getLanguage()->getTag()).", ".$db->Quote('*').")";
}
}
else
{
$query .=" AND i.`access`<=".$aid;
}

$query .= " AND ( i.`publish_up` = ".$db->Quote($nullDate)." OR i.`publish_up` <= ".$db->Quote($now)." )";
$query .= " AND ( i.`publish_down` = ".$db->Quote($nullDate)." OR i.`publish_down` >= ".$db->Quote($now)." )";
$db->setQuery($query);
$total_additional = $db->loadResult();
$total=$total+$total_additional;
}

}
  • Mario Beck
  • Mario Beck's Avatar
26 Feb 2014 13:55

[SOLVED] Item created & published dates change on edit

Category: English K2 Community

Did some troubleshooting.. here are the results

First of all i've checked if the regular joomla articles/categories are still accessable and found out that the category manager is not langer accessable with the following error message

Fatal error: Call to undefined method CategoriesHelper::getActions() in C:\inetpub\wwwroot\joomla\administrator\components\com_categories\views\categories\view.html.php on line 106

line 106:
// Get the results for each action.
$canDo = CategoriesHelper::getActions($component, $categoryId);

This will get important later..

Next step.. installed the latest dev build (again) without uninstalling K2 before
Issue still occurs!

Uninstalled K2 and installed your latest dev version..
issue is gone.. item is published directly and this would mean it is solved BUT
of course all my items and categories i have created before have gone and i cant access the joomla category manager.. do you have a workaround how i can save my already created items/categories?

thank you
  • Lefteris
  • Lefteris's Avatar
23 Feb 2014 21:50 - 24 Feb 2014 12:03
Replied by Lefteris on topic Cannot delete image from K2 item

Cannot delete image from K2 item

Category: Commercial Joomla Templates

Krikor Boghossian wrote: Hello Thanos,

Since Joomla! does not support image resizing so it is normal that this happens when GD library is needed.

These are the minimum requirements for Joomla! www.joomla.org/technical-requirements.html


Dear Krikor,

I appreciate your effort to advice me how to overtake this issue. I just check the requirements and found out that the php and mysql version on my client's server is higher than minimum requirements.

Here's all info:

Kindly advice.
  • John Dunstan
  • John Dunstan's Avatar
23 Feb 2014 03:03 - 23 Feb 2014 03:06
Sorry K2 was created by John Dunstan

Sorry K2

Category: English K2 Community

Hello,

I write this post with a heavy heart...I have been using K2 for so so many years, and I have loved the component. I used it in every Joomla build I did for myself and my customers, and back in the Joomla 1.5 days, I even replaced the default Joomla articles with k2 items and used K2 for my info pages. K2 WAS the bomb back in the day!

When JoomlArt decided to drop K2 for EasyBlog, I personally protested and argued constantly, then I saw Gavick change to EasyBlog, and I protested again...I have been one of K2's biggest fan boys who has promoted K2 till I am blue in the face.

With that said, today I move to EasyBlog...I'll tell you why!

1) Joomla 3 does almost everything K2 does and it does it better and MUCH faster

2) If ALL a person wants is 1 blog (not team or multi blogging), then they don't need anything more than default Joomla articles and maybe disquss

3) The backend user interface is dated and doesnt look professional. K2 stayed with pretty much the same 'look' with its Joomla 3 implementation....This adds less professionalisim to our projects and it adds a different UI for customers to get accustomed to.

4) The front end user interface is horrible....if people want to use K2 for Team or Multi blogging, K2 simply is to much effort. Plus to get frontend editing actually working is to much of an effort...back when I started with K2, it took way to long to figure out how to get front end editing working...it should just be a check box, nothing more to enble front end editing...in fact, it should be enabled by default, especially with Joomla 3.

5) (this relates to 3 and 4)...K2 is only applicable for web designers or people who buy templates with K2 setup and styled. For anyone who is not a website developer, K2 is not an option. It is very ugly when you install it, and requires 'time' to style it. Therefore, K2 has cornered itself into the market of developers only...same goes for the front end and backend user interface. Compare this to EasyBlog, anyone can install this and not need to edit any code to make it look right.

6) K2 simply hasnt grown and adapted to give more than what default Joomla 3 articles can give. Look at the feature set difference between EasyBlog and K2? If K2 is to survive, it needs to adapt.

7) So K2 is a CCK, not just a blog! Yes, this is true...Lately, I have been trying to find any excuse to keep using K2, as I am so familar with it..I have tried to build business directories with it, a photography site with it, and much more....IK2 simply isnt flexible enough anymore for these things, there are better Joomla extensions out there that are designed for these exact things.

8) K2 is rather slow compared to default Joomla articles

9) K2 brings out maybe 2 updates per year...For a Joomla component that has won awards and has been used widely but many Joomla template clubs, the development of K2 has been very slow and very slow to bring out new features or just updates. updates are a sign of an active community.

10) For me lately, there have been to many show stopping bugs and things that don't work, which brings us back to no.9..with new versions of Joomla 3 coming out, we need updates. One example, is the Tags..selection based...When you choose a tag from the left list and then click ADD, NOTHING shows up in the right list...It is there, but it can't be seen. This has been a problem for almost 1 year now...this is ok for people like me that know its working, but for clients, It looked upon as a horrible mess up.

11) We are moving more and more into frontend editing, and as per no.4, K2 is quite awful. As a Joomla developer, I am personally ONLY interested in Joomla extensions that have decent looking and functioning front end editing capabilities. Clients are finally starting to use their sites more now and I am receiving less support phone calls asking how to edit this or edit that.

Guys, I know you provide a free component, but if you want K2 to endure, things must change, and they must change now. WIth Joomla template clubs like JoomlArt dropping support for you, it won;t be long before more drop support for you. etc etc....Template clubs are even dropping support for Virtuemart now, because Virtuemart won't provide a Joomla 3 version until it becomes LTS.

If you have to charge money, so be it....The JoomlaSphere has been changing to a subscription based model for extensions more and more lately, so why not do that?

Either way, I do write this with a heavy heart, and honestly I write this in hopes that you take what I write seriously and look to refresh K2 and bring the Joomla community back to K2...The trouble is, once you have lost people, its very hard to get them back....Its better to change when you have people, this way when you improve and provide great new features, customers love you even more and become even more loyal.

K2 has been great, but for me (and many others as it seems), we need to find something that caters to our needs better...

Sorry for this post, BUT I look forward to see where K2 goes from here!

Signed
X K2 Lover!
Displaying 81 - 100 out of 270 results.

Powered by Kunena Forum