feat(deployed): add K2 2.8.0 (no-source, vetted live)

K2 2.8.0 (JoomlaWorks), vetted clean from live; no version-matching upstream package (getk2/k2 has no 2.8.0 tag) → deployed files. Bundles elFinder (admin file-manager attack surface).

Signed-off-by: LÁZÁR Imre <imre@illusion.hu>
Assisted-by: claude-code@claude-opus-4-8
This commit is contained in:
LÁZÁR Imre AI Agent 2026-07-16 09:48:13 +02:00
parent 47ba7facad
commit 266c5956af
1081 changed files with 151411 additions and 0 deletions

View File

@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<access component="com_k2">
<section name="component">
<action name="core.admin" title="JACTION_ADMIN" description="JACTION_ADMIN_COMPONENT_DESC"/>
<action name="core.manage" title="JACTION_MANAGE" description="JACTION_MANAGE_COMPONENT_DESC"/>
<action name="core.create" title="JACTION_CREATE" description="JACTION_CREATE_COMPONENT_DESC"/>
<action name="core.delete" title="JACTION_DELETE" description="JACTION_DELETE_COMPONENT_DESC"/>
<action name="core.edit" title="JACTION_EDIT" description="JACTION_EDIT_COMPONENT_DESC"/>
<action name="core.edit.state" title="JACTION_EDITSTATE" description="JACTION_EDITSTATE_COMPONENT_DESC"/>
<action name="core.edit.own" title="JACTION_EDITOWN" description="JACTION_EDITOWN_COMPONENT_DESC"/>
</section>
</access>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerCategories extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'categories');
parent::display();
}
function publish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->publish();
}
function unpublish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->unpublish();
}
function saveorder()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->saveorder();
$document = JFactory::getDocument();
if ($document->getType() == 'raw')
{
echo '1';
return $this;
}
else
{
$this->setRedirect('index.php?option=com_k2&view=categories', JText::_('K2_NEW_ORDERING_SAVED'));
}
}
function orderup()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->orderup();
}
function orderdown()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->orderdown();
}
function accessregistered()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->accessregistered();
}
function accessspecial()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->accessspecial();
}
function accesspublic()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->accesspublic();
}
function trash()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->trash();
}
function restore()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->restore();
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->remove();
}
function add()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=category');
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=category&cid='.$cid[0]);
}
function element()
{
JRequest::setVar('view', 'categories');
JRequest::setVar('layout', 'element');
parent::display();
}
function move()
{
$view = $this->getView('categories', 'html');
$view->setLayout('move');
$view->move();
}
function saveBatch()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->saveBatch();
}
function saveMove()
{
$model = $this->getModel('categories');
$model->move();
}
function copy()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('categories');
$model->copy();
}
}

View File

@ -0,0 +1,49 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerCategory extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'category');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('category');
$model->save();
}
function saveAndNew()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('category');
$model->save();
}
function apply()
{
$this->save();
}
function cancel()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=categories');
}
}

View File

@ -0,0 +1,60 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerComments extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
require_once(JPATH_SITE.'/components/com_k2/helpers/route.php');
JRequest::setVar('view', 'comments');
parent::display();
}
function publish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('comments');
$model->publish();
}
function unpublish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('comments');
$model->unpublish();
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('comments');
$model->remove();
}
function deleteUnpublished()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('comments');
$model->deleteUnpublished();
}
function saveComment()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('comments');
$model->save();
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
if (version_compare(JVERSION, '3.0', 'ge'))
{
class K2Controller extends JControllerLegacy
{
public function display($cachable = false, $urlparams = array())
{
parent::display($cachable, $urlparams);
}
}
}
else if (version_compare(JVERSION, '2.5', 'ge'))
{
class K2Controller extends JController
{
public function display($cachable = false, $urlparams = false)
{
parent::display($cachable, $urlparams);
}
}
}
else
{
class K2Controller extends JController
{
public function display($cachable = false)
{
parent::display($cachable);
}
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerExtraField extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'extrafield');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraField');
$model->save();
}
function apply()
{
$this->save();
}
function cancel()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=extrafields');
}
}

View File

@ -0,0 +1,89 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerExtraFields extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'extrafields');
parent::display();
}
function publish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->publish();
}
function unpublish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->unpublish();
}
function saveorder()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->saveorder();
$document = JFactory::getDocument();
if ($document->getType() == 'raw')
{
echo '1';
return $this;
}
else
{
$this->setRedirect('index.php?option=com_k2&view=extrafields', JText::_('K2_NEW_ORDERING_SAVED'));
}
}
function orderup()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->orderup();
}
function orderdown()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->orderdown();
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->remove();
}
function add()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=extrafield');
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=extrafield&cid='.$cid[0]);
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerExtraFieldsGroup extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'extrafieldsgroup');
$model = $this->getModel('extraFields');
$view = $this->getView('extrafieldsgroup', 'html');
$view->setModel($model, true);
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$view = $this->getView('extrafieldsgroup', 'html');
$view->setModel($model, true);
$model->saveGroup();
}
function apply()
{
$this->save();
}
function cancel()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=extrafieldsgroups');
}
}

View File

@ -0,0 +1,47 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerExtraFieldsGroups extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'extrafieldsgroups');
$model = $this->getModel('extraFields');
$view = $this->getView('extrafieldsgroups', 'html');
$view->setModel($model, true);
parent::display();
}
function add()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=extrafieldsgroup');
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=extrafieldsgroup&cid='.$cid[0]);
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('extraFields');
$model->removeGroups();
}
}

View File

@ -0,0 +1,24 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerInfo extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'info');
parent::display();
}
}

View File

@ -0,0 +1,127 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerItem extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'item');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('item');
$model->save();
}
function apply()
{
$this->save();
}
function cancel()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('item');
$model->cancel();
}
function deleteAttachment()
{
$model = $this->getModel('item');
$model->deleteAttachment();
}
function tag()
{
$model = $this->getModel('tag');
$model->addTag();
}
function tags()
{
$user = JFactory::getUser();
if($user->guest)
{
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
$model = $this->getModel('tag');
$model->tags();
}
function download()
{
$model = $this->getModel('item');
$model->download();
}
function extraFields()
{
$application = JFactory::getApplication();
$itemID = JRequest::getInt('id', NULL);
$categoryModel = $this->getModel('category');
$category = $categoryModel->getData();
$extraFieldModel = $this->getModel('extraField');
$extraFields = $extraFieldModel->getExtraFieldsByGroup($category->extraFieldsGroup);
$counter = 0;
$output = '';
if (count($extraFields))
{
foreach ($extraFields as $extraField)
{
if ($extraField->type == 'header')
{
$output .= '<div class="itemAdditionalField"><h4 class="k2ExtraFieldHeader">'.$extraField->name.'</h4></div>';
}
else
{
$output .= '
<div class="itemAdditionalField">
<div class="k2Right k2FLeft itemAdditionalValue">
<label for="K2ExtraField_'.$extraField->id.'">'.$extraField->name.'</label>
</div>
<div class="itemAdditionalData">'.$extraFieldModel->renderExtraField($extraField, $itemID).'</div>
</div>
';
}
$counter++;
}
}
if ($counter == 0)
$output = JText::_('K2_THIS_CATEGORY_DOESNT_HAVE_ASSIGNED_EXTRA_FIELDS');
echo $output;
$application->close();
}
function resetHits()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('item');
$model->resetHits();
}
function resetRating()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('item');
$model->resetRating();
}
}

View File

@ -0,0 +1,214 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerItems extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'items');
parent::display();
}
function publish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->publish();
}
function unpublish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->unpublish();
}
function saveorder()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$result = $model->saveorder();
$document = JFactory::getDocument();
if ($document->getType() == 'raw')
{
echo '1';
return $this;
}
else
{
$this->setRedirect('index.php?option=com_k2&view=items', JText::_('K2_NEW_ORDERING_SAVED'));
}
}
function orderup()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->orderup();
}
function orderdown()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->orderdown();
}
function savefeaturedorder()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$result = $model->savefeaturedorder();
$document = JFactory::getDocument();
if ($document->getType() == 'raw')
{
echo '1';
return $this;
}
else
{
$this->setRedirect('index.php?option=com_k2&view=items', JText::_('K2_NEW_FEATURED_ORDERING_SAVED'));
}
}
function featuredorderup()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->featuredorderup();
}
function featuredorderdown()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->featuredorderdown();
}
function accessregistered()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->accessregistered();
}
function accessspecial()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->accessspecial();
}
function accesspublic()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->accesspublic();
}
function featured()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->featured();
}
function trash()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->trash();
}
function restore()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->restore();
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->remove();
}
function add()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=item');
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=item&cid='.$cid[0]);
}
function copy()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->copy();
}
function element()
{
JRequest::setVar('view', 'items');
JRequest::setVar('layout', 'element');
parent::display();
}
function import()
{
$model = $this->getModel('items');
if (K2_JVERSION != '15')
{
$model->importJ16();
}
else
{
$model->import();
}
}
function saveBatch()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('items');
$model->saveBatch();
}
function logStats()
{
JRequest::checkToken() or jexit('Invalid Token');
$status = JRequest::getInt('status');
$response = JRequest::getString('response');
$date = JFactory::getDate();
$now = version_compare(JVERSION, '2.5', 'ge') ? $date->toSql() : $date->toMySQL();
$db = JFactory::getDbo();
$query = 'DELETE FROM #__k2_log';
$db->setQuery($query);
$db->query();
$query = 'INSERT INTO #__k2_log VALUES('.$status.', '.$db->quote($response).', '.$db->quote($now).')';
$db->setQuery($query);
$db->query();
exit;
}
}

View File

@ -0,0 +1,132 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
jimport('joomla.filesystem.file');
class K2ControllerMedia extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'media');
parent::display();
}
function connector()
{
if ($_POST)
{
JSession::checkToken('post') or jexit(JText::_('JINVALID_TOKEN'));
}
else
{
JSession::checkToken('get') or jexit(JText::_('JINVALID_TOKEN'));
}
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_media');
$root = $params->get('file_path', 'media');
$folder = JRequest::getVar('folder', $root, 'default', 'path');
$type = JRequest::getCmd('type', 'video');
if (JString::trim($folder) == "")
{
$folder = $root;
}
else
{
// Ensure that we are always below the root directory
if (strpos($folder, $root) !== 0)
{
$folder = $root;
}
}
// Disable debug
JRequest::setVar('debug', false);
$url = JURI::root(true).'/'.$folder;
$path = JPATH_SITE.'/'.JPath::clean($folder);
JPath::check($path);
require_once(JPATH_SITE.'/media/k2/assets/vendors/studio-42/elfinder/php/autoload.php');
function access($attr, $path, $data, $volume)
{
$application = JFactory::getApplication();
// Hide PHP files
$ext = strtolower(JFile::getExt(basename($path)));
if ($ext == 'php')
{
return true;
}
// Hide files and folders starting with .
if (strpos(basename($path), '.') === 0 && $attr == 'hidden')
{
return true;
}
// Read only access for front-end. Full access for administration section.
switch($attr)
{
case 'read' :
return true;
break;
case 'write' :
return ($application->isSite()) ? false : true;
break;
case 'locked' :
return ($application->isSite()) ? true : false;
break;
case 'hidden' :
return false;
break;
}
}
if ($application->isAdmin())
{
$permissions = array('read' => true, 'write' => true);
}
else
{
$permissions = array('read' => true, 'write' => false);
}
$options = array(
'debug' => false,
'roots' => array(
array(
'driver' => 'LocalFileSystem',
'path' => $path,
'URL' => $url,
'accessControl' => 'access',
'defaults' => $permissions,
'mimeDetect' => 'internal',
'uploadDeny' => array('all'),
'uploadAllow' => array('image', 'video', 'audio', 'text/plain', 'text/html', 'application/json', 'application/pdf', 'application/zip', 'application/x-7z-compressed', 'application/x-bzip', 'application/x-bzip2', 'text/css', 'application/msword', 'application/vnd.ms-excel', 'application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet', 'application/vnd.openxmlformats-officedocument.presentationml.presentation'),
'uploadOrder' => array('deny', 'allow')
)
)
);
$connector = new elFinderConnector(new elFinder($options));
$connector->run();
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerSettings extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
if (K2_JVERSION != '15')
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_config&view=component&component=com_k2&path=&tmpl=component');
}
else
{
JRequest::setVar('tmpl', 'component');
parent::display();
}
}
function save()
{
$application = JFactory::getApplication();
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('settings');
$model->save();
$application->redirect('index.php?option=com_k2&view=settings');
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerTag extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'tag');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('tag');
$model->save();
}
function apply()
{
$this->save();
}
function cancel()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=tags');
}
}

View File

@ -0,0 +1,72 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerTags extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'tags');
parent::display();
}
function publish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('tags');
$model->publish();
}
function unpublish()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('tags');
$model->unpublish();
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('tags');
$model->remove();
}
function add()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=tag');
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=tag&cid='.$cid[0]);
}
function element()
{
JRequest::setVar('view', 'tags');
JRequest::setVar('layout', 'element');
parent::display();
}
function removeOrphans()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('tags');
$model->removeOrphans();
}
}

View File

@ -0,0 +1,55 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerUser extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'user');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('user');
$model->save();
}
function apply()
{
$this->save();
}
function cancel()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=users');
}
function report()
{
$app = JFactory::getApplication();
$model = K2Model::getInstance('User', 'K2Model');
$model->setState('id', JRequest::getInt('id'));
$model->reportSpammer();
if(JRequest::getCmd('context') == "modalselector"){
$app->redirect('index.php?option=com_k2&view=users&tmpl=component&context=modalselector');
} else {
//$this->setRedirect('index.php?option=com_k2&view=users');
$app->redirect('index.php?option=com_k2&view=users');
}
}
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerUserGroup extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'usergroup');
parent::display();
}
function save()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('userGroup');
$model->save();
}
function apply()
{
$this->save();
}
function cancel()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=usergroups');
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerUserGroups extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'usergroups');
parent::display();
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=usergroup&cid='.$cid[0]);
}
function add()
{
$application = JFactory::getApplication();
$application->redirect('index.php?option=com_k2&view=usergroup');
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('userGroups');
$model->remove();
}
}

View File

@ -0,0 +1,106 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.controller');
class K2ControllerUsers extends K2Controller
{
public function display($cachable = false, $urlparams = array())
{
JRequest::setVar('view', 'users');
parent::display();
}
function edit()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$application->redirect('index.php?option=com_k2&view=user&cid='.$cid[0]);
}
function remove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('users');
$model->remove();
}
function element()
{
JRequest::setVar('view', 'users');
JRequest::setVar('layout', 'element');
parent::display();
}
function enable()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('users');
$model->enable();
}
function disable()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('users');
$model->disable();
}
function delete()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('users');
$model->delete();
}
function move()
{
$view = $this->getView('users', 'html');
$view->setLayout('move');
$model = $this->getModel('users');
$view->setModel($model);
$view->move();
}
function saveMove()
{
JRequest::checkToken() or jexit('Invalid Token');
$model = $this->getModel('users');
$model->saveMove();
}
function import()
{
$model = $this->getModel('users');
$model->import();
}
function search()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$word = JRequest::getString('q', null);
if (K2_JVERSION == '15')
{
$word = $db->Quote($db->getEscaped($word, true).'%', false);
}
else
{
$word = $db->Quote($db->escape($word, true).'%', false);
}
$query = "SELECT id,name FROM #__users WHERE name LIKE ".$word." OR username LIKE ".$word." OR email LIKE ".$word;
$db->setQuery($query);
$result = $db->loadObjectList();
echo json_encode($result);
$application->close();
}
}

View File

@ -0,0 +1,85 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
K2HelperHTML::loadHeadIncludes(true, true, false, true);
if (K2_JVERSION == '15')
{
jimport('joomla.html.parameter.element');
class K2Element extends JElement
{
}
}
else
{
jimport('joomla.form.formfield');
if(version_compare(JVERSION, '3.5.0', 'ge'))
{
class K2Element extends JFormField
{
function getInput()
{
if (method_exists($this,'fetchElement')) // BC
{
return $this->fetchElement($this->name, $this->value, $this->element, $this->options['control']);
}
return $this->fetchElementValue($this->name, $this->value, $this->element, $this->options['control']);
}
function getLabel()
{
if (method_exists($this, 'fetchTooltip')) // BC
{
return $this->fetchTooltip($this->element['label'], $this->description, $this->element, $this->options['control'], $this->element['name'] = '');
}
if (method_exists($this, 'fetchElementName'))
{
return $this->fetchElementName($this->element['label'], $this->description, $this->element, $this->options['control'], $this->element['name'] = '');
}
return parent::getLabel();
}
function render($layoutId, $data = array())
{
return $this->getInput();
}
}
}
else
{
class K2Element extends JFormField
{
function getInput()
{
if (method_exists($this, 'fetchElement')) // BC
{
return $this->fetchElement($this->name, $this->value, $this->element, $this->options['control']);
}
return $this->fetchElementValue($this->name, $this->value, $this->element, $this->options['control']);
}
function getLabel()
{
if (method_exists($this, 'fetchTooltip')) // BC
{
return $this->fetchTooltip($this->element['label'], $this->description, $this->element, $this->options['control'], $this->element['name'] = '');
}
if (method_exists($this, 'fetchElementName'))
{
return $this->fetchElementName($this->element['label'], $this->description, $this->element, $this->options['control'], $this->element['name'] = '');
}
return parent::getLabel();
}
function render()
{
return $this->getInput();
}
}
}
}

View File

@ -0,0 +1,92 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementCategories extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$db = JFactory::getDbo();
$query = 'SELECT m.* FROM #__k2_categories m WHERE 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();
$mitems[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'));
foreach ($list as $item)
{
$item->treename = JString::str_ireplace('&#160;', ' -', $item->treename);
$mitems[] = JHTML::_('select.option', $item->id, $item->treename);
}
$attributes = 'class="inputbox"';
if (K2_JVERSION != '15')
{
$attribute = K2_JVERSION == '25' ? $node->getAttribute('multiple') : $node->attributes()->multiple;
if ($attribute)
{
$attributes .= ' multiple="multiple" size="10"';
}
}
else
{
if ($node->attributes('multiple'))
{
$attributes .= ' multiple="multiple" size="10"';
}
}
if (K2_JVERSION != '15')
{
$fieldName = $name;
}
else
{
$fieldName = $control_name.'['.$name.']';
if ($node->attributes('multiple'))
{
$fieldName .= '[]';
}
}
return JHTML::_('select.genericlist', $mitems, $fieldName, $attributes, 'value', 'text', $value);
}
}
class JFormFieldCategories extends K2ElementCategories
{
var $type = 'categories';
}
class JElementCategories extends K2ElementCategories
{
var $_name = 'categories';
}

View File

@ -0,0 +1,138 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementCategoriesLatest extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
JHTML::_('behavior.modal');
$params = JComponentHelper::getParams('com_k2');
$document = JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
K2HelperHTML::loadjQuery();
$mainframe = JFactory::getApplication();
if (K2_JVERSION != '15')
{
$fieldName = $name;
if (!$node->attributes()->multiple)
{
$fieldName .= '[]';
}
$image = JURI::root(true).'/administrator/templates/'.$mainframe->getTemplate().'/images/admin/publish_x.png';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
$image = JURI::root(true).'/administrator/images/publish_x.png';
}
$js = "
function jSelectCategory(id, title, object) {
var exists = false;
\$K2('#categoriesList input').each(function(){
if(\$K2(this).val()==id){
alert('".JText::_('K2_THE_SELECTED_CATEGORY_IS_ALREADY_IN_THE_LIST', true)."');
exists = true;
}
});
if(!exists){
var container = \$K2('<li/>').appendTo(\$K2('#categoriesList'));
var img = \$K2('<img/>',{'class':'remove', src:'".$image."'}).appendTo(container);
img.click(function(){\$K2(this).parent().remove();});
var span = \$K2('<span/>',{'class':'handle'}).html(title).appendTo(container);
var input = \$K2('<input/>',{value:id, type:'hidden', name:'".$fieldName."'}).appendTo(container);
var div = \$K2('<div/>',{style:'clear:both;'}).appendTo(container);
\$K2('#categoriesList').sortable('refresh');
alert('".JText::_('K2_CATEGORY_ADDED_IN_THE_LIST', true)."');
}
}
\$K2(document).ready(function(){
\$K2('#categoriesList').sortable({
containment: '#categoriesList',
items: 'li',
handle: 'span.handle'
});
\$K2('#categoriesList .remove').click(function(){
\$K2(this).parent().remove();
});
});
";
$document->addScriptDeclaration($js);
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.modules.css?v=2.7.1');
$current = array();
if (is_string($value) && !empty($value))
{
$current[] = $value;
}
if (is_array($value))
{
$current = $value;
}
$output = '
<div class="button2-left">
<div class="blank">
<a class="modal btn" title="'.JText::_('K2_CLICK_TO_SELECT_ONE_OR_MORE_CATEGORIES').'" href="index.php?option=com_k2&view=categories&task=element&tmpl=component" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">'.JText::_('K2_CLICK_TO_SELECT_ONE_OR_MORE_CATEGORIES').'</a>
</div>
</div>
<div style="clear:both;"></div>
';
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'tables');
$output .= '<ul id="categoriesList">';
foreach ($current as $id)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($id);
$output .= '
<li>
<img class="remove" src="'.$image.'" />
<span class="handle">'.$row->name.'</span>
<input type="hidden" value="'.$row->id.'" name="'.$fieldName.'" />
<span style="clear:both;"></span>
</li>
';
}
$output .= '</ul>';
return $output;
}
}
class JFormFieldCategoriesLatest extends K2ElementCategoriesLatest
{
var $type = 'categorieslatest';
}
class JElementCategoriesLatest extends K2ElementCategoriesLatest
{
var $_name = 'categorieslatest';
}

View File

@ -0,0 +1,146 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementCategoriesMultiple extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$document = JFactory::getDocument();
$db = JFactory::getDbo();
$query = 'SELECT m.* FROM #__k2_categories m WHERE 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 $item)
{
$item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
$mitems[] = JHTML::_('select.option', $item->id, ' '.$item->treename);
}
$doc = JFactory::getDocument();
if (K2_JVERSION != '15')
{
$js = "
\$K2(document).ready(function(){
\$K2('#jform_params_catfilter0').click(function(){
\$K2('#jformparamscategory_id').attr('disabled', 'disabled');
\$K2('#jformparamscategory_id option').each(function() {
\$K2(this).attr('selected', 'selected');
});
\$K2('#jformparamscategory_id').trigger('liszt:updated');
});
\$K2('#jform_params_catfilter1').click(function(){
\$K2('#jformparamscategory_id').removeAttr('disabled');
\$K2('#jformparamscategory_id option').each(function() {
\$K2(this).removeAttr('selected');
});
\$K2('#jformparamscategory_id').trigger('liszt:updated');
});
if (\$K2('#jform_params_catfilter0').attr('checked')) {
\$K2('#jformparamscategory_id').attr('disabled', 'disabled');
\$K2('#jformparamscategory_id option').each(function() {
\$K2(this).attr('selected', 'selected');
});
\$K2('#jformparamscategory_id').trigger('liszt:updated');
}
if (\$K2('#jform_params_catfilter1').attr('checked')) {
\$K2('#jformparamscategory_id').removeAttr('disabled');
\$K2('#jformparamscategory_id').trigger('liszt:updated');
}
});
";
}
else
{
$js = "
\$K2(document).ready(function(){
\$K2('#paramscatfilter0').click(function(){
\$K2('#paramscategory_id').attr('disabled', 'disabled');
\$K2('#paramscategory_id option').each(function() {
\$K2(this).attr('selected', 'selected');
});
});
\$K2('#paramscatfilter1').click(function(){
\$K2('#paramscategory_id').removeAttr('disabled');
\$K2('#paramscategory_id option').each(function() {
\$K2(this).removeAttr('selected');
});
});
if (\$K2('#paramscatfilter0').attr('checked')) {
\$K2('#paramscategory_id').attr('disabled', 'disabled');
\$K2('#paramscategory_id option').each(function() {
\$K2(this).attr('selected', 'selected');
});
}
if (\$K2('#paramscatfilter1').attr('checked')) {
\$K2('#paramscategory_id').removeAttr('disabled');
}
});
";
}
if (K2_JVERSION != '15')
{
$fieldName = $name.'[]';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
}
$doc->addScriptDeclaration($js);
$output = JHTML::_('select.genericlist', $mitems, $fieldName, 'class="inputbox" multiple="multiple" size="10"', 'value', 'text', $value);
return $output;
}
}
class JFormFieldCategoriesMultiple extends K2ElementCategoriesMultiple
{
var $type = 'categoriesmultiple';
}
class JElementCategoriesMultiple extends K2ElementCategoriesMultiple
{
var $_name = 'categoriesmultiple';
}

View File

@ -0,0 +1,256 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementCategory extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$db = JFactory::getDbo();
$query = 'SELECT m.* FROM #__k2_categories m WHERE 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();
$option = JRequest::getCmd('option');
$prefix = ($option == 'com_joomfish') ? 'refField_' : '';
if ($name == 'categories' || $name == 'jform[params][categories]')
{
if(version_compare(JVERSION, '3.5', 'ge')) {
JHtml::_('behavior.framework');
}
$doc = JFactory::getDocument();
$js = "
window.addEvent('domready', function(){
setTask();
});
function setTask() {
var counter=0;
$$('#".$prefix."paramscategories option').each(function(el) {
if (el.selected){
value=el.value;
counter++;
}
});
if (counter>1 || counter==0){
$('urlparamsid').setProperty('value','');
$('urlparamstask').setProperty('value','');
$('".$prefix."paramssingleCatOrdering').setProperty('disabled', 'disabled');
enableParams();
}
if (counter==1){
$('urlparamsid').setProperty('value',value);
$('urlparamstask').setProperty('value','category');
$('".$prefix."paramssingleCatOrdering').removeProperty('disabled');
disableParams();
}
}
function disableParams(){
$('".$prefix."paramsnum_leading_items').setProperty('disabled','disabled');
$('".$prefix."paramsnum_leading_columns').setProperty('disabled','disabled');
$('".$prefix."paramsleadingImgSize').setProperty('disabled','disabled');
$('".$prefix."paramsnum_primary_items').setProperty('disabled','disabled');
$('".$prefix."paramsnum_primary_columns').setProperty('disabled','disabled');
$('".$prefix."paramsprimaryImgSize').setProperty('disabled','disabled');
$('".$prefix."paramsnum_secondary_items').setProperty('disabled','disabled');
$('".$prefix."paramsnum_secondary_columns').setProperty('disabled','disabled');
$('".$prefix."paramssecondaryImgSize').setProperty('disabled','disabled');
$('".$prefix."paramsnum_links').setProperty('disabled','disabled');
$('".$prefix."paramsnum_links_columns').setProperty('disabled','disabled');
$('".$prefix."paramslinksImgSize').setProperty('disabled','disabled');
$('".$prefix."paramscatCatalogMode').setProperty('disabled','disabled');
$('".$prefix."paramscatFeaturedItems').setProperty('disabled','disabled');
$('".$prefix."paramscatOrdering').setProperty('disabled','disabled');
$('".$prefix."paramscatPagination').setProperty('disabled','disabled');
$('".$prefix."paramscatPaginationResults0').setProperty('disabled','disabled');
$('".$prefix."paramscatPaginationResults1').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedLink0').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedLink1').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedIcon0').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedIcon1').setProperty('disabled','disabled');
$('".$prefix."paramstheme').setProperty('disabled','disabled');
}
function enableParams(){
$('".$prefix."paramsnum_leading_items').removeProperty('disabled');
$('".$prefix."paramsnum_leading_columns').removeProperty('disabled');
$('".$prefix."paramsleadingImgSize').removeProperty('disabled');
$('".$prefix."paramsnum_primary_items').removeProperty('disabled');
$('".$prefix."paramsnum_primary_columns').removeProperty('disabled');
$('".$prefix."paramsprimaryImgSize').removeProperty('disabled');
$('".$prefix."paramsnum_secondary_items').removeProperty('disabled');
$('".$prefix."paramsnum_secondary_columns').removeProperty('disabled');
$('".$prefix."paramssecondaryImgSize').removeProperty('disabled');
$('".$prefix."paramsnum_links').removeProperty('disabled');
$('".$prefix."paramsnum_links_columns').removeProperty('disabled');
$('".$prefix."paramslinksImgSize').removeProperty('disabled');
$('".$prefix."paramscatCatalogMode').removeProperty('disabled');
$('".$prefix."paramscatFeaturedItems').removeProperty('disabled');
$('".$prefix."paramscatOrdering').removeProperty('disabled');
$('".$prefix."paramscatPagination').removeProperty('disabled');
$('".$prefix."paramscatPaginationResults0').removeProperty('disabled');
$('".$prefix."paramscatPaginationResults1').removeProperty('disabled');
$('".$prefix."paramscatFeedLink0').removeProperty('disabled');
$('".$prefix."paramscatFeedLink1').removeProperty('disabled');
$('".$prefix."paramscatFeedIcon0').removeProperty('disabled');
$('".$prefix."paramscatFeedIcon1').removeProperty('disabled');
$('".$prefix."paramstheme').removeProperty('disabled');
}
";
if (K2_JVERSION != '15')
{
$js = "
function disableParams(){
$('jform_params_num_leading_items').setProperty('disabled','disabled');
$('jform_params_num_leading_columns').setProperty('disabled','disabled');
$('jform_params_leadingImgSize').setProperty('disabled','disabled');
$('jform_params_num_primary_items').setProperty('disabled','disabled');
$('jform_params_num_primary_columns').setProperty('disabled','disabled');
$('jform_params_primaryImgSize').setProperty('disabled','disabled');
$('jform_params_num_secondary_items').setProperty('disabled','disabled');
$('jform_params_num_secondary_columns').setProperty('disabled','disabled');
$('jform_params_secondaryImgSize').setProperty('disabled','disabled');
$('jform_params_num_links').setProperty('disabled','disabled');
$('jform_params_num_links_columns').setProperty('disabled','disabled');
$('jform_params_linksImgSize').setProperty('disabled','disabled');
$('jform_params_catCatalogMode').setProperty('disabled','disabled');
$('jform_params_catFeaturedItems').setProperty('disabled','disabled');
$('jform_params_catOrdering').setProperty('disabled','disabled');
$('jform_params_catPagination').setProperty('disabled','disabled');
$('jform_params_catPaginationResults0').setProperty('disabled','disabled');
$('jform_params_catPaginationResults1').setProperty('disabled','disabled');
$('jform_params_catFeedLink0').setProperty('disabled','disabled');
$('jform_params_catFeedLink1').setProperty('disabled','disabled');
$('jform_params_catFeedIcon0').setProperty('disabled','disabled');
$('jform_params_catFeedIcon1').setProperty('disabled','disabled');
$('jformparamstheme').setProperty('disabled','disabled');
}
function enableParams(){
$('jform_params_num_leading_items').removeProperty('disabled');
$('jform_params_num_leading_columns').removeProperty('disabled');
$('jform_params_leadingImgSize').removeProperty('disabled');
$('jform_params_num_primary_items').removeProperty('disabled');
$('jform_params_num_primary_columns').removeProperty('disabled');
$('jform_params_primaryImgSize').removeProperty('disabled');
$('jform_params_num_secondary_items').removeProperty('disabled');
$('jform_params_num_secondary_columns').removeProperty('disabled');
$('jform_params_secondaryImgSize').removeProperty('disabled');
$('jform_params_num_links').removeProperty('disabled');
$('jform_params_num_links_columns').removeProperty('disabled');
$('jform_params_linksImgSize').removeProperty('disabled');
$('jform_params_catCatalogMode').removeProperty('disabled');
$('jform_params_catFeaturedItems').removeProperty('disabled');
$('jform_params_catOrdering').removeProperty('disabled');
$('jform_params_catPagination').removeProperty('disabled');
$('jform_params_catPaginationResults0').removeProperty('disabled');
$('jform_params_catPaginationResults1').removeProperty('disabled');
$('jform_params_catFeedLink0').removeProperty('disabled');
$('jform_params_catFeedLink1').removeProperty('disabled');
$('jform_params_catFeedIcon0').removeProperty('disabled');
$('jform_params_catFeedIcon1').removeProperty('disabled');
$('jformparamstheme').removeProperty('disabled');
}
function setTask() {
var counter=0;
$$('#jformparamscategories option').each(function(el) {
if (el.selected){
value=el.value;
counter++;
}
});
if (counter>1 || counter==0){
$('jform_request_id').setProperty('value','');
$('jform_request_task').setProperty('value','');
$('jform_params_singleCatOrdering').setProperty('disabled', 'disabled');
enableParams();
}
if (counter==1){
$('jform_request_id').setProperty('value',value);
$('jform_request_task').setProperty('value','category');
$('jform_params_singleCatOrdering').removeProperty('disabled');
disableParams();
}
}
window.addEvent('domready', function(){
if($('request-options')) {
$$('.panel')[0].setStyle('display', 'none');
}
setTask();
});
";
}
$doc->addScriptDeclaration($js);
}
foreach ($list as $item)
{
$item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
@$mitems[] = JHTML::_('select.option', $item->id, $item->treename);
}
if (K2_JVERSION != '15')
{
$fieldName = $name.'[]';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
}
if ($name == 'categories' || $name == 'jform[params][categories]')
{
$onChange = 'onchange="setTask();"';
}
else
{
$onChange = '';
}
return JHTML::_('select.genericlist', $mitems, $fieldName, $onChange.' class="inputbox" style="width:90%;" multiple="multiple" size="15"', 'value', 'text', $value);
}
}
class JFormFieldCategory extends K2ElementCategory
{
var $type = 'category';
}
class JElementCategory extends K2ElementCategory
{
var $_name = 'category';
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementHeader extends K2Element
{
public function fetchElementValue($name, $value, &$node, $control_name)
{
if (version_compare(JVERSION, '2.5.0', 'ge'))
{
return '<div class="jwHeaderContainer"><div class="jwHeaderContent">'.JText::_($value).'</div><div class="jwHeaderClr"></div></div>';
}
else
{
return '<div class="jwHeaderContainer15"><div class="jwHeaderContent">'.JText::_($value).'</div><div class="jwHeaderClr"></div></div>';
}
}
public function fetchElementName($label, $description, &$node, $control_name, $name)
{
return NULL;
}
}
class JFormFieldHeader extends K2ElementHeader
{
var $type = 'header';
}
class JElementHeader extends K2ElementHeader
{
var $_name = 'header';
}

View File

@ -0,0 +1,100 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
// Load CSS/JS for all elements/fields
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementItem extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$document = JFactory::getDocument();
$fieldName = (K2_JVERSION != '15') ? $name : $control_name.'['.$name.']';
JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_k2/tables');
$item = JTable::getInstance('K2Item', 'Table');
if ($value)
{
$item->load($value);
}
else
{
$item->title = JText::_('K2_SELECT_AN_ITEM');
}
$document->addScriptDeclaration("
function jSelectItem(id, title, object) {
document.getElementById('".$name."' + '_id').value = id;
document.getElementById('".$name."' + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}
");
$link = 'index.php?option=com_k2&amp;view=items&amp;tmpl=component&amp;context=modalselector&amp;object='.$name;
JHTML::_('behavior.modal', 'a.modal');
if (K2_JVERSION == '30')
{
$value = (int) $value;
if(!$value) {
$value = '';
}
$class = '';
if($node->attributes()->required) {
$class = 'required ';
}
$html = '
<span class="input-append">
<input type="text" id="'.$name.'_name" value="'.htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
<a class="modal btn" title="'.JText::_('K2_SELECT_AN_ITEM').'" href="'.$link.'" rel="{handler:\'iframe\', size:{x:(document.documentElement.clientWidth)*0.96, y:(document.documentElement.clientHeight)*0.96}}">
<i class="icon-file"></i>'.JText::_('K2_SELECT').'
</a>
<input type="hidden" class="'.$class.'modal-value" id="'.$name.'_id" name="'.$fieldName.'" value="'.$value.'" />
</span>
';
}
else
{
$html = '
<div style="float:left;">
<input style="background:#fff;margin:3px 0;" type="text" id="'.$name.'_name" value="'.htmlspecialchars($item->title, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
</div>
<div class="button2-left">
<div class="blank">
<a class="modal btn" title="'.JText::_('K2_SELECT_AN_ITEM').'" href="'.$link.'" rel="{handler:\'iframe\', size:{x:(document.documentElement.clientWidth)*0.96, y:(document.documentElement.clientHeight)*0.96}}">
'.JText::_('K2_SELECT').'
</a>
</div>
</div>
<input type="hidden" id="'.$name.'_id" name="'.$fieldName.'" value="'.( int )$value.'" />
';
}
return $html;
}
}
class JFormFieldItem extends K2ElementItem
{
var $type = 'item';
}
class JElementItem extends K2ElementItem
{
var $_name = 'item';
}

View File

@ -0,0 +1,59 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementItemForm extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
if(version_compare(JVERSION, '3.5', 'ge')) {
JHtml::_('behavior.framework');
}
$document = JFactory::getDocument();
$document->addScriptDeclaration("
/* Mootools Snippet */
window.addEvent('domready', function() {
if($('request-options')) {
$$('.panel')[0].setStyle('display', 'none');
}
if($('jform_browserNav')) {
$('jform_browserNav').setProperty('value', 2);
$('jform_browserNav').getElements('option')[0].destroy();
}
if($('browserNav')) {
$('browserNav').setProperty('value', 2);
options = $('browserNav').getElements('option');
if(options.length == 3) {
options[0].remove();
}
}
});
");
return '';
}
function fetchElementName($label, $description, &$node, $control_name, $name)
{
return '';
}
}
class JFormFielditemform extends K2ElementItemForm
{
var $type = 'itemform';
}
class JElementitemform extends K2ElementItemForm
{
var $_name = 'itemform';
}

View File

@ -0,0 +1,122 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementItems extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
$params = JComponentHelper::getParams('com_k2');
$document = JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
K2HelperHTML::loadjQuery();
$mainframe = JFactory::getApplication();
if (K2_JVERSION != '15')
{
$fieldName = $name;
$attribute = K2_JVERSION == '25' ? $node->getAttribute('multiple') : $node->attributes()->multiple;
if (!$attribute)
{
$fieldName .= '[]';
}
$image = JURI::root(true).'/administrator/templates/'.$mainframe->getTemplate().'/images/admin/publish_x.png';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
$image = JURI::root(true).'/administrator/images/publish_x.png';
}
$js = "
function jSelectItem(id, title, object) {
var exists = false;
\$K2('#itemsList input').each(function(){
if(\$K2(this).val()==id){
alert('".JText::_('K2_THE_SELECTED_ITEM_IS_ALREADY_IN_THE_LIST')."');
exists = true;
}
});
if(!exists){
var container = \$K2('<li/>').appendTo(\$K2('#itemsList'));
var img = \$K2('<img/>',{'class':'remove', src:'".$image."'}).appendTo(container);
img.click(function(){\$K2(this).parent().remove();});
var span = \$K2('<span/>',{'class':'handle'}).html(title).appendTo(container);
var input = \$K2('<input/>',{value:id, type:'hidden', name:'".$fieldName."'}).appendTo(container);
var div = \$K2('<div/>',{style:'clear:both;'}).appendTo(container);
\$K2('#itemsList').sortable('refresh');
alert('".JText::_('K2_ITEM_ADDED_IN_THE_LIST', true)."');
}
}
\$K2(document).ready(function(){
\$K2('#itemsList').sortable({
containment: '#itemsList',
items: 'li',
handle: 'span.handle'
});
\$K2('#itemsList .remove').click(function(){
\$K2(this).parent().remove();
});
});
";
$document->addScriptDeclaration($js);
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.modules.css?v=2.7.1');
$current = array();
if (is_string($value) && !empty($value))
{
$current[] = $value;
}
if (is_array($value))
{
$current = $value;
}
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'tables');
$output = '<div style="clear:both"></div><ul id="itemsList">';
foreach ($current as $id)
{
$row = JTable::getInstance('K2Item', 'Table');
$row->load($id);
$output .= '
<li>
<img class="remove" src="'.$image.'" alt="'.JText::_('K2_REMOVE_ENTRY_FROM_LIST').'" />
<span class="handle">'.$row->title.'</span>
<input type="hidden" value="'.$row->id.'" name="'.$fieldName.'" />
<span style="clear:both;"></span>
</li>
';
}
$output .= '</ul>';
return $output;
}
}
class JFormFieldItems extends K2ElementItems
{
var $type = 'items';
}
class JElementItems extends K2ElementItems
{
var $_name = 'items';
}

View File

@ -0,0 +1,257 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2Category extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$db = JFactory::getDbo();
$query = 'SELECT m.* FROM #__k2_categories m WHERE 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();
$option = JRequest::getCmd('option');
$prefix = ($option == 'com_joomfish') ? 'refField_' : '';
if ($name == 'categories' || $name == 'jform[params][categories]')
{
if(version_compare(JVERSION, '3.5', 'ge')) {
JHtml::_('behavior.framework');
}
$doc = JFactory::getDocument();
$js = "
/* Mootools Snippet */
window.addEvent('domready', function(){
setTask();
});
function setTask() {
var counter=0;
$$('#".$prefix."paramscategories option').each(function(el) {
if (el.selected){
value=el.value;
counter++;
}
});
if (counter>1 || counter==0){
$('urlparamsid').setProperty('value','');
$('urlparamstask').setProperty('value','');
$('".$prefix."paramssingleCatOrdering').setProperty('disabled', 'disabled');
enableParams();
}
if (counter==1){
$('urlparamsid').setProperty('value',value);
$('urlparamstask').setProperty('value','category');
$('".$prefix."paramssingleCatOrdering').removeProperty('disabled');
disableParams();
}
}
function disableParams(){
$('".$prefix."paramsnum_leading_items').setProperty('disabled','disabled');
$('".$prefix."paramsnum_leading_columns').setProperty('disabled','disabled');
$('".$prefix."paramsleadingImgSize').setProperty('disabled','disabled');
$('".$prefix."paramsnum_primary_items').setProperty('disabled','disabled');
$('".$prefix."paramsnum_primary_columns').setProperty('disabled','disabled');
$('".$prefix."paramsprimaryImgSize').setProperty('disabled','disabled');
$('".$prefix."paramsnum_secondary_items').setProperty('disabled','disabled');
$('".$prefix."paramsnum_secondary_columns').setProperty('disabled','disabled');
$('".$prefix."paramssecondaryImgSize').setProperty('disabled','disabled');
$('".$prefix."paramsnum_links').setProperty('disabled','disabled');
$('".$prefix."paramsnum_links_columns').setProperty('disabled','disabled');
$('".$prefix."paramslinksImgSize').setProperty('disabled','disabled');
$('".$prefix."paramscatCatalogMode').setProperty('disabled','disabled');
$('".$prefix."paramscatFeaturedItems').setProperty('disabled','disabled');
$('".$prefix."paramscatOrdering').setProperty('disabled','disabled');
$('".$prefix."paramscatPagination').setProperty('disabled','disabled');
$('".$prefix."paramscatPaginationResults0').setProperty('disabled','disabled');
$('".$prefix."paramscatPaginationResults1').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedLink0').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedLink1').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedIcon0').setProperty('disabled','disabled');
$('".$prefix."paramscatFeedIcon1').setProperty('disabled','disabled');
$('".$prefix."paramstheme').setProperty('disabled','disabled');
}
function enableParams(){
$('".$prefix."paramsnum_leading_items').removeProperty('disabled');
$('".$prefix."paramsnum_leading_columns').removeProperty('disabled');
$('".$prefix."paramsleadingImgSize').removeProperty('disabled');
$('".$prefix."paramsnum_primary_items').removeProperty('disabled');
$('".$prefix."paramsnum_primary_columns').removeProperty('disabled');
$('".$prefix."paramsprimaryImgSize').removeProperty('disabled');
$('".$prefix."paramsnum_secondary_items').removeProperty('disabled');
$('".$prefix."paramsnum_secondary_columns').removeProperty('disabled');
$('".$prefix."paramssecondaryImgSize').removeProperty('disabled');
$('".$prefix."paramsnum_links').removeProperty('disabled');
$('".$prefix."paramsnum_links_columns').removeProperty('disabled');
$('".$prefix."paramslinksImgSize').removeProperty('disabled');
$('".$prefix."paramscatCatalogMode').removeProperty('disabled');
$('".$prefix."paramscatFeaturedItems').removeProperty('disabled');
$('".$prefix."paramscatOrdering').removeProperty('disabled');
$('".$prefix."paramscatPagination').removeProperty('disabled');
$('".$prefix."paramscatPaginationResults0').removeProperty('disabled');
$('".$prefix."paramscatPaginationResults1').removeProperty('disabled');
$('".$prefix."paramscatFeedLink0').removeProperty('disabled');
$('".$prefix."paramscatFeedLink1').removeProperty('disabled');
$('".$prefix."paramscatFeedIcon0').removeProperty('disabled');
$('".$prefix."paramscatFeedIcon1').removeProperty('disabled');
$('".$prefix."paramstheme').removeProperty('disabled');
}
";
if (K2_JVERSION != '15')
{
$js = "
/* Mootools Snippet */
function disableParams(){
$('jform_params_num_leading_items').setProperty('disabled','disabled');
$('jform_params_num_leading_columns').setProperty('disabled','disabled');
$('jform_params_leadingImgSize').setProperty('disabled','disabled');
$('jform_params_num_primary_items').setProperty('disabled','disabled');
$('jform_params_num_primary_columns').setProperty('disabled','disabled');
$('jform_params_primaryImgSize').setProperty('disabled','disabled');
$('jform_params_num_secondary_items').setProperty('disabled','disabled');
$('jform_params_num_secondary_columns').setProperty('disabled','disabled');
$('jform_params_secondaryImgSize').setProperty('disabled','disabled');
$('jform_params_num_links').setProperty('disabled','disabled');
$('jform_params_num_links_columns').setProperty('disabled','disabled');
$('jform_params_linksImgSize').setProperty('disabled','disabled');
$('jform_params_catCatalogMode').setProperty('disabled','disabled');
$('jform_params_catFeaturedItems').setProperty('disabled','disabled');
$('jform_params_catOrdering').setProperty('disabled','disabled');
$('jform_params_catPagination').setProperty('disabled','disabled');
$('jform_params_catPaginationResults0').setProperty('disabled','disabled');
$('jform_params_catPaginationResults1').setProperty('disabled','disabled');
$('jform_params_catFeedLink0').setProperty('disabled','disabled');
$('jform_params_catFeedLink1').setProperty('disabled','disabled');
$('jform_params_catFeedIcon0').setProperty('disabled','disabled');
$('jform_params_catFeedIcon1').setProperty('disabled','disabled');
$('jformparamstheme').setProperty('disabled','disabled');
}
function enableParams(){
$('jform_params_num_leading_items').removeProperty('disabled');
$('jform_params_num_leading_columns').removeProperty('disabled');
$('jform_params_leadingImgSize').removeProperty('disabled');
$('jform_params_num_primary_items').removeProperty('disabled');
$('jform_params_num_primary_columns').removeProperty('disabled');
$('jform_params_primaryImgSize').removeProperty('disabled');
$('jform_params_num_secondary_items').removeProperty('disabled');
$('jform_params_num_secondary_columns').removeProperty('disabled');
$('jform_params_secondaryImgSize').removeProperty('disabled');
$('jform_params_num_links').removeProperty('disabled');
$('jform_params_num_links_columns').removeProperty('disabled');
$('jform_params_linksImgSize').removeProperty('disabled');
$('jform_params_catCatalogMode').removeProperty('disabled');
$('jform_params_catFeaturedItems').removeProperty('disabled');
$('jform_params_catOrdering').removeProperty('disabled');
$('jform_params_catPagination').removeProperty('disabled');
$('jform_params_catPaginationResults0').removeProperty('disabled');
$('jform_params_catPaginationResults1').removeProperty('disabled');
$('jform_params_catFeedLink0').removeProperty('disabled');
$('jform_params_catFeedLink1').removeProperty('disabled');
$('jform_params_catFeedIcon0').removeProperty('disabled');
$('jform_params_catFeedIcon1').removeProperty('disabled');
$('jformparamstheme').removeProperty('disabled');
}
function setTask() {
var counter=0;
$$('#jformparamscategories option').each(function(el) {
if (el.selected){
value=el.value;
counter++;
}
});
if (counter>1 || counter==0){
$('jform_request_id').setProperty('value','');
$('jform_request_task').setProperty('value','');
$('jform_params_singleCatOrdering').setProperty('disabled', 'disabled');
enableParams();
}
if (counter==1){
$('jform_request_id').setProperty('value',value);
$('jform_request_task').setProperty('value','category');
$('jform_params_singleCatOrdering').removeProperty('disabled');
disableParams();
}
}
window.addEvent('domready', function(){
if($('request-options')) {
$$('.panel')[0].setStyle('display', 'none');
}
setTask();
});
";
}
$doc->addScriptDeclaration($js);
}
foreach ($list as $item)
{
$item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
@$mitems[] = JHTML::_('select.option', $item->id, $item->treename);
}
if (K2_JVERSION != '15')
{
$fieldName = $name.'[]';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
}
if ($name == 'categories' || $name == 'jform[params][categories]')
{
$onChange = 'onchange="setTask();"';
}
else
{
$onChange = '';
}
return JHTML::_('select.genericlist', $mitems, $fieldName, $onChange.' class="inputbox" multiple="multiple" size="15"', 'value', 'text', $value);
}
}
class JFormFieldK2Category extends K2ElementK2Category
{
var $type = 'k2category';
}
class JElementK2Category extends K2ElementK2Category
{
var $_name = 'k2category';
}

View File

@ -0,0 +1,210 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2modalselector extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
JTable::addIncludePath(JPATH_ADMINISTRATOR.'/components/com_k2/tables');
// Attributes
$fieldID = 'fieldID_'.md5($name);
if (version_compare(JVERSION, '1.5.0', 'gt'))
{
if($node->attributes()->scope)
{
$scope = $node->attributes()->scope;
}
else
{
$scope = 'items';
}
if($scope == 'items' || $scope == 'categories' || $scope == 'users' || $scope == 'tags')
{
$fieldName = $name.'[]';
}
else
{
$fieldName = $name;
}
}
else
{
if($node->attributes('scope')){
$scope = $node->attributes('scope');
}
else
{
$scope = 'items';
}
if($scope == 'items' || $scope == 'categories' || $scope == 'users' || $scope == 'tags')
{
$fieldName = $control_name.'['.$name.'][]';
}
else
{
$fieldName = $control_name.'['.$name.']';
}
}
if(!$value)
{
$value = '';
}
$saved = array();
if (is_string($value) && !empty($value))
{
$saved[] = $value;
}
if (is_array($value))
{
$saved = $value;
}
// Output
$output = '';
// Output for lists
if($scope == 'items' || $scope == 'categories' || $scope == 'users' || $scope == 'tags')
{
$output = '
<div class="k2SelectorButton">
<a data-k2-modal="iframe" class="btn" title="'.JText::_('K2_SELECT').'" href="index.php?option=com_k2&view='.$scope.'&tmpl=component&context=modalselector&output=list&fid='.$fieldID.'&fname='.$fieldName.'">
<i class="fa fa-file-text-o"></i> '.JText::_('K2_SELECT').'
</a>
</div>
<ul id="'.$fieldID.'" class="k2SortableListContainer">
';
foreach ($saved as $value)
{
if($scope == 'items')
{
$row = JTable::getInstance('K2Item', 'Table');
$row->load($value);
$entryName = $row->title;
$entryValue = $row->id;
}
if($scope == 'categories')
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($value);
$entryName = $row->name;
$entryValue = $row->id;
}
if($scope == 'users')
{
$row = JFactory::getUser($value);
$entryName = $row->name;
$entryValue = $row->id;
}
if($scope == 'tags')
{
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__k2_tags WHERE name='.$db->Quote($value);
$db->setQuery($query);
$row = $db->loadObject();
$entryName = $row->name;
$entryValue = htmlspecialchars($row->name, ENT_QUOTES, 'utf-8');
}
$output .= '<li class="handle"><a class="k2EntryRemove" href="#" title="'.JText::_('K2_REMOVE_THIS_ENTRY').'"><i class="fa fa-trash-o"></i></a><span class="k2EntryText">'.$entryName.'</span><input type="hidden" id="'.$fieldID.'" name="'.$fieldName.'" value="'.$entryValue.'" /></li>';
}
$output .= '
</ul>
';
}
// Output for single entities
if($scope == 'item' || $scope == 'category' || $scope == 'user' || $scope == 'tag')
{
if(count($saved)) $value = $saved[0]; else $value = '';
if($scope == 'item')
{
if($value)
{
$row = JTable::getInstance('K2Item', 'Table');
$row->load($value);
$entryName = $row->title;
$entryValue = $row->id;
}
$view = "items";
}
if($scope == 'category')
{
if($value)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($value);
$entryName = $row->name;
$entryValue = $row->id;
}
$view = "categories";
}
if($scope == 'user')
{
if($value)
{
$row = JFactory::getUser($value);
$entryName = $row->name;
$entryValue = $row->id;
}
$view = "users";
}
if($scope == 'tag')
{
if($value)
{
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__k2_tags WHERE name='.$db->Quote($value);
$db->setQuery($query);
$row = $db->loadObject();
$entryName = $row->name;
$entryValue = htmlspecialchars($row->name, ENT_QUOTES, 'utf-8');
}
$view = "tags";
}
$output = '
<div class="k2SelectorButton k2SingleSelect">
<a data-k2-modal="iframe" class="btn" title="'.JText::_('K2_SELECT').'" href="index.php?option=com_k2&view='.$view.'&tmpl=component&context=modalselector&fid='.$fieldID.'&fname='.$fieldName.'">
<i class="fa fa-file-text-o"></i> '.JText::_('K2_SELECT').'
</a>
</div>
<div id="'.$fieldID.'" class="k2SingleSelect">
';
if($value)
{
$output .= '<span class="k2EntryText">'.$entryName.'</span><input type="hidden" id="'.$fieldID.'" name="'.$fieldName.'" value="'.$entryValue.'" />';
}
$output .= '
</div>
';
}
return $output;
}
}
class JFormFieldK2modalselector extends K2ElementK2modalselector
{
var $type = 'k2modalselector';
}
class JElementK2modalselector extends K2ElementK2modalselector
{
var $_name = 'k2modalselector';
}

View File

@ -0,0 +1,89 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2Tag extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$doc = JFactory::getDocument();
$fieldName = (K2_JVERSION != '15') ? $name : $control_name.'['.$name.']';
JTable::addIncludePath(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_k2'.DS.'tables');
$tag = JTable::getInstance('K2Tag', 'Table');
if ($value)
{
$db = JFactory::getDBO();
$query = "SELECT * FROM #__k2_tags WHERE name=".$db->Quote($value);
$db->setQuery($query);
$tag = $db->loadObject();
}
if (is_null($tag))
{
$tag = new stdClass;
$tag->name = JText::_('K2_SELECT_A_TAG');
}
// Move this to main JS file
$js = "
function jSelectTag(id, title, object) {
document.getElementById('".$name."' + '_id').value = id;
document.getElementById('".$name."' + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}
";
$doc->addScriptDeclaration($js);
$link = 'index.php?option=com_k2&amp;view=tags&amp;task=element&amp;tmpl=component&amp;object='.$name;
JHTML::_('behavior.modal', 'a.modal');
if (K2_JVERSION == '30')
{
$html = '<span class="input-append">
<input type="text" id="'.$name.'_name" value="'.htmlspecialchars($tag->name, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
<a class="modal btn" title="'.JText::_('K2_SELECT_A_TAG').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 700, y: 450}}"><i class="icon-file"></i>'.JText::_('K2_SELECT').'</a>
<input type="hidden" class="required modal-value" id="'.$name.'_id" name="'.$fieldName.'" value="'.$value.'" />
</span>';
}
else
{
$html = '
<div style="float:left;">
<input style="background:#fff;margin:3px 0;" type="text" id="'.$name.'_name" value="'.htmlspecialchars($tag->name, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
</div>
<div class="button2-left">
<div class="blank">
<a class="modal" title="'.JText::_('K2_SELECT_A_TAG').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">'.JText::_('K2_SELECT').'</a>
</div>
</div>
<input type="hidden" id="'.$name.'_id" name="'.$fieldName.'" value="'.$value.'" />
';
}
return $html;
}
}
class JFormFieldK2Tag extends K2ElementK2Tag
{
var $type = 'k2tag';
}
class JElementK2Tag extends K2ElementK2Tag
{
var $_name = 'k2tag';
}

View File

@ -0,0 +1,78 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2Tags extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$fieldName = (K2_JVERSION != '15') ? $name.'[]' : $control_name.'['.$name.'][]';
$document = JFactory::getDocument();
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js');
$document->addScriptDeclaration('
$K2(document).ready(function() {
if(typeof($K2(".k2TagsElement").chosen) == "function") {
$K2(".k2TagsElement").chosen("destroy");
}
$K2(".k2TagsElement").select2({
width : "300px",
minimumInputLength : 2,
ajax: {
dataType : "json",
url: "'.JURI::root(true).'/administrator/index.php?option=com_k2&view=item&task=tags&id=1",
cache: "true",
data: function (params) {
var queryParameters = {q: params.term};
return queryParameters;
},
processResults: function (data) {
var results = [];
jQuery.each(data, function(index, value) {
var row = {
id : value.id,
text : value.name
};
results.push(row);
});
return {results: results};
}
}
});
});
');
$options = array();
if(is_array($value) && count($value))
{
$db = JFactory::getDbo();
$query = "SELECT id AS value, name AS text FROM #__k2_tags WHERE id IN(".implode(',', $value).")";
$db->setQuery($query);
$options = $db->loadObjectList();
}
return JHTML::_('select.genericlist', $options, $fieldName, 'class="k2TagsElement" multiple="multiple" size="15"', 'value', 'text', $value);
}
}
class JFormFieldK2Tags extends K2ElementK2Tags
{
var $type = 'k2tags';
}
class JElementK2Tags extends K2ElementK2Tags
{
var $_name = 'k2tags';
}

View File

@ -0,0 +1,67 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2textarea extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
// Attributes
if (version_compare(JVERSION, '1.5.0', 'gt'))
{
$fieldName = $name;
if($node->attributes()->chars)
{
$chars = $node->attributes()->chars;
}
if($node->attributes()->cols)
{
$cols = $node->attributes()->cols;
}
if($node->attributes()->rows)
{
$rows = $node->attributes()->rows;
}
}
else
{
$fieldName = $control_name.'['.$name.']';
if($node->attributes('chars')){
$chars = $node->attributes('chars');
}
if($node->attributes('cols')){
$cols = $node->attributes('cols');
}
if($node->attributes('rows')){
$rows = $node->attributes('rows');
}
}
if(!$value)
{
$value = '';
}
// Output
return '<textarea name="'.$fieldName.'" rows="'.$rows.'" cols="'.$cols.'" data-k2-chars="'.$chars.'">'.$value.'</textarea>';
}
}
class JFormFieldK2textarea extends K2ElementK2textarea
{
var $type = 'k2textarea';
}
class JElementK2textarea extends K2ElementK2textarea
{
var $_name = 'k2textarea';
}

View File

@ -0,0 +1,84 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2User extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$doc = JFactory::getDocument();
$fieldName = (K2_JVERSION != '15') ? $name : $control_name.'['.$name.']';
if ($value)
{
$user = JFactory::getUser($value);
}
else
{
$user = new stdClass;
$user->name = JText::_('K2_SELECT_A_USER');
}
// Move this to main JS file
$js = "
function jSelectUser(id, title, object) {
document.getElementById('".$name."' + '_id').value = id;
document.getElementById('".$name."' + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}
";
$doc->addScriptDeclaration($js);
$link = 'index.php?option=com_k2&amp;view=users&amp;task=element&amp;tmpl=component&amp;object='.$name;
JHTML::_('behavior.modal', 'a.modal');
if (K2_JVERSION == '30')
{
$html = '<span class="input-append">
<input type="text" id="'.$name.'_name" value="'.htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
<a class="modal btn" title="'.JText::_('K2_SELECT_A_USER').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 700, y: 450}}"><i class="icon-file"></i>'.JText::_('K2_SELECT').'</a>
<input type="hidden" class="required modal-value" id="'.$name.'_id" name="'.$fieldName.'" value="'.(int)$value.'" />
</span>';
}
else
{
$html = '
<div style="float:left;">
<input style="background:#fff;margin:3px 0;" type="text" id="'.$name.'_name" value="'.htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
</div>
<div class="button2-left">
<div class="blank">
<a class="modal" title="'.JText::_('K2_SELECT_A_USER').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">'.JText::_('K2_SELECT').'</a>
</div>
</div>
<input type="hidden" id="'.$name.'_id" name="'.$fieldName.'" value="'.(int)$value.'" />
';
}
return $html;
}
}
class JFormFieldK2User extends K2ElementK2User
{
var $type = 'k2user';
}
class JElementK2User extends K2ElementK2User
{
var $_name = 'k2user';
}

View File

@ -0,0 +1,78 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementK2Users extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$fieldName = (K2_JVERSION != '15') ? $name.'[]' : $control_name.'['.$name.'][]';
$document = JFactory::getDocument();
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/css/select2.min.css');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.3/js/select2.min.js');
$document->addScriptDeclaration('
$K2(document).ready(function() {
if(typeof($K2(".k2UsersElement").chosen) == "function") {
$K2(".k2UsersElement").chosen("destroy");
}
$K2(".k2UsersElement").select2({
width : "300px",
minimumInputLength : 2,
ajax: {
dataType : "json",
url: "'.JURI::root(true).'/administrator/index.php?option=com_k2&view=users&task=search&format=raw",
cache: "true",
data: function (params) {
var queryParameters = {q: params.term};
return queryParameters;
},
processResults: function (data) {
var results = [];
jQuery.each(data, function(index, value) {
var row = {
id : value.id,
text : value.name
};
results.push(row);
});
return {results: results};
}
}
});
});
');
$options = array();
if(is_array($value) && count($value))
{
$db = JFactory::getDbo();
$query = "SELECT id AS value, name AS text FROM #__users WHERE id IN(".implode(',', $value).")";
$db->setQuery($query);
$options = $db->loadObjectList();
}
return JHTML::_('select.genericlist', $options, $fieldName, 'class="k2UsersElement" multiple="multiple" size="15"', 'value', 'text', $value);
}
}
class JFormFieldK2Users extends K2ElementK2Users
{
var $type = 'k2users';
}
class JElementK2Users extends K2ElementK2Users
{
var $_name = 'k2users';
}

View File

@ -0,0 +1,150 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// Check to ensure this file is within the rest of the framework
defined('JPATH_BASE') or die();
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementMenuItem extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$db = JFactory::getDbo();
// load the list of menu types
// TODO: move query to model
$query = 'SELECT menutype, title'.' FROM #__menu_types'.' ORDER BY title';
$db->setQuery($query);
$menuTypes = $db->loadObjectList();
$where = '';
if ($state = $node->attributes('state'))
{
$where .= ' AND published = '.(int)$state;
}
// load the list of menu items
// TODO: move query to model
if (K2_JVERSION != '15')
{
$query = 'SELECT id, parent_id, title, menutype, type, published'.' FROM #__menu'.$where.' ORDER BY menutype, parent_id, ordering';
}
else
{
$query = 'SELECT id, parent, name, menutype, type, published'.' FROM #__menu'.$where.' ORDER BY menutype, parent, ordering';
}
$db->setQuery($query);
$menuItems = $db->loadObjectList();
// establish the hierarchy of the menu
// TODO: use node model
$children = array();
if ($menuItems)
{
// first pass - collect children
foreach ($menuItems as $v)
{
if (K2_JVERSION != '15')
{
$v->parent = $v->parent_id;
$v->name = $v->title;
}
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
// second pass - get an indent list of the items
$list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0);
foreach ($list as $item)
{
$item->treename = JString::str_ireplace('&#160;', ' -', $item->treename);
$mitems[] = JHTML::_('select.option', $item->id, ' '.$item->treename);
}
// assemble into menutype groups
$n = count($list);
$groupedList = array();
foreach ($list as $k => $v)
{
$groupedList[$v->menutype][] = &$list[$k];
}
// assemble menu items to the array
$options = array();
$options[] = JHTML::_('select.option', '', '- '.JText::_('K2_SELECT_MENU_ITEM').' -');
foreach ($menuTypes as $type)
{
if ($type != '')
{
$options[] = JHTML::_('select.option', '0', '&nbsp;', 'value', 'text', true);
$options[] = JHTML::_('select.option', $type->menutype, $type->title.' - '.JText::_('K2_TOP'), 'value', 'text', true);
}
if (isset($groupedList[$type->menutype]))
{
$n = count($groupedList[$type->menutype]);
for ($i = 0; $i < $n; $i++)
{
$item = &$groupedList[$type->menutype][$i];
//If menutype is changed but item is not saved yet, use the new type in the list
if (JRequest::getString('option', '', 'get') == 'com_menus')
{
$currentItemArray = JRequest::getVar('cid', array(0), '', 'array');
$currentItemId = (int)$currentItemArray[0];
$currentItemType = JRequest::getString('type', $item->type, 'get');
if ($currentItemId == $item->id && $currentItemType != $item->type)
{
$item->type = $currentItemType;
}
}
$disable = @strpos($node->attributes('disable'), $item->type) !== false ? true : false;
if ($item->published == 0)
$item->treename .= ' [**'.JText::_('K2_UNPUBLISHED').'**]';
if ($item->published == -2)
$item->treename .= ' [**'.JText::_('K2_TRASHED').'**]';
$options[] = JHTML::_('select.option', $item->id, $item->treename, 'value', 'text', $disable);
}
}
}
if (K2_JVERSION != '15')
{
$fieldName = $name;
}
else
{
$fieldName = $control_name.'['.$name.']';
}
return JHTML::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value, $control_name.$name);
}
}
class JFormFieldMenuItem extends K2ElementMenuItem
{
var $type = 'MenuItem';
}
class JElementMenuItem extends K2ElementMenuItem
{
var $_name = 'MenuItem';
}

View File

@ -0,0 +1,42 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementMenus extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
$fieldName = (K2_JVERSION != '15') ? $name : $control_name.'['.$name.']';
$db = JFactory::getDbo();
$query = "SELECT menutype, title FROM #__menu_types";
$db->setQuery($query);
$menus = $db->loadObjectList();
$options = array();
$options[] = JHTML::_('select.option', '', JText::_('K2_NONE_ONSELECTLISTS'));
foreach ($menus as $menu)
{
$options[] = JHTML::_('select.option', $menu->menutype, $menu->title);
}
return JHTML::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value);
}
}
class JFormFieldMenus extends K2ElementMenus
{
var $type = 'menus';
}
class JElementMenus extends K2ElementMenus
{
var $_name = 'menus';
}

View File

@ -0,0 +1,90 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementModuleTemplate extends K2Element
{
function fetchElementValue($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
if (K2_JVERSION != '15')
{
$moduleName = $node->attributes()->modulename;
}
else
{
$moduleName = $node->_attributes['modulename'];
}
$moduleTemplatesPath = JPATH_SITE.'/modules/'.$moduleName.'/tmpl';
$moduleTemplatesFolders = JFolder::folders($moduleTemplatesPath);
$db = JFactory::getDbo();
if (K2_JVERSION != '15')
{
$query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1";
}
else
{
$query = "SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0";
}
$db->setQuery($query);
$defaultemplate = $db->loadResult();
$templatePath = JPATH_SITE.'/templates/'.$defaultemplate.'/html/'.$moduleName;
if (JFolder::exists($templatePath))
{
$templateFolders = JFolder::folders($templatePath);
$folders = @array_merge($templateFolders, $moduleTemplatesFolders);
$folders = @array_unique($folders);
}
else
{
$folders = $moduleTemplatesFolders;
}
$exclude = 'Default';
$options = array();
foreach ($folders as $folder)
{
if (preg_match(chr(1).$exclude.chr(1), $folder))
{
continue;
}
$options[] = JHTML::_('select.option', $folder, $folder);
}
array_unshift($options, JHTML::_('select.option', 'Default', '-- '.JText::_('K2_USE_DEFAULT').' --'));
if (K2_JVERSION != '15')
{
$fieldName = $name;
}
else
{
$fieldName = $control_name.'['.$name.']';
}
return JHTML::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value, $control_name.$name);
}
}
class JFormFieldModuleTemplate extends K2ElementModuleTemplate
{
var $type = 'moduletemplate';
}
class JElementModuleTemplate extends K2ElementModuleTemplate
{
var $_name = 'moduletemplate';
}

View File

@ -0,0 +1,81 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementTemplate extends K2Element
{
public function fetchElementValue($name, $value, &$node, $control_name)
{
jimport('joomla.filesystem.folder');
$application = JFactory::getApplication();
$fieldName = (K2_JVERSION != '15') ? $name : $control_name.'['.$name.']';
$componentPath = JPATH_SITE.'/components/com_k2/templates';
$componentFolders = JFolder::folders($componentPath);
$db = JFactory::getDbo();
if (K2_JVERSION != '15')
{
$query = "SELECT template FROM #__template_styles WHERE client_id = 0 AND home = 1";
}
else
{
$query = "SELECT template FROM #__templates_menu WHERE client_id = 0 AND menuid = 0";
}
$db->setQuery($query);
$defaultemplate = $db->loadResult();
if (JFolder::exists(JPATH_SITE.'/templates/'.$defaultemplate.'/html/com_k2/templates'))
{
$templatePath = JPATH_SITE.'/templates/'.$defaultemplate.'/html/com_k2/templates';
}
else
{
$templatePath = JPATH_SITE.'/templates/'.$defaultemplate.'/html/com_k2';
}
if (JFolder::exists($templatePath))
{
$templateFolders = JFolder::folders($templatePath);
$folders = @array_merge($templateFolders, $componentFolders);
$folders = @array_unique($folders);
}
else
{
$folders = $componentFolders;
}
$exclude = 'default';
$options = array();
foreach ($folders as $folder)
{
if (preg_match(chr(1).$exclude.chr(1), $folder))
{
continue;
}
$options[] = JHTML::_('select.option', $folder, $folder);
}
array_unshift($options, JHTML::_('select.option', '', '-- '.JText::_('K2_USE_DEFAULT').' --'));
return JHTML::_('select.genericlist', $options, $fieldName, 'class="inputbox"', 'value', 'text', $value, $control_name.$name);
}
}
class JFormFieldTemplate extends K2ElementTemplate
{
var $type = 'template';
}
class JElementTemplate extends K2ElementTemplate
{
var $_name = 'template';
}

View File

@ -0,0 +1,84 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementUser extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
$mainframe = JFactory::getApplication();
$db = JFactory::getDBO();
$doc = JFactory::getDocument();
$fieldName = (K2_JVERSION != '15') ? $name : $control_name.'['.$name.']';
if ($value)
{
$user = JFactory::getUser($value);
}
else
{
$user = new stdClass;
$user->name = JText::_('K2_SELECT_A_USER');
}
// Move this to main JS file
$js = "
function jSelectUser(id, title, object) {
document.getElementById('".$name."' + '_id').value = id;
document.getElementById('".$name."' + '_name').value = title;
if(typeof(window.parent.SqueezeBox.close=='function')){
window.parent.SqueezeBox.close();
}
else {
document.getElementById('sbox-window').close();
}
}
";
$doc->addScriptDeclaration($js);
$link = 'index.php?option=com_k2&amp;view=users&amp;task=element&amp;tmpl=component&amp;object='.$name;
JHTML::_('behavior.modal', 'a.modal');
if (K2_JVERSION == '30')
{
$html = '<span class="input-append">
<input type="text" id="'.$name.'_name" value="'.htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
<a class="modal btn" title="'.JText::_('K2_SELECT_A_USER').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 700, y: 450}}"><i class="icon-file"></i>'.JText::_('K2_SELECT').'</a>
<input type="hidden" class="required modal-value" id="'.$name.'_id" name="'.$fieldName.'" value="'.(int)$value.'" />
</span>';
}
else
{
$html = '
<div style="float:left;">
<input style="background:#fff;margin:3px 0;" type="text" id="'.$name.'_name" value="'.htmlspecialchars($user->name, ENT_QUOTES, 'UTF-8').'" disabled="disabled" />
</div>
<div class="button2-left">
<div class="blank">
<a class="modal" title="'.JText::_('K2_SELECT_A_USER').'" href="'.$link.'" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">'.JText::_('K2_SELECT').'</a>
</div>
</div>
<input type="hidden" id="'.$name.'_id" name="'.$fieldName.'" value="'.(int)$value.'" />
';
}
return $html;
}
}
class JFormFieldUser extends K2ElementUser
{
var $type = 'k2user';
}
class JElementHeader extends K2ElementUser
{
var $_name = 'k2user';
}

View File

@ -0,0 +1,121 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementUsers extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
JHTML::_('behavior.modal');
$params = JComponentHelper::getParams('com_k2');
$document = JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
K2HelperHTML::loadjQuery();
$mainframe = JFactory::getApplication();
if (K2_JVERSION != '15')
{
$fieldName = $name;
if (!$node->attributes('multiple'))
{
$fieldName .= '[]';
}
$image = JURI::root(true).'/administrator/templates/'.$mainframe->getTemplate().'/images/admin/publish_x.png';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
$image = JURI::root(true).'/administrator/images/publish_x.png';
}
$js = "
function jSelectUser(id, title, object) {
var exists = false;
\$K2('#usersList input').each(function(){
if(\$K2(this).val()==id){
alert('".JText::_('K2_THE_SELECTED_USER_IS_ALREADY_IN_THE_LIST', true)."');
exists = true;
}
});
if(!exists){
var container = \$K2('<li/>').appendTo(\$K2('#usersList'));
var img = \$K2('<img/>',{'class':'remove', src:'".$image."'}).appendTo(container);
img.click(function(){\$K2(this).parent().remove();});
var span = \$K2('<span/>',{'class':'handle'}).html(title).appendTo(container);
var input = \$K2('<input/>',{value:id, type:'hidden', name:'".$fieldName."'}).appendTo(container);
var div = \$K2('<div/>',{style:'clear:both;'}).appendTo(container);
\$K2('#usersList').sortable('refresh');
alert('".JText::_('K2_USER_ADDED_IN_THE_LIST', true)."');
}
}
\$K2(document).ready(function(){
\$K2('#usersList').sortable({
containment: '#usersList',
items: 'li',
handle: 'span.handle'
});
\$K2('#usersList .remove').click(function(){
\$K2(this).parent().remove();
});
});
";
$document->addScriptDeclaration($js);
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.modules.css?v=2.7.1');
$current = array();
if (is_string($value) && !empty($value))
{
$current[] = $value;
}
if (is_array($value))
{
$current = $value;
}
$output = '<ul id="usersList">';
foreach ($current as $id)
{
$row = JFactory::getUser($id);
$output .= '
<li>
<img class="remove" src="'.$image.'" alt="'.JText::_('K2_REMOVE_ENTRY_FROM_LIST').'" />
<span class="handle">'.$row->name.'</span>
<input type="hidden" value="'.$row->id.'" name="'.$fieldName.'" />
<div style="clear:both;"></div>
</li>
';
}
$output .= '</ul>';
return $output;
}
}
class JFormFieldUsers extends K2ElementUsers
{
var $type = 'users';
}
class JElementUsers extends K2ElementUsers
{
var $_name = 'users';
}

View File

@ -0,0 +1,132 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
require_once (JPATH_ADMINISTRATOR.'/components/com_k2/elements/base.php');
class K2ElementUsersLatest extends K2Element
{
function fetchElement($name, $value, &$node, $control_name)
{
JHTML::_('behavior.modal');
$params = JComponentHelper::getParams('com_k2');
$document = JFactory::getDocument();
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
K2HelperHTML::loadjQuery();
$mainframe = JFactory::getApplication();
if (K2_JVERSION != '15')
{
$fieldName = $name;
if (!$node->attributes('multiple'))
{
$fieldName .= '[]';
}
$image = JURI::root(true).'/administrator/templates/'.$mainframe->getTemplate().'/images/admin/publish_x.png';
}
else
{
$fieldName = $control_name.'['.$name.'][]';
$image = JURI::root(true).'/administrator/images/publish_x.png';
}
$js = "
function jSelectUser(id, title, object) {
var exists = false;
\$K2('#usersList input').each(function(){
if(\$K2(this).val()==id){
alert('".JText::_('K2_THE_SELECTED_USER_IS_ALREADY_IN_THE_LIST', true)."');
exists = true;
}
});
if(!exists){
var container = \$K2('<li/>').appendTo(\$K2('#usersList'));
var img = \$K2('<img/>',{'class':'remove', src:'".$image."'}).appendTo(container);
img.click(function(){\$K2(this).parent().remove();});
var span = \$K2('<span/>',{'class':'handle'}).html(title).appendTo(container);
var input = \$K2('<input/>',{value:id, type:'hidden', name:'".$fieldName."'}).appendTo(container);
var div = \$K2('<div/>',{style:'clear:both;'}).appendTo(container);
\$K2('#usersList').sortable('refresh');
alert('".JText::_('K2_USER_ADDED_IN_THE_LIST', true)."');
}
}
\$K2(document).ready(function(){
\$K2('#usersList').sortable({
containment: '#usersList',
items: 'li',
handle: 'span.handle'
});
\$K2('#usersList .remove').click(function(){
\$K2(this).parent().remove();
});
});
";
$document->addScriptDeclaration($js);
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.modules.css?v=2.7.1');
$current = array();
if (is_string($value) && !empty($value))
{
$current[] = $value;
}
if (is_array($value))
{
$current = $value;
}
$output = '
<div class="button2-left">
<div class="blank">
<a class="modal btn" title="'.JText::_('K2_CLICK_TO_SELECT_ONE_OR_MORE_USERS').'" href="index.php?option=com_k2&view=users&task=element&tmpl=component" rel="{handler: \'iframe\', size: {x: 700, y: 450}}">'.JText::_('K2_CLICK_TO_SELECT_ONE_OR_MORE_USERS').'</a>
</div>
</div>
<div style="clear:both;"></div>
';
$output .= '<ul id="usersList">';
foreach ($current as $id)
{
$row = JFactory::getUser($id);
$output .= '
<li>
<img class="remove" src="'.$image.'" alt="'.JText::_('K2_REMOVE_ENTRY_FROM_LIST').'" />
<span class="handle">'.$row->name.'</span>
<input type="hidden" value="'.$row->id.'" name="'.$fieldName.'" />
<span style="clear:both;"></span>
</li>
';
}
$output .= '</ul>';
return $output;
}
}
class JFormFieldUsersLatest extends K2ElementUsersLatest
{
var $type = 'userslatest';
}
class JElementUsersLatest extends K2ElementUsersLatest
{
var $_name = 'userslatest';
}

View File

@ -0,0 +1,315 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
class K2HelperHTML
{
public static function subMenu()
{
$user = JFactory::getUser();
$view = JRequest::getCmd('view');
$view = JString::strtolower($view);
$params = JComponentHelper::getParams('com_k2');
JSubMenuHelper::addEntry(JText::_('K2_ITEMS'), 'index.php?option=com_k2&view=items', $view == 'items');
JSubMenuHelper::addEntry(JText::_('K2_CATEGORIES'), 'index.php?option=com_k2&view=categories', $view == 'categories');
if (!$params->get('lockTags') || $user->gid > 23)
{
JSubMenuHelper::addEntry(JText::_('K2_TAGS'), 'index.php?option=com_k2&view=tags', $view == 'tags');
}
JSubMenuHelper::addEntry(JText::_('K2_COMMENTS'), 'index.php?option=com_k2&view=comments', $view == 'comments');
if ($user->gid > 23)
{
JSubMenuHelper::addEntry(JText::_('K2_USERS'), 'index.php?option=com_k2&view=users', $view == 'users');
JSubMenuHelper::addEntry(JText::_('K2_USER_GROUPS'), 'index.php?option=com_k2&view=usergroups', $view == 'usergroups');
JSubMenuHelper::addEntry(JText::_('K2_EXTRA_FIELDS'), 'index.php?option=com_k2&view=extrafields', $view == 'extrafields');
JSubMenuHelper::addEntry(JText::_('K2_EXTRA_FIELD_GROUPS'), 'index.php?option=com_k2&view=extrafieldsgroups', $view == 'extrafieldsgroups');
}
JSubMenuHelper::addEntry(JText::_('K2_MEDIA_MANAGER'), 'index.php?option=com_k2&view=media', $view == 'media');
JSubMenuHelper::addEntry(JText::_('K2_INFORMATION'), 'index.php?option=com_k2&view=info', $view == 'info');
}
public static function stateToggler(&$row, $key, $property = 'published', $tasks = array('publish', 'unpublish'), $labels = array('K2_PUBLISH', 'K2_UNPUBLISH'))
{
$task = $row->$property ? $tasks[1] : $tasks[0];
$action = $row->$property ? JText::_($labels[1]) : JText::_($labels[0]);
$class = 'k2Toggler';
$status = $row->$property ? 'k2Active' : 'k2Inactive';
$href = '<a class="'.$class.' '.$status.'" href="javascript:void(0);" onclick="return listItemTask(\'cb'.$key.'\',\''.$task.'\')" title="'.$action.'">'.$action.'</a>';
return $href;
}
public static function loadHeadIncludes($loadFramework = false, $jQueryUI = false, $adminHeadIncludes = false, $adminModuleIncludes = false)
{
$application = JFactory::getApplication();
$document = JFactory::getDocument();
$user = JFactory::getUser();
$params = K2HelperUtilities::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = strtolower(JRequest::getWord('view', 'items'));
$task = JRequest::getCmd('task');
$jQueryHandling = $params->get('jQueryHandling', '1.9.1');
if ($document->getType() == 'html')
{
if ($loadFramework && $view != 'media')
{
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
}
if (version_compare(JVERSION, '3.0.0', 'ge'))
{
if ($application->isAdmin() || ($application->isSite() && $params->get('jQueryHandling')))
{
JHtml::_('jquery.framework');
}
}
// jQuery
if (version_compare(JVERSION, '3.0.0', 'lt'))
{
// Frontend
if ($application->isSite())
{
// B/C for saved old options
if ($jQueryHandling == '1.7remote') $jQueryHandling = '1.7.2';
if ($jQueryHandling == '1.8remote') $jQueryHandling = '1.8.3';
if ($jQueryHandling == '1.9remote') $jQueryHandling = '1.9.1';
if ($jQueryHandling == '1.10remote') $jQueryHandling = '1.10.2';
if ($jQueryHandling == '1.11remote') $jQueryHandling = '1.11.3';
if ($jQueryHandling == '1.12remote') $jQueryHandling = '1.12.4';
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/'.$jQueryHandling.'/jquery.min.js');
}
// Backend
if ($application->isAdmin())
{
if (($option == 'com_k2' && ($view == 'item' || $view == 'category')) || $option == 'com_menus')
{
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/1.8.3/jquery.min.js');
}
else
{
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery/1.12.4/jquery.min.js');
}
}
}
// jQueryUI
if ($jQueryUI)
{
// Load version 1.8.24 for tabs & sortables (called the "old" way)...
if (($option == 'com_k2' && ($view == 'item' || $view == 'category')) || $option == 'com_menus')
{
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.8.24/jquery-ui.min.js');
}
// Load latest version for the "media" view & modules only
if (($option == 'com_k2' && $view == 'media') || $option == 'com_modules' || $option == 'com_advancedmodules')
{
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/themes/smoothness/jquery-ui.min.css');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js');
}
}
// Everything else...
if ($application->isAdmin() || $adminHeadIncludes)
{
// JS
$isBackend = ($application->isAdmin()) ? ' k2IsBackend' : '';
$isTask = ($task) ? ' k2TaskIs'.ucfirst($task) : '';
$cssClass = 'isJ'.K2_JVERSION.' k2ViewIs'.ucfirst($view).''.$isTask.''.$isBackend;
$document->addScriptDeclaration("
// Set K2 version as global JS variable
K2JVersion = '".K2_JVERSION."';
// Set Joomla version as class in the 'html' tag
(function(){
var addedClass = '".$cssClass."';
if (document.getElementsByTagName('html')[0].className !== '') {
document.getElementsByTagName('html')[0].className += ' '+addedClass;
} else {
document.getElementsByTagName('html')[0].className = addedClass;
}
})();
// K2 Language Strings
var K2_THE_ENTRY_IS_ALREADY_IN_THE_LIST = '".JText::_('K2_THE_ENTRY_IS_ALREADY_IN_THE_LIST')."';
var K2_REMOVE_THIS_ENTRY = '".JText::_('K2_REMOVE_THIS_ENTRY')."';
var K2_THE_ENTRY_WAS_ADDED_IN_THE_LIST = '".JText::_('K2_THE_ENTRY_WAS_ADDED_IN_THE_LIST')."';
");
$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.backend.js?v='.K2_CURRENT_VERSION.'&amp;sitepath='.JURI::root(true).'/');
// NicEdit
if ($option == 'com_k2' && $view == 'item')
{
$document->addScript(JURI::root(true).'/media/k2/assets/vendors/bkirchoff/nicedit/nicEdit.js?v='.K2_CURRENT_VERSION);
}
// Media (elFinder)
if ($view == 'media')
{
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/vendors/studio-42/elfinder/css/elfinder.min.css?v='.K2_CURRENT_VERSION);
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/vendors/studio-42/elfinder/css/theme.css?v='.K2_CURRENT_VERSION);
$document->addScript(JURI::root(true).'/media/k2/assets/vendors/studio-42/elfinder/js/elfinder.min.js?v='.K2_CURRENT_VERSION);
}
else
{
JHTML::_('behavior.tooltip');
if (version_compare(JVERSION, '3.0.0', 'ge'))
{
if ($view == 'item' && !$params->get('taggingSystem'))
{
JHtml::_('formbehavior.chosen', 'select:not(#selectedTags, #tags)');
}
else
{
JHtml::_('formbehavior.chosen', 'select');
}
}
}
// Flatpickr
if ($view == 'item' || $view == 'extrafield')
{
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/flatpickr/2.6.3/flatpickr.min.css');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/flatpickr/2.6.3/flatpickr.min.js');
$document->addCustomTag('<!--[if IE 9]><link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/flatpickr/2.6.3/ie.css" /><![endif]-->');
}
// Magnific Popup
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css');
$document->addStyleDeclaration('
/* K2 - Magnific Popup Overrides */
.mfp-iframe-holder {padding:10px;}
.mfp-iframe-holder .mfp-content {max-width:100%;width:100%;height:100%;}
.mfp-iframe-scaler iframe {background:#fff;padding:10px;box-sizing:border-box;box-shadow:none;}
');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js');
// Fancybox
if ($view == 'item' || $view == 'items' || $view == 'categories')
{
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.20/jquery.fancybox.min.css');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/fancybox/3.1.20/jquery.fancybox.min.js');
}
// CSS
if ($option == 'com_k2' || $adminModuleIncludes)
{
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css');
}
if ($option == 'com_k2')
{
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.backend.css?v='.K2_CURRENT_VERSION);
}
if($adminModuleIncludes)
{
$document->addStyleSheet(JURI::root(true).'/media/k2/assets/css/k2.global.css?v='.K2_CURRENT_VERSION);
}
}
// Frontend only
if($application->isSite())
{
// Magnific Popup
if (!$user->guest || ($option == 'com_k2' && $view == 'item') || defined('K2_JOOMLA_MODAL_REQUIRED')){
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/magnific-popup.min.css');
$document->addStyleDeclaration('
/* K2 - Magnific Popup Overrides */
.mfp-iframe-holder {padding:10px;}
.mfp-iframe-holder .mfp-content {max-width:100%;width:100%;height:100%;}
.mfp-iframe-scaler iframe {background:#fff;padding:10px;box-sizing:border-box;box-shadow:none;}
');
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js');
}
// JS
$document->addScript(JURI::root(true).'/media/k2/assets/js/k2.frontend.js?v='.K2_CURRENT_VERSION.'&amp;sitepath='.JURI::root(true).'/');
// Google Search (deprecated - to remove)
if ($task == 'search' && $params->get('googleSearch'))
{
$language = JFactory::getLanguage();
$lang = $language->getTag();
// Fallback to the new container ID without breaking things
$googleSearchContainerID = trim($params->get('googleSearchContainer', 'k2GoogleSearchContainer'));
if($googleSearchContainerID == 'k2Container'){
$googleSearchContainerID = 'k2GoogleSearchContainer';
}
$document->addScript('https://www.google.com/jsapi');
$document->addScriptDeclaration('
google.load("search", "1", {"language" : "'.$lang.'"});
function OnLoad(){
var searchControl = new google.search.SearchControl();
var siteSearch = new google.search.WebSearch();
siteSearch.setUserDefinedLabel("'.$application->getCfg('sitename').'");
siteSearch.setUserDefinedClassSuffix("k2");
options = new google.search.SearcherOptions();
options.setExpandMode(google.search.SearchControl.EXPAND_MODE_OPEN);
siteSearch.setSiteRestriction("'.JURI::root().'");
searchControl.addSearcher(siteSearch, options);
searchControl.setResultSetSize(google.search.Search.LARGE_RESULTSET);
searchControl.setLinkTarget(google.search.Search.LINK_TARGET_SELF);
searchControl.draw(document.getElementById("'.$googleSearchContainerID.'"));
searchControl.execute("'.JRequest::getString('searchword').'");
}
google.setOnLoadCallback(OnLoad);
');
}
// Add related CSS to the <head>
if ($params->get('enable_css'))
{
jimport('joomla.filesystem.file');
// Simple Line Icons
$document->addStyleSheet('https://cdnjs.cloudflare.com/ajax/libs/simple-line-icons/2.4.1/css/simple-line-icons.min.css');
// k2.css
if (JFile::exists(JPATH_SITE.'/templates/'.$application->getTemplate().'/css/k2.css'))
{
$document->addStyleSheet(JURI::root(true).'/templates/'.$application->getTemplate().'/css/k2.css?v='.K2_CURRENT_VERSION);
}
else
{
$document->addStyleSheet(JURI::root(true).'/components/com_k2/css/k2.css?v='.K2_CURRENT_VERSION);
}
// k2.print.css
if (JRequest::getInt('print') == 1)
{
if (JFile::exists(JPATH_SITE.'/templates/'.$application->getTemplate().'/css/k2.print.css'))
{
$document->addStyleSheet(JURI::root(true).'/templates/'.$application->getTemplate().'/css/k2.print.css?v='.K2_CURRENT_VERSION, 'text/css', 'print');
}
else
{
$document->addStyleSheet(JURI::root(true).'/components/com_k2/css/k2.print.css?v='.K2_CURRENT_VERSION, 'text/css', 'print');
}
}
}
}
}
}
}

View File

@ -0,0 +1,172 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
class K2HelperStats
{
public static function getScripts()
{
$data = self::getData();
$token = version_compare(JVERSION, '2.5', 'ge') ? JSession::getFormToken() : JUtility::getToken();
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
JHtml::_('behavior.framework');
}
else
{
JHTML::_('behavior.mootools');
}
if (version_compare(JVERSION, '3.0.0', 'ge'))
{
JHtml::_('jquery.framework');
}
$document = JFactory::getDocument();
$document->addScript('https://cdnjs.cloudflare.com/ajax/libs/jquery-ajaxtransport-xdomainrequest/1.0.4/jquery.xdomainrequest.min.js');
$document->addScriptDeclaration("
/* K2 - Metrics */
(function(\$){
function K2LogResult(xhr) {
\$.ajax({
type: 'POST',
url: 'index.php',
data: {
'option': 'com_k2',
'view': 'items',
'task': 'logStats',
'".$token."': '1',
'status': xhr.status,
'response': xhr.responseText
}
});
}
\$(document).ready(function(){
\$.ajax({
crossDomain: true,
type: 'POST',
url: 'https://metrics.getk2.org/gather.php',
data: ".$data."
}).done(function(response, result, xhr) {
K2LogResult(xhr);
}).fail(function(xhr, result, response) {
K2LogResult(xhr);
});
});
})(jQuery);
");
}
public static function getData()
{
$data = new stdClass;
$data->identifier = self::getIdentifier();
$data->php = self::getPhpVersion();
$data->databaseType = self::getDbType();
$data->databaseVersion = self::getDbVersion();
$data->server = self::getServer();
$data->serverInterface = self::getServerInterface();
$data->cms = self::getCmsVersion();
$data->extensionName = 'K2';
$data->extensionVersion = self::getExtensionVersion();
$data->caching = self::getCaching();
$data->cachingDriver = self::getCachingDriver();
return json_encode($data);
}
public static function getIdentifier()
{
$configuration = JFactory::getConfig();
$secret = version_compare(JVERSION, '2.5', 'ge') ? $configuration->get('secret') : $configuration->getValue('config.secret');
return md5($secret.$_SERVER['SERVER_ADDR']);
}
public static function getPhpVersion()
{
return phpversion();
}
public static function getDbType()
{
$configuration = JFactory::getConfig();
$type = version_compare(JVERSION, '2.5', 'ge') ? $configuration->get('dbtype') : $configuration->getValue('config.dbtype');
if($type == 'mysql' || $type == 'mysqli' || $type == 'pdomysql')
{
$db = JFactory::getDbo();
$query = 'SELECT version();';
$db->setQuery($query);
$result = $db->loadResult();
$result = strtolower($result);
if(strpos($result, 'mariadb') !== false)
{
$type = 'mariadb';
}
}
return $type;
}
public static function getDbVersion()
{
$db = JFactory::getDbo();
return $db->getVersion();
}
public static function getServer()
{
return isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : getenv('SERVER_SOFTWARE');
}
public static function getServerInterface()
{
return php_sapi_name();
}
public static function getCmsVersion()
{
return JVERSION;
}
public static function getExtensionVersion()
{
return K2_CURRENT_VERSION;
}
public static function getCaching()
{
$configuration = JFactory::getConfig();
return version_compare(JVERSION, '2.5', 'ge') ? $configuration->get('caching') : $configuration->getValue('config.caching');
}
public static function getCachingDriver()
{
$configuration = JFactory::getConfig();
return version_compare(JVERSION, '2.5', 'ge') ? $configuration->get('cache_handler') : $configuration->getValue('config.cache_handler');
}
public static function shouldLog()
{
$db = JFactory::getDbo();
$query = 'SELECT * FROM #__k2_log';
$db->setQuery($query, 0, 1);
$result = $db->loadObject();
if (!$result)
{
return true;
}
$now = JFactory::getDate()->toUnix();
$days = floor(($now - strtotime($result->timestamp)) / (60 * 60 * 24));
if ($days >= 30 || $result->status != 200)
{
return true;
}
return false;
}
}

View File

@ -0,0 +1,187 @@
CREATE TABLE IF NOT EXISTS `#__k2_attachments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`itemID` int(11) NOT NULL,
`filename` varchar(255) NOT NULL,
`title` varchar(255) NOT NULL,
`titleAttribute` text NOT NULL,
`hits` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `hits` (`hits`),
KEY `itemID` (`itemID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_categories` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`alias` varchar(255) NOT NULL,
`description` text NOT NULL,
`parent` int(11) DEFAULT '0',
`extraFieldsGroup` int(11) NOT NULL,
`published` smallint(6) NOT NULL DEFAULT '0',
`access` int(11) NOT NULL DEFAULT '0',
`ordering` int(11) NOT NULL DEFAULT '0',
`image` varchar(255) NOT NULL,
`params` text NOT NULL,
`trash` smallint(6) NOT NULL DEFAULT '0',
`plugins` text NOT NULL,
`language` char(7) NOT NULL,
PRIMARY KEY (`id`),
KEY `access` (`access`),
KEY `category` (`published`,`access`,`trash`),
KEY `language` (`language`),
KEY `ordering` (`ordering`),
KEY `parent` (`parent`),
KEY `published` (`published`),
KEY `trash` (`trash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_comments` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`itemID` int(11) NOT NULL,
`userID` int(11) NOT NULL,
`userName` varchar(255) NOT NULL,
`commentDate` datetime NOT NULL,
`commentText` text NOT NULL,
`commentEmail` varchar(255) NOT NULL,
`commentURL` varchar(255) NOT NULL,
`published` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `commentDate` (`commentDate`),
KEY `countComments` (`itemID`,`published`),
KEY `itemID` (`itemID`),
KEY `latestComments` (`published`,`commentDate`),
KEY `published` (`published`),
KEY `userID` (`userID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_extra_fields` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`value` text NOT NULL,
`type` varchar(255) NOT NULL,
`group` int(11) NOT NULL,
`published` tinyint(4) NOT NULL,
`ordering` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `group` (`group`),
KEY `published` (`published`),
KEY `ordering` (`ordering`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_extra_fields_groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) NOT NULL,
`alias` varchar(255) DEFAULT NULL,
`catid` int(11) NOT NULL,
`published` smallint(6) NOT NULL DEFAULT '0',
`introtext` mediumtext NOT NULL,
`fulltext` mediumtext NOT NULL,
`video` text,
`gallery` varchar(255) DEFAULT NULL,
`extra_fields` text CHARACTER SET utf8 COLLATE utf8_unicode_ci,
`extra_fields_search` text NOT NULL,
`created` datetime NOT NULL,
`created_by` int(11) NOT NULL DEFAULT '0',
`created_by_alias` varchar(255) NOT NULL,
`checked_out` int(10) unsigned NOT NULL,
`checked_out_time` datetime NOT NULL,
`modified` datetime NOT NULL,
`modified_by` int(11) NOT NULL DEFAULT '0',
`publish_up` datetime NOT NULL,
`publish_down` datetime NOT NULL,
`trash` smallint(6) NOT NULL DEFAULT '0',
`access` int(11) NOT NULL DEFAULT '0',
`ordering` int(11) NOT NULL DEFAULT '0',
`featured` smallint(6) NOT NULL DEFAULT '0',
`featured_ordering` int(11) NOT NULL DEFAULT '0',
`image_caption` text NOT NULL,
`image_credits` varchar(255) NOT NULL,
`video_caption` text NOT NULL,
`video_credits` varchar(255) NOT NULL,
`hits` int(10) unsigned NOT NULL,
`params` text NOT NULL,
`metadesc` text NOT NULL,
`metadata` text NOT NULL,
`metakey` text NOT NULL,
`plugins` text NOT NULL,
`language` char(7) NOT NULL,
PRIMARY KEY (`id`),
KEY `access` (`access`),
KEY `catid` (`catid`),
KEY `created_by` (`created_by`),
KEY `created` (`created`),
KEY `featured_ordering` (`featured_ordering`),
KEY `featured` (`featured`),
KEY `hits` (`hits`),
KEY `item` (`published`,`publish_up`,`publish_down`,`trash`,`access`),
KEY `language` (`language`),
KEY `ordering` (`ordering`),
KEY `published` (`published`),
KEY `publish_down` (`publish_down`),
KEY `publish_up` (`publish_up`),
KEY `trash` (`trash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_rating` (
`itemID` int(11) NOT NULL DEFAULT '0',
`rating_sum` int(11) unsigned NOT NULL DEFAULT '0',
`rating_count` int(11) unsigned NOT NULL DEFAULT '0',
`lastip` varchar(50) NOT NULL DEFAULT '',
PRIMARY KEY (`itemID`),
KEY `rating_sum` (`rating_sum`),
KEY `rating_count` (`rating_count`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_tags` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`published` smallint(6) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`),
KEY `published` (`published`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_tags_xref` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`tagID` int(11) NOT NULL,
`itemID` int(11) NOT NULL,
PRIMARY KEY (`id`),
KEY `tagID` (`tagID`),
KEY `itemID` (`itemID`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_users` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`userID` int(11) NOT NULL,
`userName` varchar(255) DEFAULT NULL,
`gender` enum('m','f') NOT NULL DEFAULT 'm',
`description` text NOT NULL,
`image` varchar(255) DEFAULT NULL,
`url` varchar(255) DEFAULT NULL,
`group` int(11) NOT NULL DEFAULT '0',
`plugins` text NOT NULL,
`ip` varchar(15) NOT NULL,
`hostname` varchar(255) NOT NULL,
`notes` text NOT NULL,
PRIMARY KEY (`id`),
KEY `userID` (`userID`),
KEY `group` (`group`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_user_groups` (
`id` int(10) unsigned NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`permissions` text NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
CREATE TABLE IF NOT EXISTS `#__k2_log` (
`status` int(11) NOT NULL,
`response` text NOT NULL,
`timestamp` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

View File

@ -0,0 +1,93 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
defined('JPATH_BASE') or die();
/**
* K2 migration class from Joomla 1.5 to Joomla 1.6+
*
* You can also put this class into your own extension, which makes jUpgrade to use your own copy instead of this adapter class.
* In order to do that you should have j16upgrade.xml file somewhere in your extension path containing:
* <jupgrade>
* <!-- Adapter class location and name -->
* <installer>
* <file>administrator/components/com_k2/jupgrade/j16upgrade.php</file>
* <class>jUpgradeComponentK2</class>
* </installer>
* </jupgrade>
* For more information, see ./j16upgrade.xml
*/
class jUpgradeComponentK2 extends jUpgrade
{
/**
* Check if K2 migration is supported.
*/
protected function detectExtension()
{
return true;
}
/**
* Migrate custom information.
*
* This function gets called after all folders and tables have been copied.
*
* If you want to split this task into smaller chunks,
* please store your custom state variables into $this->state and return false.
* Returning false will force jUpgrade to call this function again,
* which allows you to continue import by reading $this->state before continuing.
*
* @return boolean Ready (true/false)
* @since 1.6.4
* @throws Exception
*/
protected function migrateExtensionCustom()
{
return true;
}
protected function copyTable_k2_categories($table)
{
$this->source = $this->destination = "#__{$table}";
// Clone table
$this->cloneTable($this->source, $this->destination);
// Get data
$rows = parent::getSourceData('*');
// Do some custom post processing on the list.
foreach ($rows as &$row) {
$row['access'] = $row['access'] == 0 ? 1 : $row['access'] + 1;
$row['params'] = $this->convertParams($row['params']);
}
$this->setDestinationData($rows);
return true;
}
protected function copyTable_k2_items($table)
{
$this->source = $this->destination = "#__{$table}";
// Clone table
$this->cloneTable($this->source, $this->destination);
// Get data
$rows = parent::getSourceData('*');
// Do some custom post processing on the list.
foreach ($rows as &$row) {
$row['access'] = $row['access'] == 0 ? 1 : $row['access'] + 1;
$row['params'] = $this->convertParams($row['params']);
$row['plugins'] = $this->convertParams($row['plugins']);
}
$this->setDestinationData($rows);
return true;
}
}

View File

@ -0,0 +1,49 @@
<?xml version="1.0" ?>
<!DOCTYPE jupgrade>
<jupgrade>
<collection>http://getk2.org/app/collection.xml</collection>
<installer>
<file>administrator/components/com_k2/jupgrade/j16upgrade.php</file>
<class>jUpgradeComponentK2</class>
</installer>
<!-- The tables to copy to the new site. -->
<tables>
<table>k2_attachments</table>
<table>k2_categories</table>
<table>k2_comments</table>
<table>k2_extra_fields</table>
<table>k2_extra_fields_groups</table>
<table>k2_items</table>
<table>k2_rating</table>
<table>k2_tags</table>
<table>k2_tags_xref</table>
<table>k2_users</table>
<table>k2_user_groups</table>
</tables>
<!-- The folders to copy to the new site. -->
<folders>
<folder>administrator/components/com_k2</folder>
<folder>components/com_k2</folder>
<folder>media/k2</folder>
</folders>
<package>
<extension>
<name>mod_k2_comments</name>
</extension>
<extension>
<name>mod_k2_content</name>
</extension>
<extension>
<name>mod_k2_login</name>
</extension>
<extension>
<name>mod_k2_tools</name>
</extension>
<extension>
<name>mod_k2_user</name>
</extension>
<extension>
<name>mod_k2_users</name>
</extension>
</package>
</jupgrade>

View File

@ -0,0 +1,93 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
defined('JPATH_BASE') or die();
/**
* K2 migration class from Joomla 1.5 to Joomla 2.5+
*
* You can also put this class into your own extension, which makes jUpgrade to use your own copy instead of this adapter class.
* In order to do that you should have j25upgrade.xml file somewhere in your extension path containing:
* <jupgrade>
* <!-- Adapter class location and name -->
* <installer>
* <file>administrator/components/com_k2/jupgrade/j25upgrade.php</file>
* <class>jUpgradeComponentK2</class>
* </installer>
* </jupgrade>
* For more information, see ./j25upgrade.xml
*/
class jUpgradeComponentK2 extends jUpgradeExtensions
{
/**
* Check if K2 migration is supported.
*/
protected function detectExtension()
{
return true;
}
/**
* Migrate custom information.
*
* This function gets called after all folders and tables have been copied.
*
* If you want to split this task into smaller chunks,
* please store your custom state variables into $this->state and return false.
* Returning false will force jUpgrade to call this function again,
* which allows you to continue import by reading $this->state before continuing.
*
* @return boolean Ready (true/false)
* @since 1.6.4
* @throws Exception
*/
protected function migrateExtensionCustom()
{
return true;
}
protected function copyTable_k2_categories($table)
{
$this->source = $this->destination = "#__{$table}";
// Clone table
$this->cloneTable($this->source, $this->destination);
// Get data
$rows = parent::getSourceData('*');
// Do some custom post processing on the list.
foreach ($rows as &$row) {
$row['access'] = $row['access'] == 0 ? 1 : $row['access'] + 1;
$row['params'] = $this->convertParams($row['params']);
}
$this->setDestinationData($rows);
return true;
}
protected function copyTable_k2_items($table)
{
$this->source = $this->destination = "#__{$table}";
// Clone table
$this->cloneTable($this->source, $this->destination);
// Get data
$rows = parent::getSourceData('*');
// Do some custom post processing on the list.
foreach ($rows as &$row) {
$row['access'] = $row['access'] == 0 ? 1 : $row['access'] + 1;
$row['params'] = $this->convertParams($row['params']);
$row['plugins'] = $this->convertParams($row['plugins']);
}
$this->setDestinationData($rows);
return true;
}
}

View File

@ -0,0 +1,49 @@
<?xml version="1.0" ?>
<!DOCTYPE jupgrade>
<jupgrade>
<collection>http://getk2.org/app/collection.xml</collection>
<installer>
<file>administrator/components/com_k2/jupgrade/j25upgrade.php</file>
<class>jUpgradeComponentK2</class>
</installer>
<!-- The tables to copy to the new site. -->
<tables>
<table>k2_attachments</table>
<table>k2_categories</table>
<table>k2_comments</table>
<table>k2_extra_fields</table>
<table>k2_extra_fields_groups</table>
<table>k2_items</table>
<table>k2_rating</table>
<table>k2_tags</table>
<table>k2_tags_xref</table>
<table>k2_users</table>
<table>k2_user_groups</table>
</tables>
<!-- The folders to copy to the new site. -->
<folders>
<folder>administrator/components/com_k2</folder>
<folder>components/com_k2</folder>
<folder>media/k2</folder>
</folders>
<package>
<extension>
<name>mod_k2_comments</name>
</extension>
<extension>
<name>mod_k2_content</name>
</extension>
<extension>
<name>mod_k2_login</name>
</extension>
<extension>
<name>mod_k2_tools</name>
</extension>
<extension>
<name>mod_k2_user</name>
</extension>
<extension>
<name>mod_k2_users</name>
</extension>
</package>
</jupgrade>

View File

@ -0,0 +1,146 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
$user = JFactory::getUser();
$option = JRequest::getCmd('option');
$view = strtolower(JRequest::getWord('view', 'items'));
$task = JRequest::getCmd('task');
$params = JComponentHelper::getParams('com_k2');
if(K2_JVERSION=='15')
{
if(($params->get('lockTags') && $user->gid<=23 && ($view=='tags' || $view=='tag')) || ($user->gid <= 23) && (
$view=='extrafield' ||
$view=='extrafields' ||
$view=='extrafieldsgroup' ||
$view=='extrafieldsgroups' ||
$view=='user' ||
($view=='users' && $task != 'element') ||
$view=='usergroup' ||
$view=='usergroups'
)
)
{
JError::raiseError( 403, JText::_('K2_ALERTNOTAUTH') );
}
}
else
{
JLoader::register('K2HelperPermissions', JPATH_SITE.'/components/com_k2/helpers/permissions.j16.php');
K2HelperPermissions::checkPermissions();
// Compatibility for gid variable
if($user->authorise('core.admin', 'com_k2'))
{
$user->gid = 1000;
}
else
{
$user->gid = 1;
}
if(
($params->get('lockTags') && !$user->authorise('core.admin', 'com_k2') && ($view=='tags' || $view=='tag')) ||
(!$user->authorise('core.admin', 'com_k2')) && (
$view=='extrafield' ||
$view=='extrafields' ||
$view=='extrafieldsgroup' ||
$view=='extrafieldsgroups' ||
$view=='user' ||
($view=='users' && $task != 'element') ||
$view=='usergroup' ||
$view=='usergroups'
)
)
{
JError::raiseError( 403, JText::_('K2_ALERTNOTAUTH') );
}
}
$document = JFactory::getDocument();
K2HelperHTML::loadHeadIncludes(true, true);
// Container CSS class definition
if(K2_JVERSION == '15')
{
$k2CSSContainerClass = ' oldJ isJ15';
}
elseif (K2_JVERSION == '25')
{
$k2CSSContainerClass = ' oldJ isJ25';
}
elseif (K2_JVERSION == '30')
{
$k2CSSContainerClass = ' isJ25 isJ30';
}
else
{
$k2CSSContainerClass = '';
}
if(JRequest::getCmd('context') == "modalselector")
{
$k2CSSContainerClass .= ' inModalSelector';
$k2FooterClass = 'inModalSelector';
}
else
{
$k2FooterClass = '';
}
if(
$document->getType() != 'raw' &&
JRequest::getWord('task')!='deleteAttachment' &&
JRequest::getWord('task')!='connector' &&
JRequest::getWord('task')!='tag' &&
JRequest::getWord('task')!='tags' &&
JRequest::getWord('task')!='extrafields' &&
JRequest::getWord('task')!='download' &&
JRequest::getWord('task')!='saveComment'
)
{
$k2ComponentHeader = '<div id="k2AdminContainer" class="K2AdminView'.ucfirst($view).$k2CSSContainerClass.'">';
$k2ComponentFooter = '
</div>
<div id="k2AdminFooter" class="'.$k2FooterClass.'">
<a target="_blank" href="https://getk2.org/">K2 v'.K2_CURRENT_VERSION.K2_BUILD.'</a> | Copyright &copy; 2006-'.date('Y').' <a target="_blank" href="http://www.joomlaworks.net/">JoomlaWorks Ltd.</a>
</div>
<!-- K2 Update Service -->
<script type="text/javascript">var K2_INSTALLED_VERSION = \''.K2_CURRENT_VERSION.'\';</script>
<script type="text/javascript" src="https://getk2.org/app/update.js?t='.date('Ymd').'"></script>
';
}
else
{
$k2ComponentHeader = '';
$k2ComponentFooter = '';
}
// Output
echo $k2ComponentHeader;
JLoader::register('K2Controller', JPATH_COMPONENT.'/controllers/controller.php');
JLoader::register('K2View', JPATH_COMPONENT.'/views/view.php');
JLoader::register('K2Model', JPATH_COMPONENT.'/models/model.php');
$controller = JRequest::getWord('view', 'items');
$controller = JString::strtolower($controller);
require_once(JPATH_COMPONENT.'/controllers/'.$controller.'.php');
$classname = 'K2Controller'.$controller;
$controller = new $classname();
$controller->registerTask('saveAndNew', 'save');
$controller->execute(JRequest::getWord('task'));
$controller->redirect();
echo $k2ComponentFooter;

View File

@ -0,0 +1,304 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="component" version="2.5" method="upgrade">
<name>COM_K2</name>
<author>JoomlaWorks</author>
<creationDate>August 18th, 2017</creationDate>
<copyright>Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.</copyright>
<authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
<authorUrl>www.joomlaworks.net</authorUrl>
<version>2.8.0</version>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>Thank you for installing K2 by JoomlaWorks, the powerful content extension for Joomla</description>
<installfile>install.k2.php</installfile>
<uninstallfile>uninstall.k2.php</uninstallfile>
<scriptfile>script.k2.php</scriptfile>
<install>
<sql>
<file driver="mysqli" charset="utf8">install.mysql.sql</file>
<file driver="mysql" charset="utf8">install.mysql.sql</file>
</sql>
</install>
<uninstall>
<sql>
<file driver="mysqli" charset="utf8">uninstall.mysql.sql</file>
<file driver="mysql" charset="utf8">uninstall.mysql.sql</file>
</sql>
</uninstall>
<updateservers>
<server type="extension" priority="1" name="K2 Updates">http://getk2.org/app/update.xml</server>
</updateservers>
<files folder="components/com_k2">
<folder>controllers</folder>
<folder>css</folder>
<folder>helpers</folder>
<folder>images</folder>
<folder>models</folder>
<folder>templates</folder>
<folder>views</folder>
<filename>k2.php</filename>
<filename>router.php</filename>
</files>
<media destination="k2" folder="media/k2">
<folder>assets</folder>
<folder>attachments</folder>
<folder>categories</folder>
<folder>galleries</folder>
<folder>items</folder>
<folder>users</folder>
<folder>videos</folder>
</media>
<languages folder="language/en-GB">
<language tag="en-GB">en-GB.com_k2.ini</language>
<language tag="en-GB">en-GB.mod_k2_comments.ini</language>
<language tag="en-GB">en-GB.mod_k2_comments.sys.ini</language>
<language tag="en-GB">en-GB.mod_k2_content.ini</language>
<language tag="en-GB">en-GB.mod_k2_content.sys.ini</language>
<language tag="en-GB">en-GB.mod_k2_tools.ini</language>
<language tag="en-GB">en-GB.mod_k2_tools.sys.ini</language>
<language tag="en-GB">en-GB.mod_k2_users.ini</language>
<language tag="en-GB">en-GB.mod_k2_users.sys.ini</language>
<language tag="en-GB">en-GB.mod_k2_user.ini</language>
<language tag="en-GB">en-GB.mod_k2_user.sys.ini</language>
</languages>
<administration>
<menu img="../media/k2/assets/images/backend/k2_logo_16x16.png" view="items">COM_K2</menu>
<submenu>
<menu view="items" link="option=com_k2&amp;view=items">K2_ITEMS</menu>
<menu view="categories" link="option=com_k2&amp;view=categories">K2_CATEGORIES</menu>
<menu view="tags" link="option=com_k2&amp;view=tags">K2_TAGS</menu>
<menu view="comments" link="option=com_k2&amp;view=comments">K2_COMMENTS</menu>
<menu view="usergroups" link="option=com_k2&amp;view=users">K2_USERS</menu>
<menu view="usergroups" link="option=com_k2&amp;view=usergroups">K2_USER_GROUPS</menu>
<menu view="extrafields" link="option=com_k2&amp;view=extrafields">K2_EXTRA_FIELDS</menu>
<menu view="extrafieldgroups" link="option=com_k2&amp;view=extrafieldsgroups">K2_EXTRA_FIELD_GROUPS</menu>
<menu view="media" link="option=com_k2&amp;view=media">K2_MEDIA_MANAGER</menu>
<menu view="info" link="option=com_k2&amp;view=info">K2_INFORMATION</menu>
</submenu>
<files folder="administrator/components/com_k2">
<folder>controllers</folder>
<folder>elements</folder>
<folder>helpers</folder>
<folder>jupgrade</folder>
<folder>lib</folder>
<folder>models</folder>
<folder>tables</folder>
<folder>views</folder>
<filename>access.xml</filename>
<filename>k2.php</filename>
<filename>config.xml</filename>
<filename>install.mysql.sql</filename>
<filename>uninstall.mysql.sql</filename>
</files>
<languages folder="administrator/language/en-GB">
<language tag="en-GB">en-GB.com_k2.dates.ini</language>
<language tag="en-GB">en-GB.com_k2.ini</language>
<language tag="en-GB">en-GB.com_k2.menu.ini</language>
<language tag="en-GB">en-GB.mod_k2_quickicons.ini</language>
<language tag="en-GB">en-GB.mod_k2_quickicons.sys.ini</language>
<language tag="en-GB">en-GB.mod_k2_stats.ini</language>
<language tag="en-GB">en-GB.mod_k2_stats.sys.ini</language>
<language tag="en-GB">en-GB.plg_finder_k2.ini</language>
<language tag="en-GB">en-GB.plg_finder_k2.sys.ini</language>
<language tag="en-GB">en-GB.plg_search_k2.ini</language>
<language tag="en-GB">en-GB.plg_search_k2.sys.ini</language>
<language tag="en-GB">en-GB.plg_system_k2.ini</language>
<language tag="en-GB">en-GB.plg_system_k2.sys.ini</language>
<language tag="en-GB">en-GB.plg_user_k2.ini</language>
<language tag="en-GB">en-GB.plg_user_k2.sys.ini</language>
</languages>
</administration>
<config>
<fields>
<fieldset>
<!-- ######################### CSS Settings ######################### -->
<field name="enable_css" default="1" />
<field name="jQueryHandling" default="1.9.1" />
<!-- ######################### Layout and view options for user (blog/profile) pages ######################### -->
<field name="userName" default="1" />
<field name="userImage" default="1" />
<field name="userDescription" default="1" />
<field name="userURL" default="1" />
<field name="userEmail" default="0" />
<field name="userFeedLink" default="1" />
<field name="userFeedIcon" default="1" />
<field name="userItemCount" default="10" />
<field name="userItemTitle" default="1" />
<field name="userItemTitleLinked" default="1" />
<field name="userItemDateCreated" default="1" />
<field name="userItemImage" default="1" />
<field name="userItemIntroText" default="1" />
<field name="userItemCategory" default="1" />
<field name="userItemTags" default="1" />
<field name="userItemCommentsAnchor" default="1" />
<field name="userItemReadMore" default="1" />
<field name="userItemK2Plugins" default="1" />
<!-- ######################### Layout and view options for Tag listings ######################### -->
<field name="tagItemCount" default="10" />
<field name="tagItemTitle" default="1" />
<field name="tagItemTitleLinked" default="1" />
<field name="tagItemDateCreated" default="1" />
<field name="tagItemImage" default="1" />
<field name="tagItemIntroText" default="1" />
<field name="tagItemCategory" default="1" />
<field name="tagItemReadMore" default="1" />
<field name="tagItemExtraFields" default="0" />
<field name="tagOrdering" default="" />
<field name="tagFeedLink" default="1" />
<field name="tagFeedIcon" default="1" />
<!-- ######################### Layout and view options for Search and Date listings ######################### -->
<field name="genericItemCount" default="10" />
<field name="genericItemTitle" default="1" />
<field name="genericItemTitleLinked" default="1" />
<field name="genericItemDateCreated" default="1" />
<field name="genericItemImage" default="1" />
<field name="genericItemIntroText" default="1" />
<field name="genericItemCategory" default="1" />
<field name="genericItemReadMore" default="1" />
<field name="genericItemExtraFields" default="0" />
<field name="genericFeedLink" default="1" />
<field name="genericFeedIcon" default="1" />
<!-- ######################### RSS Feed Settings ######################### -->
<field name="feedLimit" default="10" />
<field name="feedItemImage" default="1" />
<field name="feedImgSize" default="S" />
<field name="feedItemIntroText" default="1" />
<field name="feedTextWordLimit" default="" />
<field name="feedItemFullText" default="1" />
<field name="feedItemTags" default="0" />
<field name="feedItemVideo" default="0" />
<field name="feedItemGallery" default="0" />
<field name="feedItemAttachments" default="0" />
<field name="feedBogusEmail" default="" />
<!-- ######################### Content Cleanup Settings ######################### -->
<field name="introTextCleanup" default="0" />
<field name="introTextCleanupExcludeTags" default="" />
<field name="introTextCleanupTagAttr" default="" />
<field name="fullTextCleanup" default="0" />
<field name="fullTextCleanupExcludeTags" default="" />
<field name="fullTextCleanupTagAttr" default="" />
<field name="xssFiltering" default="0" />
<!-- ######################### Extra Fields Settings ######################### -->
<field name="linkPopupWidth" default="900" />
<field name="linkPopupHeight" default="600" />
<!-- ######################### Image Settings ######################### -->
<field name="imagesQuality" default="100" />
<field name="itemImageXS" default="100" />
<field name="itemImageS" default="200" />
<field name="itemImageM" default="400" />
<field name="itemImageL" default="600" />
<field name="itemImageXL" default="900" />
<field name="itemImageGeneric" default="300" />
<field name="catImageWidth" default="100" />
<field name="catImageDefault" default="1" />
<field name="userImageWidth" default="100" />
<field name="userImageDefault" default="1" />
<field name="commenterImgWidth" default="48" />
<field name="onlineImageEditor" default="picozu" />
<field name="imageTimestamp" default="0" />
<field name="imageMemoryLimit" default="" />
<!-- ######################### Social Settings ######################### -->
<field name="socialButtonCode" default="" />
<field name="twitterUsername" default="" />
<field name="facebookMetatags" default="1" />
<field name="facebookImage" default="Medium" />
<!-- ######################### Comments ######################### -->
<field name="comments" default="1" />
<field name="commentsOrdering" default="DESC" />
<field name="commentsLimit" default="10" />
<field name="commentsFormPosition" default="below" />
<field name="commentsPublishing" default="0" />
<field name="commentsReporting" default="2" />
<field name="commentsReportRecipient" default="" />
<field name="inlineCommentsModeration" default="0" />
<field name="gravatar" default="1" />
<field name="recaptcha" default="0" />
<field name="recaptchaForRegistered" default="1" />
<field name="commentsFormNotes" default="1" />
<field name="commentsFormNotesText" default="" />
<!-- ######################### Frontend Editing ######################### -->
<field name="frontendEditing" default="1" />
<field name="showImageTab" default="1" />
<field name="showImageGalleryTab" default="1" />
<field name="showVideoTab" default="1" />
<field name="showExtraFieldsTab" default="1" />
<field name="showAttachmentsTab" default="1" />
<field name="showK2Plugins" default="1" />
<field name="sideBarDisplayFrontend" default="0" />
<!-- ######################### Advanced Settings ######################### -->
<field name="mergeEditors" default="1" />
<field name="sideBarDisplay" default="1" />
<field name="attachmentsFolder" default="" />
<field name="hideImportButton" default="0" />
<field name="googleSearch" default="0" />
<field name="googleSearchContainer" default="k2GoogleSearchContainer" />
<field name="K2UserProfile" default="1" />
<field name="K2UserGroup" default="" />
<field name="redirect" default="" />
<field name="adminSearch" default="simple" />
<field name="cookieDomain" default="" />
<field name="gatherStatistics" default="1" />
<!-- ######################### Tag System Settings ######################### -->
<field name="taggingSystem" default="1" />
<field name="lockTags" default="0" />
<field name="showTagFilter" default="0" />
<field name="k2TagNorm" default="0" />
<field name="k2TagNormCase" default="lower" />
<field name="k2TagNormAdditionalReplacements" default="" />
<!-- ######################### Anti-spam Settings ######################### -->
<field name="recaptcha_public_key" default="" />
<field name="recaptcha_private_key" default="" />
<field name="recaptcha_theme" default="clean" />
<field name="recaptchaOnRegistration" default="0" />
<field name="stopForumSpam" default="0" />
<field name="stopForumSpamApiKey" default="" />
<field name="profilePageDisplay" default="" />
<!-- ######################### Performance Settings ######################### -->
<field name="showItemsCounterAdmin" default="1" />
<field name="showChildCatItems" default="1" />
<field name="disableCompactOrdering" default="0" />
<!-- ######################### SEO Settings ######################### -->
<field name="metaDescLimit" default="150" />
<field name="enforceSEFReplacements" default="0" />
<field name="SEFReplacements" default="" />
<!-- ######################### Advanced SEF Settings ######################### -->
<field name="k2Sef" default="0" />
<field name="k2SefLabelCat" default="content" />
<field name="k2SefLabelTag" default="tag" />
<field name="k2SefLabelUser" default="author" />
<field name="k2SefLabelSearch" default="search" />
<field name="k2SefLabelDate" default="date" />
<field name="k2SefLabelItem" default="0" />
<field name="k2SefLabelItemCustomPrefix" default="" />
<field name="k2SefInsertItemId" default="1" />
<field name="k2SefItemIdTitleAliasSep" default="dash" />
<field name="k2SefUseItemTitleAlias" default="1" />
<field name="k2SefInsertCatId" default="1" />
<field name="k2SefCatIdTitleAliasSep" default="dash" />
<field name="k2SefUseCatTitleAlias" default="1" />
</fieldset>
</fields>
</config>
<modules>
<module module="mod_k2_comments" client="site" />
<module module="mod_k2_content" client="site" />
<module module="mod_k2_tools" client="site" />
<module module="mod_k2_users" client="site" />
<module module="mod_k2_user" client="site" />
<module module="mod_k2_quickicons" client="administrator" />
<module module="mod_k2_stats" client="administrator" />
</modules>
<plugins>
<plugin plugin="k2" group="finder" />
<plugin plugin="k2" group="search" />
<plugin plugin="k2" group="system" />
<plugin plugin="k2" group="user" />
</plugins>
<joomfish>
<file>k2_attachments.xml</file>
<file>k2_categories.xml</file>
<file>k2_extra_fields.xml</file>
<file>k2_items.xml</file>
<file>k2_tags.xml</file>
<file>k2_users.xml</file>
</joomfish>
</extension>

View File

@ -0,0 +1,815 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id$
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
if(!defined('SERVICES_JSON_SLICE')) define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
if(!defined('SERVICES_JSON_IN_STR')) define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
if(!defined('SERVICES_JSON_IN_ARR')) define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
if(!defined('SERVICES_JSON_IN_OBJ')) define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
if(!defined('SERVICES_JSON_IN_CMT')) define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
if(!defined('SERVICES_JSON_LOOSE_TYPE')) define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
if(!defined('SERVICES_JSON_SUPPRESS_ERRORS')) define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
if(!class_exists('Services_JSON')){
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
}
if (!class_exists('Services_JSON_Error')) {
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
}

View File

@ -0,0 +1,536 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
/**
* Akismet anti-comment spam service
*
* The class in this package allows use of the {@link http://akismet.com Akismet} anti-comment spam service in any PHP5 application.
*
* This service performs a number of checks on submitted data and returns whether or not the data is likely to be spam.
*
* Please note that in order to use this class, you must have a vaild {@link http://wordpress.com/api-keys/ WordPress API key}. They are free for non/small-profit types and getting one will only take a couple of minutes.
*
* For commercial use, please {@link http://akismet.com/commercial/ visit the Akismet commercial licensing page}.
*
* Please be aware that this class is PHP5 only. Attempts to run it under PHP4 will most likely fail.
*
* See the Akismet class documentation page linked to below for usage information.
*
* @package akismet
* @author Alex Potsides, {@link http://www.achingbrain.net http://www.achingbrain.net}
* @version 0.5
* @copyright Alex Potsides, {@link http://www.achingbrain.net http://www.achingbrain.net}
* @license http://www.opensource.org/licenses/bsd-license.php BSD License
*/
/**
* The Akismet PHP5 Class
*
* This class takes the functionality from the Akismet WordPress plugin written by {@link http://photomatt.net/ Matt Mullenweg} and allows it to be integrated into any PHP5 application or website.
*
* The original plugin is {@link http://akismet.com/download/ available on the Akismet website}.
*
* <code>
* $akismet = new Akismet('http://www.example.com/blog/', 'aoeu1aoue');
* $akismet->setCommentAuthor($name);
* $akismet->setCommentAuthorEmail($email);
* $akismet->setCommentAuthorURL($url);
* $akismet->setCommentContent($comment);
* $akismet->setPermalink('http://www.example.com/blog/alex/someurl/');
*
* if($akismet->isCommentSpam())
* // store the comment but mark it as spam (in case of a mis-diagnosis)
* else
* // store the comment normally
* </code>
*
* Optionally you may wish to check if your WordPress API key is valid as in the example below.
*
* <code>
* $akismet = new Akismet('http://www.example.com/blog/', 'aoeu1aoue');
*
* if($akismet->isKeyValid()) {
* // api key is okay
* } else {
* // api key is invalid
* }
* </code>
*
* @package akismet
* @name Akismet
* @version 0.5
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
class Akismet
{
private $version = '0.5';
private $wordPressAPIKey;
private $blogURL;
private $comment;
private $apiPort;
private $akismetServer;
private $akismetVersion;
private $requestFactory;
// This prevents some potentially sensitive information from being sent accross the wire.
private $ignore = array(
'HTTP_COOKIE',
'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED_HOST',
'HTTP_MAX_FORWARDS',
'HTTP_X_FORWARDED_SERVER',
'REDIRECT_STATUS',
'SERVER_PORT',
'PATH',
'DOCUMENT_ROOT',
'SERVER_ADMIN',
'QUERY_STRING',
'PHP_SELF'
);
/**
* @param string $blogURL The URL of your blog.
* @param string $wordPressAPIKey WordPress API key.
*/
public function __construct($blogURL, $wordPressAPIKey)
{
$this->blogURL = $blogURL;
$this->wordPressAPIKey = $wordPressAPIKey;
// Set some default values
$this->apiPort = 80;
$this->akismetServer = 'rest.akismet.com';
$this->akismetVersion = '1.1';
$this->requestFactory = new SocketWriteReadFactory();
// Start to populate the comment data
$this->comment['blog'] = $blogURL;
if (isset($_SERVER['HTTP_USER_AGENT']))
{
$this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
}
if (isset($_SERVER['HTTP_REFERER']))
{
$this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
}
/*
* This is necessary if the server PHP5 is running on has been set up to run PHP4 and
* PHP5 concurently and is actually running through a separate proxy al a these instructions:
* http://www.schlitt.info/applications/blog/archives/83_How_to_run_PHP4_and_PHP_5_parallel.html
* and http://wiki.coggeshall.org/37.html
* Otherwise the user_ip appears as the IP address of the PHP4 server passing the requests to the
* PHP5 one...
*/
if (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR'))
{
$this->comment['user_ip'] = $_SERVER['REMOTE_ADDR'];
}
else
{
$this->comment['user_ip'] = getenv('HTTP_X_FORWARDED_FOR');
}
}
/**
* Makes a request to the Akismet service to see if the API key passed to the constructor is valid.
*
* Use this method if you suspect your API key is invalid.
*
* @return bool True is if the key is valid, false if not.
*/
public function isKeyValid()
{
// Check to see if the key is valid
$response = $this->sendRequest('key='.$this->wordPressAPIKey.'&blog='.$this->blogURL, $this->akismetServer, '/'.$this->akismetVersion.'/verify-key');
return $response[1] == 'valid';
}
// makes a request to the Akismet service
private function sendRequest($request, $host, $path)
{
$http_request = "POST ".$path." HTTP/1.0\r\n";
$http_request .= "Host: ".$host."\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n";
$http_request .= "Content-Length: ".strlen($request)."\r\n";
$http_request .= "User-Agent: Akismet PHP5 Class ".$this->version." | Akismet/1.11\r\n";
$http_request .= "\r\n";
$http_request .= $request;
$requestSender = $this->requestFactory->createRequestSender();
$response = $requestSender->send($host, $this->apiPort, $http_request);
return explode("\r\n\r\n", $response, 2);
}
// Formats the data for transmission
private function getQueryString()
{
foreach ($_SERVER as $key => $value)
{
if (!in_array($key, $this->ignore))
{
if ($key == 'REMOTE_ADDR')
{
$this->comment[$key] = $this->comment['user_ip'];
}
else
{
$this->comment[$key] = $value;
}
}
}
$query_string = '';
foreach ($this->comment as $key => $data)
{
if (!is_array($data))
{
$query_string .= $key.'='.urlencode(stripslashes($data)).'&';
}
}
return $query_string;
}
/**
* Tests for spam.
*
* Uses the web service provided by {@link http://www.akismet.com Akismet} to see whether or not the submitted comment is spam. Returns a boolean value.
*
* @return bool True if the comment is spam, false if not
* @throws Will throw an exception if the API key passed to the constructor is invalid.
*/
public function isCommentSpam()
{
$response = $this->sendRequest($this->getQueryString(), $this->wordPressAPIKey.'.rest.akismet.com', '/'.$this->akismetVersion.'/comment-check');
if ($response[1] == 'invalid' && !$this->isKeyValid())
{
throw new exception('The Wordpress API key passed to the Akismet constructor is invalid. Please obtain a valid one from http://wordpress.com/api-keys/');
}
return ($response[1] == 'true');
}
/**
* Submit spam that is incorrectly tagged as ham.
*
* Using this function will make you a good citizen as it helps Akismet to learn from its mistakes. This will improve the service for everybody.
*/
public function submitSpam()
{
$this->sendRequest($this->getQueryString(), $this->wordPressAPIKey.'.'.$this->akismetServer, '/'.$this->akismetVersion.'/submit-spam');
}
/**
* Submit ham that is incorrectly tagged as spam.
*
* Using this function will make you a good citizen as it helps Akismet to learn from its mistakes. This will improve the service for everybody.
*/
public function submitHam()
{
$this->sendRequest($this->getQueryString(), $this->wordPressAPIKey.'.'.$this->akismetServer, '/'.$this->akismetVersion.'/submit-ham');
}
/**
* To override the user IP address when submitting spam/ham later on
*
* @param string $userip An IP address. Optional.
*/
public function setUserIP($userip)
{
$this->comment['user_ip'] = $userip;
}
/**
* To override the referring page when submitting spam/ham later on
*
* @param string $referrer The referring page. Optional.
*/
public function setReferrer($referrer)
{
$this->comment['referrer'] = $referrer;
}
/**
* A permanent URL referencing the blog post the comment was submitted to.
*
* @param string $permalink The URL. Optional.
*/
public function setPermalink($permalink)
{
$this->comment['permalink'] = $permalink;
}
/**
* The type of comment being submitted.
*
* May be blank, comment, trackback, pingback, or a made up value like "registration" or "wiki".
*/
public function setCommentType($commentType)
{
$this->comment['comment_type'] = $commentType;
}
/**
* The name that the author submitted with the comment.
*/
public function setCommentAuthor($commentAuthor)
{
$this->comment['comment_author'] = $commentAuthor;
}
/**
* The email address that the author submitted with the comment.
*
* The address is assumed to be valid.
*/
public function setCommentAuthorEmail($authorEmail)
{
$this->comment['comment_author_email'] = $authorEmail;
}
/**
* The URL that the author submitted with the comment.
*/
public function setCommentAuthorURL($authorURL)
{
$this->comment['comment_author_url'] = $authorURL;
}
/**
* The comment's body text.
*/
public function setCommentContent($commentBody)
{
$this->comment['comment_content'] = $commentBody;
}
/**
* Lets you override the user agent used to submit the comment.
* you may wish to do this when submitting ham/spam.
* Defaults to $_SERVER['HTTP_USER_AGENT']
*/
public function setCommentUserAgent($userAgent)
{
$this->comment['user_agent'] = $userAgent;
}
/**
* Defaults to 80
*/
public function setAPIPort($apiPort)
{
$this->apiPort = $apiPort;
}
/**
* Defaults to rest.akismet.com
*/
public function setAkismetServer($akismetServer)
{
$this->akismetServer = $akismetServer;
}
/**
* Defaults to '1.1'
*
* @param string $akismetVersion
*/
public function setAkismetVersion($akismetVersion)
{
$this->akismetVersion = $akismetVersion;
}
/**
* Used by unit tests to mock transport layer
*
* @param AkismetRequestFactory $requestFactory
*/
public function setRequestFactory($requestFactory)
{
$this->requestFactory = $requestFactory;
}
}
/**
* Used internally by Akismet
*
* This class is used by Akismet to do the actual sending and receiving of data. It opens a connection to a remote host, sends some data and the reads the response and makes it available to the calling program.
*
* The code that makes up this class originates in the Akismet WordPress plugin, which is {@link http://akismet.com/download/ available on the Akismet website}.
*
* N.B. It is not necessary to call this class directly to use the Akismet class.
*
* @package akismet
* @name SocketWriteRead
* @version 0.5
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
class SocketWriteRead implements AkismetRequestSender
{
private $response;
private $errorNumber;
private $errorString;
public function __construct()
{
$this->errorNumber = 0;
$this->errorString = '';
}
/**
* Sends the data to the remote host.
*
* @param string $host The host to send/receive data.
* @param int $port The port on the remote host.
* @param string $request The data to send.
* @param int $responseLength The amount of data to read. Defaults to 1160 bytes.
* @throws An exception is thrown if a connection cannot be made to the remote host.
* @returns The server response
*/
public function send($host, $port, $request, $responseLength = 1160)
{
$response = '';
$fs = fsockopen($host, $port, $this->errorNumber, $this->errorString, 3);
if ($this->errorNumber != 0)
{
throw new Exception('Error connecting to host: '.$host.' Error number: '.$this->errorNumber.' Error message: '.$this->errorString);
}
if ($fs !== false)
{
@fwrite($fs, $request);
while (!feof($fs))
{
$response .= fgets($fs, $responseLength);
}
fclose($fs);
}
return $response;
}
/**
* Returns the server response text
*
* @return string
*/
public function getResponse()
{
return $this->response;
}
/**
* Returns the error number
*
* If there was no error, 0 will be returned.
*
* @return int
*/
public function getErrorNumner()
{
return $this->errorNumber;
}
/**
* Returns the error string
*
* If there was no error, an empty string will be returned.
*
* @return string
*/
public function getErrorString()
{
return $this->errorString;
}
}
/**
* Used internally by the Akismet class and to mock the Akismet anti spam service in
* the unit tests.
*
* N.B. It is not necessary to call this class directly to use the Akismet class.
*
* @package akismet
* @name SocketWriteReadFactory
* @version 0.5
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
class SocketWriteReadFactory implements AkismetRequestFactory
{
public function createRequestSender()
{
return new SocketWriteRead();
}
}
/**
* Used internally by the Akismet class and to mock the Akismet anti spam service in
* the unit tests.
*
* N.B. It is not necessary to implement this class to use the Akismet class.
*
* @package akismet
* @name AkismetRequestSender
* @version 0.5
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
interface AkismetRequestSender
{
/**
* Sends the data to the remote host.
*
* @param string $host The host to send/receive data.
* @param int $port The port on the remote host.
* @param string $request The data to send.
* @param int $responseLength The amount of data to read. Defaults to 1160 bytes.
* @throws An exception is thrown if a connection cannot be made to the remote host.
* @returns The server response
*/
public function send($host, $port, $request, $responseLength = 1160);
}
/**
* Used internally by the Akismet class and to mock the Akismet anti spam service in
* the unit tests.
*
* N.B. It is not necessary to implement this class to use the Akismet class.
*
* @package akismet
* @name AkismetRequestFactory
* @version 0.5
* @author Alex Potsides
* @link http://www.achingbrain.net/
*/
interface AkismetRequestFactory
{
public function createRequestSender();
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,143 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
/**
* Default elFinder connector
*
* @author Dmitry (dio) Levashov
**/
class elFinderConnector {
/**
* elFinder instance
*
* @var elFinder
**/
protected $elFinder;
/**
* Options
*
* @var aray
**/
protected $options = array();
/**
* undocumented class variable
*
* @var string
**/
protected $header = 'Content-Type: application/json';
/**
* Constructor
*
* @return void
* @author Dmitry (dio) Levashov
**/
public function __construct($elFinder, $debug=false) {
$this->elFinder = $elFinder;
if ($debug) {
$this->header = 'Content-Type: text/html; charset=utf-8';
}
}
/**
* Execute elFinder command and output result
*
* @return void
* @author Dmitry (dio) Levashov
**/
public function run() {
$isPost = $_SERVER["REQUEST_METHOD"] == 'POST';
$src = $_SERVER["REQUEST_METHOD"] == 'POST' ? $_POST : $_GET;
$cmd = isset($src['cmd']) ? $src['cmd'] : '';
$args = array();
if (!function_exists('json_encode')) {
$error = $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_JSON);
$this->output(array('error' => '{"error":["'.implode('","', $error).'"]}', 'raw' => true));
}
if (!$this->elFinder->loaded()) {
$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_CONF, elFinder::ERROR_CONF_NO_VOL), 'debug' => $this->elFinder->mountErrors));
}
// telepat_mode: on
if (!$cmd && $isPost) {
$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UPLOAD, elFinder::ERROR_UPLOAD_TOTAL_SIZE), 'header' => 'Content-Type: text/html'));
}
// telepat_mode: off
if (!$this->elFinder->commandExists($cmd)) {
$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_UNKNOWN_CMD)));
}
// collect required arguments to exec command
foreach ($this->elFinder->commandArgsList($cmd) as $name => $req) {
$arg = $name == 'FILES'
? $_FILES
: (isset($src[$name]) ? $src[$name] : '');
if (!is_array($arg)) {
$arg = trim($arg);
}
if ($req && (!isset($arg) || $arg === '')) {
$this->output(array('error' => $this->elFinder->error(elFinder::ERROR_INV_PARAMS, $cmd)));
}
$args[$name] = $arg;
}
$args['debug'] = isset($src['debug']) ? !!$src['debug'] : false;
$this->output($this->elFinder->exec($cmd, $args));
}
/**
* Output json
*
* @param array data to output
* @return void
* @author Dmitry (dio) Levashov
**/
protected function output(array $data) {
$header = isset($data['header']) ? $data['header'] : $this->header;
unset($data['header']);
if ($header) {
if (is_array($header)) {
foreach ($header as $h) {
header($h);
}
} else {
header($header);
}
}
if (isset($data['pointer'])) {
rewind($data['pointer']);
fpassthru($data['pointer']);
if (!empty($data['volume'])) {
$data['volume']->close($data['pointer'], $data['info']['hash']);
}
exit();
} else {
if (!empty($data['raw']) && !empty($data['error'])) {
exit($data['error']);
} else {
exit(json_encode($data));
}
}
}
}// END class

View File

@ -0,0 +1,845 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
/**
* elFinder driver for local filesystem.
*
* @author Dmitry (dio) Levashov
* @author Troex Nevelin
**/
class elFinderVolumeLocalFileSystem extends elFinderVolumeDriver {
/**
* Driver id
* Must be started from letter and contains [a-z0-9]
* Used as part of volume id
*
* @var string
**/
protected $driverId = 'l';
/**
* Required to count total archive files size
*
* @var int
**/
protected $archiveSize = 0;
/**
* Constructor
* Extend options with required fields
*
* @return void
* @author Dmitry (dio) Levashov
**/
public function __construct() {
$this->options['alias'] = ''; // alias to replace root dir name
$this->options['dirMode'] = 0755; // new dirs mode
$this->options['fileMode'] = 0644; // new files mode
$this->options['quarantine'] = '.quarantine'; // quarantine folder name - required to check archive (must be hidden)
$this->options['maxArcFilesSize'] = 0; // max allowed archive files size (0 - no limit)
}
/*********************************************************************/
/* INIT AND CONFIGURE */
/*********************************************************************/
/**
* Configure after successfull mount.
*
* @return void
* @author Dmitry (dio) Levashov
**/
protected function configure() {
$this->aroot = realpath($this->root);
$root = $this->stat($this->root);
if ($this->options['quarantine']) {
$this->attributes[] = array(
'pattern' => '~^'.preg_quote(DIRECTORY_SEPARATOR.$this->options['quarantine']).'$~',
'read' => false,
'write' => false,
'locked' => true,
'hidden' => true
);
}
// chek thumbnails path
if ($this->options['tmbPath']) {
$this->options['tmbPath'] = strpos($this->options['tmbPath'], DIRECTORY_SEPARATOR) === false
// tmb path set as dirname under root dir
? $this->root.DIRECTORY_SEPARATOR.$this->options['tmbPath']
// tmb path as full path
: $this->_normpath($this->options['tmbPath']);
}
parent::configure();
// if no thumbnails url - try detect it
if ($root['read'] && !$this->tmbURL && $this->URL) {
if (strpos($this->tmbPath, $this->root) === 0) {
$this->tmbURL = $this->URL.str_replace(DIRECTORY_SEPARATOR, '/', substr($this->tmbPath, strlen($this->root)+1));
if (preg_match("|[^/?&=]$|", $this->tmbURL)) {
$this->tmbURL .= '/';
}
}
}
// check quarantine dir
if (!empty($this->options['quarantine'])) {
$this->quarantine = $this->root.DIRECTORY_SEPARATOR.$this->options['quarantine'];
if ((!is_dir($this->quarantine) && !$this->_mkdir($this->root, $this->options['quarantine'])) || !is_writable($this->quarantine)) {
$this->archivers['extract'] = array();
$this->disabled[] = 'extract';
}
} else {
$this->archivers['extract'] = array();
$this->disabled[] = 'extract';
}
}
/*********************************************************************/
/* FS API */
/*********************************************************************/
/*********************** paths/urls *************************/
/**
* Return parent directory path
*
* @param string $path file path
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _dirname($path) {
return dirname($path);
}
/**
* Return file name
*
* @param string $path file path
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _basename($path) {
return basename($path);
}
/**
* Join dir name and file name and retur full path
*
* @param string $dir
* @param string $name
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _joinPath($dir, $name) {
return $dir.DIRECTORY_SEPARATOR.$name;
}
/**
* Return normalized path, this works the same as os.path.normpath() in Python
*
* @param string $path path
* @return string
* @author Troex Nevelin
**/
protected function _normpath($path) {
if (empty($path)) {
return '.';
}
if (strpos($path, '/') === 0) {
$initial_slashes = true;
} else {
$initial_slashes = false;
}
if (($initial_slashes)
&& (strpos($path, '//') === 0)
&& (strpos($path, '///') === false)) {
$initial_slashes = 2;
}
$initial_slashes = (int) $initial_slashes;
$comps = explode('/', $path);
$new_comps = array();
foreach ($comps as $comp) {
if (in_array($comp, array('', '.'))) {
continue;
}
if (($comp != '..')
|| (!$initial_slashes && !$new_comps)
|| ($new_comps && (end($new_comps) == '..'))) {
array_push($new_comps, $comp);
} elseif ($new_comps) {
array_pop($new_comps);
}
}
$comps = $new_comps;
$path = implode('/', $comps);
if ($initial_slashes) {
$path = str_repeat('/', $initial_slashes) . $path;
}
return $path ? $path : '.';
}
/**
* Return file path related to root dir
*
* @param string $path file path
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _relpath($path) {
return $path == $this->root ? '' : substr($path, strlen($this->root)+1);
}
/**
* Convert path related to root dir into real path
*
* @param string $path file path
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _abspath($path) {
return $path == DIRECTORY_SEPARATOR ? $this->root : $this->root.DIRECTORY_SEPARATOR.$path;
}
/**
* Return fake path started from root dir
*
* @param string $path file path
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _path($path) {
return $this->rootName.($path == $this->root ? '' : $this->separator.$this->_relpath($path));
}
/**
* Return true if $path is children of $parent
*
* @param string $path path to check
* @param string $parent parent path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _inpath($path, $parent) {
return $path == $parent || strpos($path, $parent.DIRECTORY_SEPARATOR) === 0;
}
/***************** file stat ********************/
/**
* Return stat for given path.
* Stat contains following fields:
* - (int) size file size in b. required
* - (int) ts file modification time in unix time. required
* - (string) mime mimetype. required for folders, others - optionally
* - (bool) read read permissions. required
* - (bool) write write permissions. required
* - (bool) locked is object locked. optionally
* - (bool) hidden is object hidden. optionally
* - (string) alias for symlinks - link target path relative to root path. optionally
* - (string) target for symlinks - link target path. optionally
*
* If file does not exists - returns empty array or false.
*
* @param string $path file path
* @return array|false
* @author Dmitry (dio) Levashov
**/
protected function _stat($path) {
$stat = array();
if (!file_exists($path)) {
return $stat;
}
if ($path != $this->root && is_link($path)) {
if (($target = $this->readlink($path)) == false
|| $target == $path) {
$stat['mime'] = 'symlink-broken';
$stat['read'] = false;
$stat['write'] = false;
$stat['size'] = 0;
return $stat;
}
$stat['alias'] = $this->_path($target);
$stat['target'] = $target;
$path = $target;
$lstat = lstat($path);
$size = $lstat['size'];
} else {
$size = @filesize($path);
}
$dir = is_dir($path);
$stat['mime'] = $dir ? 'directory' : $this->mimetype($path);
$stat['ts'] = filemtime($path);
$stat['read'] = is_readable($path);
$stat['write'] = is_writable($path);
if ($stat['read']) {
$stat['size'] = $dir ? 0 : $size;
}
return $stat;
}
/**
* Return true if path is dir and has at least one childs directory
*
* @param string $path dir path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _subdirs($path) {
if (($dir = dir($path))) {
$dir = dir($path);
while (($entry = $dir->read()) !== false) {
$p = $dir->path.DIRECTORY_SEPARATOR.$entry;
if ($entry != '.' && $entry != '..' && is_dir($p) && !$this->attr($p, 'hidden')) {
$dir->close();
return true;
}
}
$dir->close();
}
return false;
}
/**
* Return object width and height
* Ususaly used for images, but can be realize for video etc...
*
* @param string $path file path
* @param string $mime file mime type
* @return string
* @author Dmitry (dio) Levashov
**/
protected function _dimensions($path, $mime) {
clearstatcache();
return strpos($mime, 'image') === 0 && ($s = @getimagesize($path)) !== false
? $s[0].'x'.$s[1]
: false;
}
/******************** file/dir content *********************/
/**
* Return symlink target file
*
* @param string $path link path
* @return string
* @author Dmitry (dio) Levashov
**/
protected function readlink($path) {
if (!($target = @readlink($path))) {
return false;
}
if (substr($target, 0, 1) != DIRECTORY_SEPARATOR) {
$target = dirname($path).DIRECTORY_SEPARATOR.$target;
}
$atarget = realpath($target);
if (!$atarget) {
return false;
}
$root = $this->root;
$aroot = $this->aroot;
if ($this->_inpath($atarget, $this->aroot)) {
return $this->_normpath($this->root.DIRECTORY_SEPARATOR.substr($atarget, strlen($this->aroot)+1));
}
return false;
}
/**
* Return files list in directory.
*
* @param string $path dir path
* @return array
* @author Dmitry (dio) Levashov
**/
protected function _scandir($path) {
$files = array();
foreach (scandir($path) as $name) {
if ($name != '.' && $name != '..') {
$files[] = $path.DIRECTORY_SEPARATOR.$name;
}
}
return $files;
}
/**
* Open file and return file pointer
*
* @param string $path file path
* @param bool $write open file for writing
* @return resource|false
* @author Dmitry (dio) Levashov
**/
protected function _fopen($path, $mode='rb') {
return @fopen($path, 'r');
}
/**
* Close opened file
*
* @param resource $fp file pointer
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _fclose($fp, $path='') {
return @fclose($fp);
}
/******************** file/dir manipulations *************************/
/**
* Create dir and return created dir path or false on failed
*
* @param string $path parent dir path
* @param string $name new directory name
* @return string|bool
* @author Dmitry (dio) Levashov
**/
protected function _mkdir($path, $name) {
$path = $path.DIRECTORY_SEPARATOR.$name;
if (@mkdir($path)) {
@chmod($path, $this->options['dirMode']);
return $path;
}
return false;
}
/**
* Create file and return it's path or false on failed
*
* @param string $path parent dir path
* @param string $name new file name
* @return string|bool
* @author Dmitry (dio) Levashov
**/
protected function _mkfile($path, $name) {
$path = $path.DIRECTORY_SEPARATOR.$name;
if (($fp = @fopen($path, 'w'))) {
@fclose($fp);
@chmod($path, $this->options['fileMode']);
return $path;
}
return false;
}
/**
* Create symlink
*
* @param string $source file to link to
* @param string $targetDir folder to create link in
* @param string $name symlink name
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _symlink($source, $targetDir, $name) {
return @symlink($source, $targetDir.DIRECTORY_SEPARATOR.$name);
}
/**
* Copy file into another file
*
* @param string $source source file path
* @param string $targetDir target directory path
* @param string $name new file name
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _copy($source, $targetDir, $name) {
return copy($source, $targetDir.DIRECTORY_SEPARATOR.$name);
}
/**
* Move file into another parent dir.
* Return new file path or false.
*
* @param string $source source file path
* @param string $target target dir path
* @param string $name file name
* @return string|bool
* @author Dmitry (dio) Levashov
**/
protected function _move($source, $targetDir, $name) {
$target = $targetDir.DIRECTORY_SEPARATOR.$name;
return @rename($source, $target) ? $target : false;
}
/**
* Remove file
*
* @param string $path file path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _unlink($path) {
return @unlink($path);
}
/**
* Remove dir
*
* @param string $path dir path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _rmdir($path) {
return @rmdir($path);
}
/**
* Create new file and write into it from file pointer.
* Return new file path or false on error.
*
* @param resource $fp file pointer
* @param string $dir target dir path
* @param string $name file name
* @return bool|string
* @author Dmitry (dio) Levashov
**/
protected function _save($fp, $dir, $name, $mime, $w, $h) {
$path = $dir.DIRECTORY_SEPARATOR.$name;
if (!($target = @fopen($path, 'wb'))) {
return false;
}
while (!feof($fp)) {
fwrite($target, fread($fp, 8192));
}
fclose($target);
@chmod($path, $this->options['fileMode']);
clearstatcache();
return $path;
}
/**
* Get file contents
*
* @param string $path file path
* @return string|false
* @author Dmitry (dio) Levashov
**/
protected function _getContents($path) {
return file_get_contents($path);
}
/**
* Write a string to a file
*
* @param string $path file path
* @param string $content new file content
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _filePutContents($path, $content) {
if (@file_put_contents($path, $content, LOCK_EX) !== false) {
clearstatcache();
return true;
}
return false;
}
/**
* Detect available archivers
*
* @return void
**/
protected function _checkArchivers() {
if (!function_exists('exec')) {
$this->options['archivers'] = $this->options['archive'] = array();
return;
}
$arcs = array(
'create' => array(),
'extract' => array()
);
//exec('tar --version', $o, $ctar);
$this->procExec('tar --version', $o, $ctar);
if ($ctar == 0) {
$arcs['create']['application/x-tar'] = array('cmd' => 'tar', 'argc' => '-cf', 'ext' => 'tar');
$arcs['extract']['application/x-tar'] = array('cmd' => 'tar', 'argc' => '-xf', 'ext' => 'tar');
//$test = exec('gzip --version', $o, $c);
unset($o);
$test = $this->procExec('gzip --version', $o, $c);
if ($c == 0) {
$arcs['create']['application/x-gzip'] = array('cmd' => 'tar', 'argc' => '-czf', 'ext' => 'tgz');
$arcs['extract']['application/x-gzip'] = array('cmd' => 'tar', 'argc' => '-xzf', 'ext' => 'tgz');
}
unset($o);
//$test = exec('bzip2 --version', $o, $c);
$test = $this->procExec('bzip2 --version', $o, $c);
if ($c == 0) {
$arcs['create']['application/x-bzip2'] = array('cmd' => 'tar', 'argc' => '-cjf', 'ext' => 'tbz');
$arcs['extract']['application/x-bzip2'] = array('cmd' => 'tar', 'argc' => '-xjf', 'ext' => 'tbz');
}
}
unset($o);
//exec('zip --version', $o, $c);
$this->procExec('zip -v', $o, $c);
if ($c == 0) {
$arcs['create']['application/zip'] = array('cmd' => 'zip', 'argc' => '-r9', 'ext' => 'zip');
}
unset($o);
$this->procExec('unzip --help', $o, $c);
if ($c == 0) {
$arcs['extract']['application/zip'] = array('cmd' => 'unzip', 'argc' => '', 'ext' => 'zip');
}
unset($o);
//exec('rar --version', $o, $c);
$this->procExec('rar --version', $o, $c);
if ($c == 0 || $c == 7) {
$arcs['create']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'a -inul', 'ext' => 'rar');
$arcs['extract']['application/x-rar'] = array('cmd' => 'rar', 'argc' => 'x -y', 'ext' => 'rar');
} else {
unset($o);
//$test = exec('unrar', $o, $c);
$test = $this->procExec('unrar', $o, $c);
if ($c==0 || $c == 7) {
$arcs['extract']['application/x-rar'] = array('cmd' => 'unrar', 'argc' => 'x -y', 'ext' => 'rar');
}
}
unset($o);
//exec('7za --help', $o, $c);
$this->procExec('7za --help', $o, $c);
if ($c == 0) {
$arcs['create']['application/x-7z-compressed'] = array('cmd' => '7za', 'argc' => 'a', 'ext' => '7z');
$arcs['extract']['application/x-7z-compressed'] = array('cmd' => '7za', 'argc' => 'e -y', 'ext' => '7z');
if (empty($arcs['create']['application/x-gzip'])) {
$arcs['create']['application/x-gzip'] = array('cmd' => '7za', 'argc' => 'a -tgzip', 'ext' => 'tar.gz');
}
if (empty($arcs['extract']['application/x-gzip'])) {
$arcs['extract']['application/x-gzip'] = array('cmd' => '7za', 'argc' => 'e -tgzip -y', 'ext' => 'tar.gz');
}
if (empty($arcs['create']['application/x-bzip2'])) {
$arcs['create']['application/x-bzip2'] = array('cmd' => '7za', 'argc' => 'a -tbzip2', 'ext' => 'tar.bz');
}
if (empty($arcs['extract']['application/x-bzip2'])) {
$arcs['extract']['application/x-bzip2'] = array('cmd' => '7za', 'argc' => 'a -tbzip2 -y', 'ext' => 'tar.bz');
}
if (empty($arcs['create']['application/zip'])) {
$arcs['create']['application/zip'] = array('cmd' => '7za', 'argc' => 'a -tzip -l', 'ext' => 'zip');
}
if (empty($arcs['extract']['application/zip'])) {
$arcs['extract']['application/zip'] = array('cmd' => '7za', 'argc' => 'e -tzip -y', 'ext' => 'zip');
}
if (empty($arcs['create']['application/x-tar'])) {
$arcs['create']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'a -ttar -l', 'ext' => 'tar');
}
if (empty($arcs['extract']['application/x-tar'])) {
$arcs['extract']['application/x-tar'] = array('cmd' => '7za', 'argc' => 'e -ttar -y', 'ext' => 'tar');
}
}
$this->archivers = $arcs;
}
/**
* Unpack archive
*
* @param string $path archive path
* @param array $arc archiver command and arguments (same as in $this->archivers)
* @return void
* @author Dmitry (dio) Levashov
* @author Alexey Sukhotin
**/
protected function _unpack($path, $arc) {
$cwd = getcwd();
$dir = $this->_dirname($path);
chdir($dir);
$cmd = $arc['cmd'].' '.$arc['argc'].' '.escapeshellarg($this->_basename($path));
$this->procExec($cmd, $o, $c);
chdir($cwd);
}
/**
* Recursive symlinks search
*
* @param string $path file/dir path
* @return bool
* @author Dmitry (dio) Levashov
**/
protected function _findSymlinks($path) {
if (is_link($path)) {
return true;
}
if (is_dir($path)) {
foreach (scandir($path) as $name) {
if ($name != '.' && $name != '..') {
$p = $path.DIRECTORY_SEPARATOR.$name;
if (is_link($p)) {
return true;
}
if (is_dir($p) && $this->_findSymlinks($p)) {
return true;
} elseif (is_file($p)) {
$this->archiveSize += filesize($p);
}
}
}
} else {
$this->archiveSize += filesize($path);
}
return false;
}
/**
* Extract files from archive
*
* @param string $path archive path
* @param array $arc archiver command and arguments (same as in $this->archivers)
* @return true
* @author Dmitry (dio) Levashov,
* @author Alexey Sukhotin
**/
protected function _extract($path, $arc) {
if ($this->quarantine) {
$dir = $this->quarantine.DIRECTORY_SEPARATOR.str_replace(' ', '_', microtime()).basename($path);
$archive = $dir.DIRECTORY_SEPARATOR.basename($path);
if (!@mkdir($dir)) {
return false;
}
chmod($dir, 0755);
// copy in quarantine
if (!copy($path, $archive)) {
return false;
}
// extract in quarantine
$this->_unpack($archive, $arc);
@unlink($archive);
// get files list
$ls = array();
foreach (scandir($dir) as $i => $name) {
if ($name != '.' && $name != '..') {
$ls[] = $name;
}
}
// no files - extract error ?
if (empty($ls)) {
return false;
}
$this->archiveSize = 0;
// find symlinks
$symlinks = $this->_findSymlinks($dir);
// remove arc copy
$this->remove($dir);
if ($symlinks) {
return $this->setError(elFinder::ERROR_ARC_SYMLINKS);
}
// check max files size
if ($this->options['maxArcFilesSize'] > 0 && $this->options['maxArcFilesSize'] < $this->archiveSize) {
return $this->setError(elFinder::ERROR_ARC_MAXSIZE);
}
// archive contains one item - extract in archive dir
if (count($ls) == 1) {
$this->_unpack($path, $arc);
$result = dirname($path).DIRECTORY_SEPARATOR.$ls[0];
} else {
// for several files - create new directory
// create unique name for directory
$name = basename($path);
if (preg_match('/\.((tar\.(gz|bz|bz2|z|lzo))|cpio\.gz|ps\.gz|xcf\.(gz|bz2)|[a-z0-9]{1,4})$/i', $name, $m)) {
$name = substr($name, 0, strlen($name)-strlen($m[0]));
}
$test = dirname($path).DIRECTORY_SEPARATOR.$name;
if (file_exists($test) || is_link($test)) {
$name = $this->uniqueName(dirname($path), $name, '-', false);
}
$result = dirname($path).DIRECTORY_SEPARATOR.$name;
$archive = $result.DIRECTORY_SEPARATOR.basename($path);
if (!$this->_mkdir(dirname($path), $name) || !copy($path, $archive)) {
return false;
}
$this->_unpack($archive, $arc);
@unlink($archive);
}
return file_exists($result) ? $result : false;
}
}
/**
* Create archive and return its path
*
* @param string $dir target dir
* @param array $files files names list
* @param string $name archive name
* @param array $arc archiver options
* @return string|bool
* @author Dmitry (dio) Levashov,
* @author Alexey Sukhotin
**/
protected function _archive($dir, $files, $name, $arc) {
$cwd = getcwd();
chdir($dir);
$files = array_map('escapeshellarg', $files);
$cmd = $arc['cmd'].' '.$arc['argc'].' '.escapeshellarg($name).' '.implode(' ', $files);
$this->procExec($cmd, $o, $c);
chdir($cwd);
$path = $dir.DIRECTORY_SEPARATOR.$name;
return file_exists($path) ? $path : false;
}
} // END class

View File

@ -0,0 +1,512 @@
# This file controls what Internet media types are sent to the client for
# given file extension(s). Sending the correct media type to the client
# is important so they know how to handle the content of the file.
# For more information about Internet media types, please read
# RFC 2045, 2046, 2047, 2048, and 2077. The Internet media type
# registry is at <ftp://ftp.iana.org/assignments/media-types/>.
# MIME type Extension
application/andrew-inset ez
application/chemtool cht
application/dicom dcm
application/docbook+xml docbook
application/ecmascript ecma
application/flash-video flv
application/illustrator ai
application/javascript js
application/mac-binhex40
application/mathematica nb
application/msword doc
application/octet-stream bin
application/oda oda
application/ogg ogg
application/pdf pdf
application/pgp pgp
application/pgp-encrypted
application/pgp-encrypted pgp gpg
application/pgp-keys
application/pgp-keys skr pkr
application/pgp-signature
application/pgp-signature sig
application/pkcs7-mime
application/pkcs7-signature p7s
application/postscript ps
application/rtf rtf
application/sdp sdp
application/smil smil smi sml
application/stuffit sit
application/vnd.corel-draw cdr
application/vnd.hp-hpgl hpgl
application/vnd.hp-pcl pcl
application/vnd.lotus-1-2-3 123 wk1 wk3 wk4 wks
application/vnd.mozilla.xul+xml xul
application/vnd.ms-excel xls xlc xll xlm xlw xla xlt xld
application/vnd.ms-powerpoint ppz ppt pps pot
application/vnd.oasis.opendocument.chart odc
application/vnd.oasis.opendocument.database odb
application/vnd.oasis.opendocument.formula odf
application/vnd.oasis.opendocument.graphics odg
application/vnd.oasis.opendocument.graphics-template otg
application/vnd.oasis.opendocument.image odi
application/vnd.oasis.opendocument.presentation odp
application/vnd.oasis.opendocument.presentation-template otp
application/vnd.oasis.opendocument.spreadsheet ods
application/vnd.oasis.opendocument.spreadsheet-template ots
application/vnd.oasis.opendocument.text odt
application/vnd.oasis.opendocument.text-master odm
application/vnd.oasis.opendocument.text-template ott
application/vnd.oasis.opendocument.text-web oth
application/vnd.palm pdb
application/vnd.rn-realmedia
application/vnd.rn-realmedia rm
application/vnd.rn-realmedia-secure rms
application/vnd.rn-realmedia-vbr rmvb
application/vnd.stardivision.calc sdc
application/vnd.stardivision.chart sds
application/vnd.stardivision.draw sda
application/vnd.stardivision.impress sdd sdp
application/vnd.stardivision.mail smd
application/vnd.stardivision.math smf
application/vnd.stardivision.writer sdw vor sgl
application/vnd.sun.xml.calc sxc
application/vnd.sun.xml.calc.template stc
application/vnd.sun.xml.draw sxd
application/vnd.sun.xml.draw.template std
application/vnd.sun.xml.impress sxi
application/vnd.sun.xml.impress.template sti
application/vnd.sun.xml.math sxm
application/vnd.sun.xml.writer sxw
application/vnd.sun.xml.writer.global sxg
application/vnd.sun.xml.writer.template stw
application/vnd.wordperfect wpd
application/x-abiword abw abw.CRASHED abw.gz zabw
application/x-amipro sam
application/x-anjuta-project prj
application/x-applix-spreadsheet as
application/x-applix-word aw
application/x-arc
application/x-archive a
application/x-arj arj
application/x-asax asax
application/x-ascx ascx
application/x-ashx ashx
application/x-asix asix
application/x-asmx asmx
application/x-asp asp
application/x-awk
application/x-axd axd
application/x-bcpio bcpio
application/x-bittorrent torrent
application/x-blender blender blend BLEND
application/x-bzip bz bz2
application/x-bzip bz2 bz
application/x-bzip-compressed-tar tar.bz tar.bz2
application/x-bzip-compressed-tar tar.bz tar.bz2 tbz tbz2
application/x-cd-image iso
application/x-cgi cgi
application/x-chess-pgn pgn
application/x-chm chm
application/x-class-file
application/x-cmbx cmbx
application/x-compress Z
application/x-compressed-tar tar.gz tar.Z tgz taz
application/x-compressed-tar tar.gz tgz
application/x-config config
application/x-core
application/x-cpio cpio
application/x-cpio-compressed cpio.gz
application/x-csh csh
application/x-cue cue
application/x-dbase dbf
application/x-dbm
application/x-dc-rom dc
application/x-deb deb
application/x-designer ui
application/x-desktop desktop kdelnk
application/x-devhelp devhelp
application/x-dia-diagram dia
application/x-disco disco
application/x-dvi dvi
application/x-e-theme etheme
application/x-egon egon
application/x-executable exe
application/x-font-afm afm
application/x-font-bdf bdf
application/x-font-dos
application/x-font-framemaker
application/x-font-libgrx
application/x-font-linux-psf psf
application/x-font-otf
application/x-font-pcf pcf
application/x-font-pcf pcf.gz
application/x-font-speedo spd
application/x-font-sunos-news
application/x-font-tex
application/x-font-tex-tfm
application/x-font-ttf ttc TTC
application/x-font-ttf ttf
application/x-font-type1 pfa pfb gsf pcf.Z
application/x-font-vfont
application/x-frame
application/x-frontline aop
application/x-gameboy-rom gb
application/x-gdbm
application/x-gdesklets-display display
application/x-genesis-rom gen md
application/x-gettext-translation gmo
application/x-glabels glabels
application/x-glade glade
application/x-gmc-link
application/x-gnome-db-connection connection
application/x-gnome-db-database database
application/x-gnome-stones caves
application/x-gnucash gnucash gnc xac
application/x-gnumeric gnumeric
application/x-graphite gra
application/x-gtar gtar
application/x-gtktalog
application/x-gzip gz
application/x-gzpostscript ps.gz
application/x-hdf hdf
application/x-ica ica
application/x-ipod-firmware
application/x-jamin jam
application/x-jar jar
application/x-java class
application/x-java-archive jar ear war
application/x-jbuilder-project jpr jpx
application/x-karbon karbon
application/x-kchart chrt
application/x-kformula kfo
application/x-killustrator kil
application/x-kivio flw
application/x-kontour kon
application/x-kpovmodeler kpm
application/x-kpresenter kpr kpt
application/x-krita kra
application/x-kspread ksp
application/x-kspread-crypt
application/x-ksysv-package
application/x-kugar kud
application/x-kword kwd kwt
application/x-kword-crypt
application/x-lha lha lzh
application/x-lha lzh
application/x-lhz lhz
application/x-linguist ts
application/x-lyx lyx
application/x-lzop lzo
application/x-lzop-compressed-tar tar.lzo tzo
application/x-macbinary
application/x-machine-config
application/x-magicpoint mgp
application/x-master-page master
application/x-matroska mkv
application/x-mdp mdp
application/x-mds mds
application/x-mdsx mdsx
application/x-mergeant mergeant
application/x-mif mif
application/x-mozilla-bookmarks
application/x-mps mps
application/x-ms-dos-executable exe
application/x-mswinurl
application/x-mswrite wri
application/x-msx-rom msx
application/x-n64-rom n64
application/x-nautilus-link
application/x-nes-rom nes
application/x-netcdf cdf nc
application/x-netscape-bookmarks
application/x-object o
application/x-ole-storage
application/x-oleo oleo
application/x-palm-database
application/x-palm-database pdb prc
application/x-par2 PAR2 par2
application/x-pef-executable
application/x-perl pl pm al perl
application/x-php php php3 php4
application/x-pkcs12 p12 pfx
application/x-planner planner mrproject
application/x-planperfect pln
application/x-prjx prjx
application/x-profile
application/x-ptoptimizer-script pto
application/x-pw pw
application/x-python-bytecode pyc pyo
application/x-quattro-pro wb1 wb2 wb3
application/x-quattropro wb1 wb2 wb3
application/x-qw qif
application/x-rar rar
application/x-rar-compressed rar
application/x-rdp rdp
application/x-reject rej
application/x-remoting rem
application/x-resources resources
application/x-resourcesx resx
application/x-rpm rpm
application/x-ruby
application/x-sc
application/x-sc sc
application/x-scribus sla sla.gz scd scd.gz
application/x-shar shar
application/x-shared-library-la la
application/x-sharedlib so
application/x-shellscript sh
application/x-shockwave-flash swf
application/x-siag siag
application/x-slp
application/x-smil kino
application/x-smil smi smil
application/x-sms-rom sms gg
application/x-soap-remoting soap
application/x-streamingmedia ssm
application/x-stuffit
application/x-stuffit bin sit
application/x-sv4cpio sv4cpio
application/x-sv4crc sv4crc
application/x-tar tar
application/x-tarz tar.Z
application/x-tex-gf gf
application/x-tex-pk k
application/x-tgif obj
application/x-theme theme
application/x-toc toc
application/x-toutdoux
application/x-trash bak old sik
application/x-troff tr roff t
application/x-troff-man man
application/x-troff-man-compressed
application/x-tzo tar.lzo tzo
application/x-ustar ustar
application/x-wais-source src
application/x-web-config
application/x-wpg wpg
application/x-wsdl wsdl
application/x-x509-ca-cert der cer crt cert pem
application/x-xbel xbel
application/x-zerosize
application/x-zoo zoo
application/xhtml+xml xhtml
application/zip zip
audio/ac3 ac3
audio/basic au snd
audio/midi mid midi
audio/mpeg mp3
audio/prs.sid sid psid
audio/vnd.rn-realaudio ra
audio/x-aac aac
audio/x-adpcm
audio/x-aifc
audio/x-aiff aif aiff
audio/x-aiff aiff aif aifc
audio/x-aiffc
audio/x-flac flac
audio/x-m4a m4a
audio/x-mod mod ult uni XM m15 mtm 669
audio/x-mp3-playlist
audio/x-mpeg
audio/x-mpegurl m3u
audio/x-ms-asx
audio/x-pn-realaudio ra ram rm
audio/x-pn-realaudio ram rmm
audio/x-riff
audio/x-s3m s3m
audio/x-scpls pls
audio/x-scpls pls xpl
audio/x-stm stm
audio/x-voc voc
audio/x-wav wav
audio/x-xi xi
audio/x-xm xm
image/bmp bmp
image/cgm cgm
image/dpx
image/fax-g3 g3
image/g3fax
image/gif gif
image/ief ief
image/jpeg jpeg jpg jpe
image/jpeg2000 jp2
image/png png
image/rle rle
image/svg+xml svg
image/tiff tif tiff
image/vnd.djvu djvu djv
image/vnd.dwg dwg
image/vnd.dxf dxf
image/x-3ds 3ds
image/x-applix-graphics ag
image/x-cmu-raster ras
image/x-compressed-xcf xcf.gz xcf.bz2
image/x-dcraw bay BAY bmq BMQ cr2 CR2 crw CRW cs1 CS1 dc2 DC2 dcr DCR fff FFF k25 K25 kdc KDC mos MOS mrw MRW nef NEF orf ORF pef PEF raf RAF rdc RDC srf SRF x3f X3F
image/x-dib
image/x-eps eps epsi epsf
image/x-fits fits
image/x-fpx
image/x-icb icb
image/x-ico ico
image/x-iff iff
image/x-ilbm ilbm
image/x-jng jng
image/x-lwo lwo lwob
image/x-lws lws
image/x-msod msod
image/x-niff
image/x-pcx
image/x-photo-cd pcd
image/x-pict pict pict1 pict2
image/x-portable-anymap pnm
image/x-portable-bitmap pbm
image/x-portable-graymap pgm
image/x-portable-pixmap ppm
image/x-psd psd
image/x-rgb rgb
image/x-sgi sgi
image/x-sun-raster sun
image/x-tga tga
image/x-win-bitmap cur
image/x-wmf wmf
image/x-xbitmap xbm
image/x-xcf xcf
image/x-xfig fig
image/x-xpixmap xpm
image/x-xwindowdump xwd
inode/blockdevice
inode/chardevice
inode/directory
inode/fifo
inode/mount-point
inode/socket
inode/symlink
message/delivery-status
message/disposition-notification
message/external-body
message/news
message/partial
message/rfc822
message/x-gnu-rmail
model/vrml wrl
multipart/alternative
multipart/appledouble
multipart/digest
multipart/encrypted
multipart/mixed
multipart/related
multipart/report
multipart/signed
multipart/x-mixed-replace
text/calendar vcs ics
text/css css CSSL
text/directory vcf vct gcrd
text/enriched
text/html html htm
text/htmlh
text/mathml mml
text/plain txt asc
text/rdf rdf
text/rfc822-headers
text/richtext rtx
text/rss rss
text/sgml sgml sgm
text/spreadsheet sylk slk
text/tab-separated-values tsv
text/vnd.rn-realtext rt
text/vnd.wap.wml wml
text/x-adasrc adb ads
text/x-authors
text/x-bibtex bib
text/x-boo boo
text/x-c++hdr hh
text/x-c++src cpp cxx cc C c++
text/x-chdr h h++ hp
text/x-comma-separated-values csv
text/x-copying
text/x-credits
text/x-csrc c
text/x-dcl dcl
text/x-dsl dsl
text/x-dsrc d
text/x-dtd dtd
text/x-emacs-lisp el
text/x-fortran f
text/x-gettext-translation po
text/x-gettext-translation-template pot
text/x-gtkrc
text/x-haskell hs
text/x-idl idl
text/x-install
text/x-java java
text/x-js js
text/x-ksysv-log
text/x-literate-haskell lhs
text/x-log log
text/x-makefile
text/x-moc moc
text/x-msil il
text/x-nemerle n
text/x-objcsrc m
text/x-pascal p pas
text/x-patch diff patch
text/x-python py
text/x-readme
text/x-rng rng
text/x-scheme scm
text/x-setext etx
text/x-speech
text/x-sql sql
text/x-suse-ymp ymp
text/x-suse-ymu ymu
text/x-tcl tcl tk
text/x-tex tex ltx sty cls
text/x-texinfo texi texinfo
text/x-texmacs tm ts
text/x-troff-me me
text/x-troff-mm mm
text/x-troff-ms ms
text/x-uil uil
text/x-uri uri url
text/x-vb vb
text/x-xds xds
text/x-xmi xmi
text/x-xsl xsl
text/x-xslfo fo xslfo
text/x-xslt xslt xsl
text/xmcd
text/xml xml
video/3gpp 3gp
video/dv dv dif
video/isivideo
video/mpeg mpeg mpg mp2 mpe vob dat
video/quicktime qt mov moov qtvr
video/vivo
video/vnd.rn-realvideo rv
video/wavelet
video/x-3gpp2 3g2
video/x-anim anim[1-9j]
video/x-avi
video/x-flic fli flc
video/x-mng mng
video/x-ms-asf asf asx
video/x-ms-wmv wmv
video/x-msvideo avi
video/x-nsv nsv NSV
video/x-real-video
video/x-sgi-movie movie
application/x-java-jnlp-file jnlp
application/vnd.openxmlformats-officedocument.wordprocessingml.document docx
application/vnd.openxmlformats-officedocument.wordprocessingml.template dotx
application/vnd.ms-word.document.macroEnabled.12 docm
application/vnd.ms-word.template.macroEnabled.12 dotm
application/vnd.openxmlformats-officedocument.spreadsheetml.sheet xlsx
application/vnd.openxmlformats-officedocument.spreadsheetml.template xltx
application/vnd.ms-excel.sheet.macroEnabled.12 xlsm
application/vnd.ms-excel.template.macroEnabled.12 xltm
application/vnd.ms-excel.addin.macroEnabled.12 xlam
application/vnd.ms-excel.sheet.binary.macroEnabled.12 xlsb
application/vnd.openxmlformats-officedocument.presentationml.presentation pptx
application/vnd.openxmlformats-officedocument.presentationml.template potx
application/vnd.openxmlformats-officedocument.presentationml.slideshow ppsx
application/vnd.ms-powerpoint.addin.macroEnabled.12 ppam

View File

@ -0,0 +1,257 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
if (K2_JVERSION == '30')
{
class K2Parameter
{
function __construct($data, $path = '', $namespace)
{
$this->namespace = $namespace;
$this->values = new JRegistry($data);
}
function get($path, $default = null)
{
return $this->values->get($this->namespace.$path, $default);
}
}
}
else
{
jimport('joomla.html.parameter');
/**
* Parameter handler
*
* @package Joomla.Framework
* @subpackage Parameter
* @since 1.5
*/
class K2Parameter extends JParameter
{
/**
* optional namespace
*
* @access private
* @var array
* @since 1.5
*/
var $namespace = null;
/**
* Constructor
*
* @access protected
* @param string The raw parms text
* @param string Path to the xml setup file
* @param string Namespace to the xml setup file
* @since 1.5
*/
function __construct($data, $path = '', $namespace)
{
parent::__construct('_default');
// Set base path
$this->_elementPath[] = JPATH_COMPONENT_ADMINISTRATOR.'/elements';
if (trim($data))
{
$this->loadINI($data);
}
if ($path)
{
@$this->loadSetupFile($path);
}
if ($namespace)
{
$this->namespace = $namespace;
}
$this->_raw = $data;
if (K2_JVERSION != '15')
{
$this->bind($data);
}
}
/**
* Get a value
*
* @access public
* @param string The name of the param
* @param mixed The default value if not found
* @return string
* @since 1.5
*/
function get($key, $default = '', $group = '_default')
{
if (K2_JVERSION != '15')
{
return parent::get($this->namespace.$key, $default);
}
$value = $this->getValue($group.'.'.$this->namespace.$key);
$result = (empty($value) && ($value !== 0) && ($value !== '0')) ? $default : $value;
//if($group != '_default') { echo ($group); }
return $result;
}
/**
* Render a parameter type
*
* @param object A param tag node
* @param string The control name
* @return array Any array of the label, the form element and the tooltip
* @since 1.5
*/
function getParam(&$node, $control_name = 'params', $group = '_default')
{
//get the type of the parameter
$type = $node->attributes('type');
//remove any occurance of a mos_ prefix
$type = str_replace('mos_', '', $type);
$element = $this->loadElement($type);
// error happened
if ($element === false)
{
$result = array();
$result[0] = $node->attributes('name');
$result[1] = JText::_('K2_ELEMENT_NOT_DEFINED_FOR_TYPE').' = '.$type;
$result[5] = $result[0];
return $result;
}
//get value
$value = $this->get($node->attributes('name'), $node->attributes('default'), $group);
//set name
$node->_attributes['name'] = $this->namespace.$node->_attributes['name'];
return $element->render($node, $value, $control_name);
}
/**
* Get a registry value
*
* @access public
* @param string $regpath Registry path (e.g. joomla.content.showauthor)
* @param mixed $default Optional default value
* @return mixed Value of entry or null
* @since 1.5
*/
function getValue($regpath, $default = null)
{
$result = $default;
// Explode the registry path into an array
if ($nodes = explode('.', $regpath))
{
// Get the namespace
//$namespace = array_shift($nodes);
$count = count($nodes);
if ($count < 2)
{
$namespace = $this->_defaultNameSpace;
$nodes[1] = $nodes[0];
}
else
{
$namespace = $nodes[0];
}
if (isset($this->_registry[$namespace]))
{
$ns = &$this->_registry[$namespace]['data'];
$pathNodes = $count - 1;
//for ($i = 0; $i < $pathNodes; $i ++) {
for ($i = 1; $i < $pathNodes; $i++)
{
if ((isset($ns->$nodes[$i])))
$ns = &$ns->$nodes[$i];
}
if (isset($ns->$nodes[$i]))
{
$result = $ns->$nodes[$i];
}
}
}
return $result;
}
/**
* Render
*
* @access public
* @param string The name of the control, or the default text area if a setup file is not found
* @return string HTML
* @since 1.5
*/
function render($name = 'params', $group = '_default')
{
if (!isset($this->_xml[$group]))
{
return false;
}
$params = $this->getParams($name, $group);
$html = array();
$html[] = '<table class="paramlist admintable" cellspacing="1">';
if ($description = $this->_xml[$group]->attributes('description'))
{
// add the params description to the display
$desc = JText::_($description);
$html[] = '<tr><td class="paramlist_description" colspan="2">'.$desc.'</td></tr>';
}
foreach ($params as $param)
{
$html[] = '<tr>';
if ($param[0])
{
$html[] = '<td class="paramlist_key"><span class="editlinktip">'.$param[0].'</span></td>';
$html[] = '<td class="paramlist_value">'.$param[1].'</td>';
}
else
{
$html[] = '<td class="paramlist_value" colspan="2">'.$param[1].'</td>';
}
$html[] = '</tr>';
}
if (count($params) < 1)
{
$html[] = "<tr><td colspan=\"2\"><i>".(K2_JVERSION != '15') ? JText::_('JLIB_HTML_NO_PARAMETERS_FOR_THIS_ITEM') : JText::_('There are no Parameters for this item')."</i></td></tr>";
}
$html[] = '</table>';
return implode("\n", $html);
}
}
}

View File

@ -0,0 +1,98 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.plugin.plugin');
JLoader::register('K2Parameter', JPATH_ADMINISTRATOR.'/components/com_k2/lib/k2parameter.php');
class K2Plugin extends JPlugin
{
/**
* Below we list all available BACKEND events, to trigger K2 plugins and generate additional fields in the item, category and user forms.
*/
/* ------------ Functions to render plugin parameters in the backend - no need to change anything ------------ */
function onRenderAdminForm(&$item, $type, $tab = '')
{
$application = JFactory::getApplication();
$manifest = (K2_JVERSION == '15') ? JPATH_SITE.'/plugins/k2/'.$this->pluginName.'.xml' : JPATH_SITE.'/plugins/k2/'.$this->pluginName.'/'.$this->pluginName.'.xml';
if (!empty($tab))
{
$path = $type.'-'.$tab;
}
else
{
$path = $type;
}
if (!isset($item->plugins))
{
$item->plugins = NULL;
}
if (K2_JVERSION == '15')
{
$form = new K2Parameter($item->plugins, $manifest, $this->pluginName);
$fields = $form->render('plugins', $path);
}
else
{
jimport('joomla.form.form');
$form = JForm::getInstance('plg_k2_'.$this->pluginName.'_'.$path, $manifest, array(), true, 'fields[@group="'.$path.'"]');
$values = array();
if ($item->plugins)
{
foreach (json_decode($item->plugins) as $name => $value)
{
$count = 1;
$values[str_replace($this->pluginName, '', $name, $count)] = $value;
}
$form->bind($values);
}
$fields = '';
foreach ($form->getFieldset() as $field)
{
if (strpos($field->name, '[]') !== false)
{
$search = 'name="'.$field->name.'"';
$replace = 'name="plugins['.$this->pluginName.str_replace('[]', '', $field->name).'][]"';
}
else
{
$search = 'name="'.$field->name.'"';
$replace = 'name="plugins['.$this->pluginName.$field->name.']"';
}
$input = JString::str_ireplace($search, $replace, $field->__get('input'));
$fields .= $field->__get('label').' '.$input;
}
// Legacy code to maintain compatibillity with existing plugins that use params instead of JForm
if (empty($fields) && K2_JVERSION == '25')
{
$form = new K2Parameter($item->plugins, $manifest, $this->pluginName);
$fields = $form->render('plugins', $path);
}
}
if ($fields)
{
$plugin = new stdClass;
$plugin->name = $this->pluginNameHumanReadable;
$plugin->fields = $fields;
return $plugin;
}
}
}

View File

@ -0,0 +1,290 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
/*
* This is a PHP library that handles calling reCAPTCHA.
* - Documentation and latest version
* http://recaptcha.net/plugins/php/
* - Get a reCAPTCHA API Key
* https://www.google.com/recaptcha/admin/create
* - Discussion group
* http://groups.google.com/group/recaptcha
*
* Copyright (c) 2007 reCAPTCHA -- http://recaptcha.net
* AUTHORS:
* Mike Crawford
* Ben Maurer
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* The reCAPTCHA server URL's
*/
define("RECAPTCHA_API_SERVER", "http://www.google.com/recaptcha/api");
define("RECAPTCHA_API_SECURE_SERVER", "https://www.google.com/recaptcha/api");
define("RECAPTCHA_VERIFY_SERVER", "www.google.com");
/**
* Encodes the given data into a query string format
* @param $data - array of string elements to be encoded
* @return string - encoded request
*/
function _recaptcha_qsencode ($data) {
$req = "";
foreach ( $data as $key => $value )
$req .= $key . '=' . urlencode( stripslashes($value) ) . '&';
// Cut the last '&'
$req=substr($req,0,strlen($req)-1);
return $req;
}
/**
* Submits an HTTP POST to a reCAPTCHA server
* @param string $host
* @param string $path
* @param array $data
* @param int port
* @return array response
*/
function _recaptcha_http_post($host, $path, $data, $port = 80) {
$req = _recaptcha_qsencode ($data);
$http_request = "POST $path HTTP/1.0\r\n";
$http_request .= "Host: $host\r\n";
$http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n";
$http_request .= "Content-Length: " . strlen($req) . "\r\n";
$http_request .= "User-Agent: reCAPTCHA/PHP\r\n";
$http_request .= "\r\n";
$http_request .= $req;
$response = '';
if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) {
die ('Could not open socket');
}
fwrite($fs, $http_request);
while ( !feof($fs) )
$response .= fgets($fs, 1160); // One TCP-IP packet
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
return $response;
}
/**
* Gets the challenge HTML (javascript and non-javascript version).
* This is called from the browser, and the resulting reCAPTCHA HTML widget
* is embedded within the HTML form it was called from.
* @param string $pubkey A public key for reCAPTCHA
* @param string $error The error given by reCAPTCHA (optional, default is null)
* @param boolean $use_ssl Should the request be made over ssl? (optional, default is false)
* @return string - The HTML to be embedded in the user's form.
*/
function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false)
{
if ($pubkey == null || $pubkey == '') {
die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
}
if ($use_ssl) {
$server = RECAPTCHA_API_SECURE_SERVER;
} else {
$server = RECAPTCHA_API_SERVER;
}
$errorpart = "";
if ($error) {
$errorpart = "&amp;error=" . $error;
}
return '
<script type="text/javascript" src="'. $server . '/challenge?k=' . $pubkey . $errorpart . '"></script>
<noscript>
<iframe src="'. $server . '/noscript?k=' . $pubkey . $errorpart . '" height="300" width="500" frameborder="0"></iframe>
<br />
<textarea name="recaptcha_challenge_field" rows="3" cols="40"></textarea>
<input type="hidden" name="recaptcha_response_field" value="manual_challenge" />
</noscript>
';
}
/**
* A ReCaptchaResponse is returned from recaptcha_check_answer()
*/
class ReCaptchaResponse {
var $is_valid;
var $error;
}
/**
* Calls an HTTP POST function to verify if the user's guess was correct
* @param string $privkey
* @param string $remoteip
* @param string $challenge
* @param string $response
* @param array $extra_params an array of extra variables to post to the server
* @return ReCaptchaResponse
*/
function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array())
{
if ($privkey == null || $privkey == '') {
die ("To use reCAPTCHA you must get an API key from <a href='https://www.google.com/recaptcha/admin/create'>https://www.google.com/recaptcha/admin/create</a>");
}
if ($remoteip == null || $remoteip == '') {
die ("For security reasons, you must pass the remote ip to reCAPTCHA");
}
//discard spam submissions
if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) {
$recaptcha_response = new ReCaptchaResponse();
$recaptcha_response->is_valid = false;
$recaptcha_response->error = 'incorrect-captcha-sol';
return $recaptcha_response;
}
$response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify",
array (
'privatekey' => $privkey,
'remoteip' => $remoteip,
'challenge' => $challenge,
'response' => $response
) + $extra_params
);
$answers = explode ("\n", $response [1]);
$recaptcha_response = new ReCaptchaResponse();
if (trim ($answers [0]) == 'true') {
$recaptcha_response->is_valid = true;
}
else {
$recaptcha_response->is_valid = false;
$recaptcha_response->error = $answers [1];
}
return $recaptcha_response;
}
/**
* gets a URL where the user can sign up for reCAPTCHA. If your application
* has a configuration page where you enter a key, you should provide a link
* using this function.
* @param string $domain The domain where the page is hosted
* @param string $appname The name of your application
*/
function recaptcha_get_signup_url ($domain = null, $appname = null) {
return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname));
}
function _recaptcha_aes_pad($val) {
$block_size = 16;
$numpad = $block_size - (strlen ($val) % $block_size);
return str_pad($val, strlen ($val) + $numpad, chr($numpad));
}
/* Mailhide related code */
function _recaptcha_aes_encrypt($val,$ky) {
if (! function_exists ("mcrypt_encrypt")) {
die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed.");
}
$mode=MCRYPT_MODE_CBC;
$enc=MCRYPT_RIJNDAEL_128;
$val=_recaptcha_aes_pad($val);
return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0");
}
function _recaptcha_mailhide_urlbase64 ($x) {
return strtr(base64_encode ($x), '+/', '-_');
}
/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */
function recaptcha_mailhide_url($pubkey, $privkey, $email) {
if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) {
die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " .
"you can do so at <a href='http://www.google.com/recaptcha/mailhide/apikey'>http://www.google.com/recaptcha/mailhide/apikey</a>");
}
$ky = pack('H*', $privkey);
$cryptmail = _recaptcha_aes_encrypt ($email, $ky);
return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail);
}
/**
* gets the parts of the email to expose to the user.
* eg, given johndoe@example,com return ["john", "example.com"].
* the email is then displayed as john...@example.com
*/
function _recaptcha_mailhide_email_parts ($email) {
$arr = preg_split("/@/", $email );
if (strlen ($arr[0]) <= 4) {
$arr[0] = substr ($arr[0], 0, 1);
} else if (strlen ($arr[0]) <= 6) {
$arr[0] = substr ($arr[0], 0, 3);
} else {
$arr[0] = substr ($arr[0], 0, 4);
}
return $arr;
}
/**
* Gets html to display an email address given a public an private key.
* to get a key, go to:
*
* http://www.google.com/recaptcha/mailhide/apikey
*/
function recaptcha_mailhide_html($pubkey, $privkey, $email) {
$emailparts = _recaptcha_mailhide_email_parts ($email);
$url = recaptcha_mailhide_url ($pubkey, $privkey, $email);
return htmlentities($emailparts[0]) . "<a href='" . htmlentities ($url) .
"' onclick=\"window.open('" . htmlentities ($url) . "', '', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=500,height=300'); return false;\" title=\"Reveal this e-mail address\">...</a>@" . htmlentities ($emailparts [1]);
}
?>

View File

@ -0,0 +1,818 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelCategories extends K2Model
{
function getData()
{
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\"\-_]/u', '', $search));
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', 'c.ordering', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_trash = $application->getUserStateFromRequest($option.$view.'filter_trash', 'filter_trash', 0, 'int');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', -1, 'int');
$language = $application->getUserStateFromRequest($option.$view.'language', 'language', '', 'string');
$filter_category = $application->getUserStateFromRequest($option.$view.'filter_category', 'filter_category', 0, 'int');
$query = "SELECT c.*, g.name AS groupname, exfg.name as extra_fields_group FROM #__k2_categories as c LEFT JOIN #__groups AS g ON g.id = c.access LEFT JOIN #__k2_extra_fields_groups AS exfg ON exfg.id = c.extraFieldsGroup WHERE c.id>0";
if (!$filter_trash)
{
$query .= " AND c.trash=0";
}
if ($search)
{
// Detect exact search phrase using double quotes in search string
if(substr($search, 0, 1)=='"' && substr($search, -1)=='"')
{
$exact = true;
}
else
{
$exact = false;
}
// Now completely strip double quotes
$search = trim(str_replace('"', '', $search));
// Escape remaining string
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
// Full phrase or set of words
if(strpos($escaped, ' ')!==false && !$exact)
{
$escaped=explode(' ', $escaped);
$quoted = array();
foreach($escaped as $key=>$escapedWord)
{
$quoted[] = $db->Quote('%'.$escapedWord.'%', false);
}
if ($params->get('adminSearch') == 'full')
{
foreach($quoted as $quotedWord)
{
$query .= " AND ( ".
"LOWER(c.name) LIKE ".$quotedWord." ".
"OR LOWER(c.description) LIKE ".$quotedWord." ".
" )";
}
}
else
{
foreach($quoted as $quotedWord)
{
$query .= " AND LOWER(c.name) LIKE ".$quotedWord;
}
}
}
// Single word or exact phrase to search for (wrapped in double quotes in the search block)
else
{
$quoted = $db->Quote('%'.$escaped.'%', false);
if ($params->get('adminSearch') == 'full')
{
$query .= " AND ( ".
"LOWER(c.name) LIKE ".$quoted." ".
"OR LOWER(c.description) LIKE ".$quoted." ".
" )";
}
else
{
$query .= " AND LOWER(c.name) LIKE ".$quoted;
}
}
}
if ($filter_state > -1)
{
$query .= " AND c.published={$filter_state}";
}
if ($language)
{
$query .= " AND c.language = ".$db->Quote($language);
}
if ($filter_category)
{
K2Model::addIncludePath(JPATH_SITE.'/components/com_k2/models');
$ItemlistModel = K2Model::getInstance('Itemlist', 'K2Model');
$tree = $ItemlistModel->getCategoryTree($filter_category);
$query .= " AND c.id IN (".implode(',', $tree).")";
}
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}";
if (K2_JVERSION != '15')
{
$query = JString::str_ireplace('#__groups', '#__viewlevels', $query);
$query = JString::str_ireplace('g.name AS groupname', 'g.title AS groupname', $query);
}
$db->setQuery($query);
$rows = $db->loadObjectList();
if (K2_JVERSION != '15')
{
foreach ($rows as $row)
{
$row->parent_id = $row->parent;
$row->title = $row->name;
}
}
$categories = array();
if ($search)
{
foreach ($rows as $row)
{
$row->treename = $row->name;
$categories[] = $row;
}
}
else
{
if ($filter_category)
{
$db->setQuery('SELECT parent FROM #__k2_categories WHERE id = '.$filter_category);
$root = $db->loadResult();
}
else if($language && count($categories))
{
$root = $categories[0]->parent;
}
else
{
$root = 0;
}
$categories = $this->indentRows($rows, $root);
}
if (isset($categories))
{
$total = count($categories);
}
else
{
$total = 0;
}
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
$categories = @array_slice($categories, $pageNav->limitstart, $pageNav->limit);
foreach ($categories as $category)
{
$category->parameters = class_exists('JParameter') ? new JParameter($category->params) : new JRegistry($category->params);
if ($category->parameters->get('inheritFrom'))
{
$db->setQuery("SELECT name FROM #__k2_categories WHERE id = ".(int)$category->parameters->get('inheritFrom'));
$category->inheritFrom = $db->loadResult();
}
else
{
$category->inheritFrom = '';
}
}
return $categories;
}
function getTotal()
{
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\"\-_]/u', '', $search));
$filter_trash = $application->getUserStateFromRequest($option.$view.'filter_trash', 'filter_trash', 0, 'int');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', 1, 'int');
$language = $application->getUserStateFromRequest($option.$view.'language', 'language', '', 'string');
$filter_category = $application->getUserStateFromRequest($option.$view.'filter_category', 'filter_category', 0, 'int');
$query = "SELECT COUNT(*) FROM #__k2_categories WHERE id>0";
if (!$filter_trash)
{
$query .= " AND trash=0";
}
if ($search)
{
// Detect exact search phrase using double quotes in search string
if(substr($search, 0, 1)=='"' && substr($search, -1)=='"')
{
$exact = true;
}
else
{
$exact = false;
}
// Now completely strip double quotes
$search = trim(str_replace('"', '', $search));
// Escape remaining string
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
// Full phrase or set of words
if(strpos($escaped, ' ')!==false && !$exact)
{
$escaped=explode(' ', $escaped);
$quoted = array();
foreach($escaped as $key=>$escapedWord)
{
$quoted[] = $db->Quote('%'.$escapedWord.'%', false);
}
if ($params->get('adminSearch') == 'full')
{
foreach($quoted as $quotedWord)
{
$query .= " AND ( ".
"LOWER(name) LIKE ".$quotedWord." ".
"OR LOWER(description) LIKE ".$quotedWord." ".
" )";
}
}
else
{
foreach($quoted as $quotedWord)
{
$query .= " AND LOWER(name) LIKE ".$quotedWord;
}
}
}
// Single word or exact phrase to search for (wrapped in double quotes in the search block)
else
{
$quoted = $db->Quote('%'.$escaped.'%', false);
if ($params->get('adminSearch') == 'full')
{
$query .= " AND ( ".
"LOWER(name) LIKE ".$quoted." ".
"OR LOWER(description) LIKE ".$quoted." ".
" )";
}
else
{
$query .= " AND LOWER(name) LIKE ".$quoted;
}
}
}
if ($filter_state > -1)
{
$query .= " AND published={$filter_state}";
}
if ($language)
{
$query .= " AND language = ".$db->Quote($language);
}
if ($filter_category)
{
K2Model::addIncludePath(JPATH_SITE.'/components/com_k2/models');
$ItemlistModel = K2Model::getInstance('Itemlist', 'K2Model');
$tree = $ItemlistModel->getCategoryTree($filter_category);
$query .= " AND id IN (".implode(',', $tree).")";
}
$db->setQuery($query);
$total = $db->loadResult();
return $total;
}
function indentRows(&$rows, $root = 0)
{
$children = array();
if (count($rows))
{
foreach ($rows as $v)
{
$pt = $v->parent;
$list = @$children[$pt] ? $children[$pt] : array();
array_push($list, $v);
$children[$pt] = $list;
}
}
$categories = JHTML::_('menu.treerecurse', $root, '', array(), $children);
return $categories;
}
function publish()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($id);
$row->published = 1;
$row->store();
}
JPluginHelper::importPlugin('finder');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onFinderChangeState', array('com_k2.category', $cid, 1));
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=categories&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=categories');
}
}
function unpublish()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($id);
$row->published = 0;
$row->store();
}
JPluginHelper::importPlugin('finder');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onFinderChangeState', array('com_k2.category', $cid, 0));
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=categories&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=categories');
}
}
function saveorder()
{
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid', array(0), 'post', 'array');
$total = count($cid);
$order = JRequest::getVar('order', array(0), 'post', 'array');
JArrayHelper::toInteger($order, array(0));
$groupings = array();
for ($i = 0; $i < $total; $i++)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load(( int )$cid[$i]);
$groupings[] = $row->parent;
if ($row->ordering != $order[$i])
{
$row->ordering = $order[$i];
if (!$row->store())
{
JError::raiseError(500, $db->getErrorMsg());
}
}
}
if (!$params->get('disableCompactOrdering'))
{
$groupings = array_unique($groupings);
foreach ($groupings as $group)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->reorder('parent = '.( int )$group.' AND trash=0');
}
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
return true;
}
function orderup()
{
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2Category', 'Table');
$row->load($cid[0]);
$row->move(-1, 'parent = '.$row->parent.' AND trash=0');
if (!$params->get('disableCompactOrdering'))
$row->reorder('parent = '.(int)$row->parent.' AND trash=0');
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ORDERING_SAVED');
$application->enqueueMessage($msg);
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=categories&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=categories');
}
}
function orderdown()
{
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2Category', 'Table');
$row->load($cid[0]);
$row->move(1, 'parent = '.$row->parent.' AND trash=0');
if (!$params->get('disableCompactOrdering'))
$row->reorder('parent = '.(int)$row->parent.' AND trash=0');
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ORDERING_SAVED');
$application->enqueueMessage($msg);
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=categories&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=categories');
}
}
function accessregistered()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$row = JTable::getInstance('K2Category', 'Table');
$cid = JRequest::getVar('cid');
$row->load($cid[0]);
$row->access = 1;
if (!$row->check())
{
return $row->getError();
}
if (!$row->store())
{
return $row->getError();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ACCESS_SETTING_SAVED');
$application->enqueueMessage($msg);
$application->redirect('index.php?option=com_k2&view=categories');
}
function accessspecial()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$row = JTable::getInstance('K2Category', 'Table');
$cid = JRequest::getVar('cid');
$row->load($cid[0]);
$row->access = 2;
if (!$row->check())
{
return $row->getError();
}
if (!$row->store())
{
return $row->getError();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ACCESS_SETTING_SAVED');
$application->enqueueMessage($msg);
$application->redirect('index.php?option=com_k2&view=categories');
}
function accesspublic()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$row = JTable::getInstance('K2Category', 'Table');
$cid = JRequest::getVar('cid');
$row->load($cid[0]);
$row->access = 0;
if (!$row->check())
{
return $row->getError();
}
if (!$row->store())
{
return $row->getError();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ACCESS_SETTING_SAVED');
$application->enqueueMessage($msg);
$application->redirect('index.php?option=com_k2&view=categories');
}
function trash()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2Category', 'Table');
JArrayHelper::toInteger($cid);
K2Model::addIncludePath(JPATH_SITE.'/components/com_k2/models');
$model = K2Model::getInstance('Itemlist', 'K2Model');
$categories = $model->getCategoryTree($cid);
$sql = @implode(',', $categories);
$db = JFactory::getDbo();
$query = "UPDATE #__k2_categories SET trash=1 WHERE id IN ({$sql})";
$db->setQuery($query);
$db->query();
$query = "UPDATE #__k2_items SET trash=1 WHERE catid IN ({$sql})";
$db->setQuery($query);
$db->query();
JPluginHelper::importPlugin('finder');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onFinderChangeState', array('com_k2.category', $cid, 0));
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_CATEGORIES_MOVED_TO_TRASH'));
$application->redirect('index.php?option=com_k2&view=categories');
}
function restore()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
$warning = false;
$restored = array();
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($id);
if ((int)$row->parent == 0)
{
$row->trash = 0;
$row->store();
$restored[] = $id;
}
else
{
$query = "SELECT COUNT(*) FROM #__k2_categories WHERE id={$row->parent} AND trash = 0";
$db->setQuery($query);
$result = $db->loadResult();
if ($result)
{
$row->trash = 0;
$row->store();
$restored[] = $id;
}
else
{
$warning = true;
}
}
}
// Restore also the items of the categories
if (count($restored))
{
JArrayHelper::toInteger($restored);
$db->setQuery('UPDATE #__k2_items SET trash = 0 WHERE catid IN ('.implode(',', $restored).') AND trash = 1');
$db->query();
}
JPluginHelper::importPlugin('finder');
$dispatcher = JDispatcher::getInstance();
$dispatcher->trigger('onFinderChangeState', array('com_k2.category', $cid, 1));
$cache = JFactory::getCache('com_k2');
$cache->clean();
if ($warning)
$application->enqueueMessage(JText::_('K2_SOME_OF_THE_CATEGORIES_HAVE_NOT_BEEN_RESTORED_BECAUSE_THEIR_PARENT_CATEGORY_IS_IN_TRASH'), 'notice');
$application->enqueueMessage(JText::_('K2_CATEGORIES_MOVED_TO_TRASH'));
$application->redirect('index.php?option=com_k2&view=categories');
}
function remove()
{
$application = JFactory::getApplication();
jimport('joomla.filesystem.file');
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
JPluginHelper::importPlugin('finder');
$dispatcher = JDispatcher::getInstance();
$warningItems = false;
$warningChildren = false;
$cid = array_reverse($cid);
for ($i = 0; $i < sizeof($cid); $i++)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($cid[$i]);
$query = "SELECT COUNT(*) FROM #__k2_items WHERE catid={$cid[$i]}";
$db->setQuery($query);
$num = $db->loadResult();
if ($num > 0)
{
$warningItems = true;
}
$query = "SELECT COUNT(*) FROM #__k2_categories WHERE parent={$cid[$i]}";
$db->setQuery($query);
$children = $db->loadResult();
if ($children > 0)
{
$warningChildren = true;
}
if ($children == 0 && $num == 0)
{
if ($row->image)
{
JFile::delete(JPATH_ROOT.'/media/k2/categories/'.$row->image);
}
$row->delete($cid[$i]);
$dispatcher->trigger('onFinderAfterDelete', array('com_k2.category', $row));
}
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
if ($warningItems)
{
$application->enqueueMessage(JText::_('K2_SOME_OF_THE_CATEGORIES_HAVE_NOT_BEEN_DELETED_BECAUSE_THEY_HAVE_ITEMS'), 'notice');
}
if ($warningChildren)
{
$application->enqueueMessage(JText::_('K2_SOME_OF_THE_CATEGORIES_HAVE_NOT_BEEN_DELETED_BECAUSE_THEY_HAVE_CHILD_CATEGORIES'), 'notice');
}
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=categories');
}
function categoriesTree($row = NULL, $hideTrashed = false, $hideUnpublished = true)
{
$db = JFactory::getDbo();
if (isset($row->id))
{
$idCheck = ' AND id != '.( int )$row->id;
}
else
{
$idCheck = null;
}
if (!isset($row->parent))
{
if (is_null($row))
{
$row = new stdClass;
}
$row->parent = 0;
}
$query = "SELECT m.* FROM #__k2_categories m WHERE id > 0 {$idCheck}";
if ($hideUnpublished)
{
$query .= " AND published=1 ";
}
if ($hideTrashed)
{
$query .= " AND trash=0 ";
}
$query .= " 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 $item)
{
$item->treename = JString::str_ireplace('&#160;', '- ', $item->treename);
if (!$item->published)
$item->treename .= ' [**'.JText::_('K2_UNPUBLISHED_CATEGORY').'**]';
if ($item->trash)
$item->treename .= ' [**'.JText::_('K2_TRASHED_CATEGORY').'**]';
$mitems[] = JHTML::_('select.option', $item->id, $item->treename);
}
return $mitems;
}
function copy($batch = false)
{
jimport('joomla.filesystem.file');
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
$copies = array();
foreach ($cid as $id)
{
// Load source category
$category = JTable::getInstance('K2Category', 'Table');
$category->load($id);
// Save target category
$row = JTable::getInstance('K2Category', 'Table');
$row = $category;
$row->id = NULL;
$row->name = JText::_('K2_COPY_OF').' '.$category->name;
$row->published = 0;
$row->store();
$copies[] = $row->id;
// Target image
if ($category->image && JFile::exists(JPATH_SITE.'/media/k2/categories/'.$category->image))
{
JFile::copy(JPATH_SITE.'/media/k2/categories/'.$category->image, JPATH_SITE.'/media/k2/categories/'.$row->id.'.jpg');
$row->image = $row->id.'.jpg';
$row->store();
}
}
if($batch)
{
return $copies;
}
else
{
$application->enqueueMessage(JText::_('K2_COPY_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=categories');
}
}
function saveBatch()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$batchMode = JRequest::getCmd('batchMode');
$catid = JRequest::getCmd('batchCategory');
$access = JRequest::getCmd('batchAccess');
$extraFieldsGroups = JRequest::getCmd('batchExtraFieldsGroups');
$language = JRequest::getVar('batchLanguage');
if($batchMode == 'clone'){
$cid = $this->copy(true);
}
if(in_array($catid, $cid))
{
$application->redirect('index.php?option=com_k2&view=categories');
return;
}
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Category', 'Table');
$row->load($id);
if(is_numeric($catid) && $catid != '')
{
$row->parent = $catid;
$row->ordering = $row->getNextOrder('parent = '.(int)$catid.' AND published = 1');
}
if($access)
{
$row->access = $access;
}
if(is_numeric($extraFieldsGroups) && $extraFieldsGroups != '')
{
$row->extraFieldsGroup = intval($extraFieldsGroups);
}
if($language)
{
$row->language = $language;
}
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_BATCH_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=categories');
}
}

View File

@ -0,0 +1,176 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelCategory extends K2Model
{
function getData()
{
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2Category', 'Table');
$row->load($cid);
return $row;
}
function save()
{
$application = JFactory::getApplication();
jimport('joomla.filesystem.file');
require_once(JPATH_SITE.'/media/k2/assets/vendors/verot/class.upload.php/src/class.upload.php');
$row = JTable::getInstance('K2Category', 'Table');
$params = JComponentHelper::getParams('com_k2');
if (!$row->bind(JRequest::get('post')))
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=categories');
}
$isNew = ($row->id) ? false : true;
//Trigger the finder before save event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
$results = $dispatcher->trigger('onFinderBeforeSave', array('com_k2.category', $row, $isNew));
$row->description = JRequest::getVar('description', '', 'post', 'string', 2);
if ($params->get('xssFiltering'))
{
$filter = new JFilterInput( array(), array(), 1, 1, 0);
$row->description = $filter->clean($row->description);
}
if (!$row->id)
{
$row->ordering = $row->getNextOrder('parent = '.(int)$row->parent.' AND trash=0');
}
if (!$row->check())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=category&cid='.$row->id);
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=categories');
}
if (!$params->get('disableCompactOrdering'))
$row->reorder('parent = '.(int)$row->parent.' AND trash=0');
if ((int)$params->get('imageMemoryLimit'))
{
ini_set('memory_limit', (int)$params->get('imageMemoryLimit').'M');
}
$files = JRequest::get('files');
$savepath = JPATH_ROOT.'/media/k2/categories/';
$existingImage = JRequest::getVar('existingImage');
if (($files['image']['error'] == 0 || $existingImage) && !JRequest::getBool('del_image'))
{
if ($files['image']['error'] == 0)
{
$image = $files['image'];
}
else
{
$image = JPATH_SITE.'/'.JPath::clean($existingImage);
}
$handle = new Upload($image);
if ($handle->uploaded)
{
$handle->file_auto_rename = false;
$handle->jpeg_quality = $params->get('imagesQuality', '85');
$handle->file_overwrite = true;
$handle->file_new_name_body = $row->id;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = $params->get('catImageWidth', '100');
$handle->Process($savepath);
if ($files['image']['error'] == 0)
$handle->Clean();
}
else
{
$application->enqueueMessage($handle->error, 'error');
$application->redirect('index.php?option=com_k2&view=categories');
}
$row->image = $handle->file_dst_name;
}
if (JRequest::getBool('del_image'))
{
$currentRow = JTable::getInstance('K2Category', 'Table');
$currentRow->load($row->id);
if (JFile::exists(JPATH_ROOT.'/media/k2/categories/'.$currentRow->image))
{
JFile::delete(JPATH_ROOT.'/media/k2/categories/'.$currentRow->image);
}
$row->image = '';
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=categories');
}
//Trigger the finder after save event
$dispatcher = JDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
$results = $dispatcher->trigger('onFinderAfterSave', array('com_k2.category', $row, $isNew));
$cache = JFactory::getCache('com_k2');
$cache->clean();
switch(JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_CATEGORY_SAVED');
$link = 'index.php?option=com_k2&view=category&cid='.$row->id;
break;
case 'saveAndNew' :
$msg = JText::_('K2_CATEGORY_SAVED');
$link = 'index.php?option=com_k2&view=category';
break;
case 'save' :
default :
$msg = JText::_('K2_CATEGORY_SAVED');
$link = 'index.php?option=com_k2&view=categories';
break;
}
$application->enqueueMessage($msg);
$application->redirect($link);
}
function countCategoryItems($catid, $trash = 0)
{
$db = JFactory::getDbo();
$catid = (int)$catid;
$query = "SELECT COUNT(*) FROM #__k2_items WHERE catid={$catid} AND trash = ".(int)$trash;
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
}

View File

@ -0,0 +1,958 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<name>K2_CATEGORY_EDIT_FORM</name>
<params group="category-item-layout" addpath="/administrator/components/com_k2/elements">
<param name="" type="header" default="K2_LAYOUT_TEMPLATE" label="" description=""/>
<param name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
<param name="" type="header" default="K2_LAYOUT_GRID" label="" description=""/>
<param name="num_leading_items" type="text" size="4" default="2" label="K2_LEADING_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LEADING"/>
<param name="num_leading_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LEADING" description=""/>
<param name="leadingImgSize" type="list" default="Large" label="K2_IMAGE_SIZE_FOR_LEADING_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description=""/>
<param name="num_primary_items" type="text" size="4" default="4" label="K2_PRIMARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_PRIMARY"/>
<param name="num_primary_columns" type="text" size="4" default="2" label="K2_COLUMNS_FOR_PRIMARY" description=""/>
<param name="primaryImgSize" type="list" default="Medium" label="K2_IMAGE_SIZE_FOR_PRIMARY_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description=""/>
<param name="num_secondary_items" type="text" size="4" default="4" label="K2_SECONDARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_SECONDARY"/>
<param name="num_secondary_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_SECONDARY" description=""/>
<param name="secondaryImgSize" type="list" default="Small" label="K2_IMAGE_SIZE_FOR_SECONDARY_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</param>
<param name="@spacer" type="spacer" default="" label="" description=""/>
<param name="num_links" type="text" size="4" default="4" label="K2_LINKS_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LINKS"/>
<param name="num_links_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LINKS" description=""/>
<param name="linksImgSize" type="list" default="XSmall" label="K2_IMAGE_SIZE_FOR_LINK_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</param>
<param name="" type="header" default="K2_OTHER_LAYOUT_OPTIONS" label="" description=""/>
<param name="catCatalogMode" type="radio" default="0" label="K2_CATALOG_MODE" description="K2_IF_YOU_SELECT_YES_THEN_ONLY_THE_ITEMS_DIRECTLY_BELONGING_TO_THIS_CATEGORY_WILL_BE_RETRIEVED_IF_YOU_SELECT_NO_THEN_ITEMS_FROM_ALL_SUBCATEGORIES_WILL_BE_RETRIEVED_SETTING_THIS_OPTION_TO_NO_IS_IDEAL_FOR_NEWSPORTALMAGAZINEBLOG_LAYOUTS">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="catFeaturedItems" type="radio" default="1" label="K2_FEATURED_ITEMS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
<option value="2">K2_SHOW_ONLY_FEATURED_ITEMS</option>
</param>
<param name="catOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
<option value="">K2_DEFAULT</option>
<option value="date">K2_OLDEST_FIRST</option>
<option value="rdate">K2_MOST_RECENT_FIRST</option>
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
<option value="order">K2_ORDERING</option>
<option value="rorder">K2_ORDERING_REVERSE</option>
<option value="featured">K2_FEATURED_FIRST</option>
<option value="hits">K2_MOST_POPULAR</option>
<option value="best">K2_HIGHEST_RATED</option>
<option value="modified">K2_LATEST_MODIFIED</option>
<option value="rand">K2_RANDOM_ORDERING</option>
</param>
<param name="catPagination" type="radio" default="2" label="K2_PAGINATION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
<option value="2">K2_AUTO</option>
</param>
<param name="catPaginationResults" type="radio" default="1" label="K2_PAGINATION_RESULTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
</params>
<params group="category-view-options" addpath="/administrator/components/com_k2/elements">
<param name="catTitle" type="radio" default="1" label="K2_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catTitleItemCounter" type="radio" default="1" label="K2_ITEM_COUNTER_NEXT_TO_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catDescription" type="radio" default="1" label="K2_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catImage" type="radio" default="1" label="K2_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
<option value="0">K2_DISABLE</option>
<option value="1">K2_ENABLE</option>
</param>
<param name="catFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_SUBCATEGORY_HANDLING" label="" description=""/>
<param name="subCategories" type="radio" default="1" label="K2_SUBCATEGORY_BLOCKS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="subCatColumns" type="text" default="2" size="4" label="K2_COLUMNS" description=""/>
<param name="subCatOrdering" type="list" default="" label="K2_SUBCATEGORY_ORDERING" description="">
<option value="">K2_DEFAULT_BY_ID_ASCENDING</option>
<option value="reversedefault">K2_REVERSE_DEFAULT_BY_ID_DESCENDING</option>
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
<option value="order">K2_ORDERING</option>
</param>
<param name="subCatTitle" type="radio" default="1" label="K2_SUBCATEGORY_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="subCatTitleItemCounter" type="radio" default="1" label="K2_ITEM_COUNTER_NEXT_TO_SUBCATEGORY_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="subCatDescription" type="radio" default="1" label="K2_SUBCATEGORY_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="subCatImage" type="radio" default="1" label="K2_SUBCATEGORY_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
</params>
<params group="item-image-options" addpath="/administrator/components/com_k2/elements">
<param name="itemImageXS" type="text" default="" label="K2_XSMALL_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<param name="itemImageS" type="text" default="" label="K2_SMALL_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<param name="itemImageM" type="text" default="" label="K2_MEDIUM_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<param name="itemImageL" type="text" default="" label="K2_LARGE_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<param name="itemImageXL" type="text" default="" label="K2_XLARGE_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
</params>
<params group="item-view-options-listings" addpath="/administrator/components/com_k2/elements">
<param name="catItemTitle" type="radio" default="1" label="K2_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemTitleLinked" type="radio" default="1" label="K2_LINK_ON_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemFeaturedNotice" type="radio" default="0" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemAuthor" type="radio" default="1" label="K2_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemDateCreated" type="radio" default="1" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemRating" type="radio" default="0" label="K2_RATING_VOTING" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemImage" type="radio" default="1" label="K2_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemIntroText" type="radio" default="1" label="K2_INTROTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemIntroTextWordLimit" type="text" default="" size="4" label="K2_INTROTEXT_WORD_LIMIT" description="K2_IF_THIS_OPTION_IS_ENABLED_ALL_HTML_TAGS_IN_THE_INTROTEXT_WILL_BE_CLEANED_UP_TO_MAKE_SURE_THE_SITE_MARKUP_WILL_NOT_BREAK"/>
<param name="catItemExtraFields" type="radio" default="0" label="K2_EXTRA_FIELDS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemHits" type="radio" default="0" label="K2_HITS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemCategory" type="radio" default="1" label="K2_CATEGORY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemTags" type="radio" default="1" label="K2_TAGS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemAttachments" type="radio" default="0" label="K2_ATTACHMENTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemAttachmentsCounter" type="radio" default="0" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemVideo" type="radio" default="0" label="K2_MEDIA" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<param name="catItemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<param name="catItemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<param name="catItemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<param name="catItemVideoAutoPlay" type="radio" default="0" label="K2_MEDIA_AUTOPLAY" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="catItemImageGallery" type="radio" default="0" label="K2_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<param name="catItemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<param name="catItemDateModified" type="radio" default="0" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemReadMore" type="radio" default="1" label="K2_READ_MORE_LINK" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemCommentsAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_ITEMS_COMMENT_FORM" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_ADVANCED" label="" description=""/>
<param name="catItemK2Plugins" type="radio" default="1" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
</params>
<params group="item-view-options" addpath="/administrator/components/com_k2/elements">
<param name="itemDateCreated" type="radio" default="1" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemTitle" type="radio" default="1" label="K2_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFeaturedNotice" type="radio" default="1" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthor" type="radio" default="1" label="K2_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFontResizer" type="radio" default="1" label="K2_FONT_RESIZER" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemPrintButton" type="radio" default="1" label="K2_PRINT_BUTTON" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemEmailButton" type="radio" default="1" label="K2_EMAIL_BUTTON" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemSocialButton" type="radio" default="1" label="K2_SOCIAL_BUTTON_LIKE_SHARETHIS_ADDTHIS_ETC" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideoAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_TO_VIDEO" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageGalleryAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_TO_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemCommentsAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_COMMENT_FORM" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRating" type="radio" default="1" label="K2_RATING_VOTING" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImage" type="radio" default="1" label="K2_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImgSize" type="radio" default="Large" label="K2_IMAGE_SIZE" description="">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</param>
<param name="itemImageMainCaption" type="radio" default="1" label="K2_IMAGE_CAPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageMainCredits" type="radio" default="1" label="K2_IMAGE_CREDITS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemIntroText" type="radio" default="1" label="K2_INTROTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFullText" type="radio" default="1" label="K2_FULLTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemExtraFields" type="radio" default="1" label="K2_EXTRA_FIELDS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemDateModified" type="radio" default="1" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemHits" type="radio" default="1" label="K2_HITS_PAGE_VIEWS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemCategory" type="radio" default="1" label="K2_CATEGORY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemTags" type="radio" default="1" label="K2_TAGS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAttachments" type="radio" default="1" label="K2_ATTACHMENTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAttachmentsCounter" type="radio" default="1" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideo" type="radio" default="1" label="K2_MEDIA" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<param name="itemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<param name="itemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<param name="itemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<param name="itemVideoAutoPlay" type="radio" default="0" label="K2_MEDIA_AUTOPLAY" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="itemVideoCaption" type="radio" default="1" label="K2_MEDIA_CAPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideoCredits" type="radio" default="1" label="K2_MEDIA_CREDITS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageGallery" type="radio" default="1" label="K2_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<param name="itemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<param name="itemNavigation" type="radio" default="1" label="K2_ITEM_NAVIGATION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemComments" type="radio" default="1" label="K2_COMMENTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_SOCIAL_SHARING" label="" description=""/>
<param name="itemTwitterButton" type="radio" default="1" label="K2_TWITTER_SHARE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFacebookButton" type="radio" default="1" label="K2_FACEBOOK_SHARE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemGooglePlusOneButton" type="radio" default="1" label="K2_GOOGLEPLUSONE_SHARE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_AUTHOR_OPTIONS" label="" description=""/>
<param name="itemAuthorBlock" type="radio" default="1" label="K2_DISPLAY_EXTENDED_AUTHOR_INFO" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorImage" type="radio" default="1" label="K2_AUTHOR_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorDescription" type="radio" default="1" label="K2_AUTHOR_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorURL" type="radio" default="1" label="K2_AUTHOR_URL" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorEmail" type="radio" default="0" label="K2_AUTHOR_EMAIL" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorLatest" type="radio" default="1" label="K2_LATEST_ITEMS_FROM_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorLatestLimit" type="text" default="5" size="4" label="K2_LIMIT_FOR_LATEST_ITEMS_FROM_AUTHOR" description=""/>
<param name="" type="header" default="K2_RELATED_ITEMS" label="" description=""/>
<param name="itemRelated" type="radio" default="1" label="K2_RELATED_ITEMS_BY_TAG" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedLimit" type="text" default="5" size="4" label="K2_RELATED_ITEMS_LIMIT" description=""/>
<param name="itemRelatedTitle" type="radio" default="1" label="K2_RELATED_ITEMS_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedCategory" type="radio" default="0" label="K2_RELATED_ITEMS_CATEGORY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedImageSize" type="radio" default="0" label="K2_RELATED_ITEMS_IMAGE" description="">
<option value="0">K2_NONE_SELECTED</option>
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</param>
<param name="itemRelatedIntrotext" type="radio" default="0" label="K2_RELATED_ITEMS_INTROTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedFulltext" type="radio" default="0" label="K2_RELATED_ITEMS_FULLTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedAuthor" type="radio" default="0" label="K2_RELATED_ITEMS_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedMedia" type="radio" default="0" label="K2_RELATED_ITEMS_MEDIA" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedImageGallery" type="radio" default="0" label="K2_RELATED_ITEMS_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_ADVANCED" label="" description=""/>
<param name="itemK2Plugins" type="radio" default="1" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
</params>
<!-- Metadata Information -->
<params group="category-metadata-information" addpath="/administrator/components/com_k2/elements">
<param name="catMetaDesc" type="k2textarea" chars="160" default="" label="K2_DESCRIPTION" description="" rows="4" cols="25" />
<param name="catMetaKey" type="textarea" default="" label="K2_KEYWORDS" description="" rows="4" cols="25" />
<param name="catMetaRobots" type="list" default="" label="K2_ROBOTS" description="">
<option value="">K2_USE_GLOBAL</option>
<option value="index, follow">K2_METADATA_ROBOTS_INDEX_FOLLOW</option>
<option value="index, nofollow">K2_METADATA_ROBOTS_INDEX_NOFOLLOW</option>
<option value="noindex, follow">K2_METADATA_ROBOTS_NOINDEX_FOLLOW</option>
<option value="noindex, nofollow">K2_METADATA_ROBOTS_NOINDEX_NOFOLLOW</option>
</param>
<param name="catMetaAuthor" type="text" default="" label="K2_AUTHOR" description=""/>
</params>
<fields name="params">
<fieldset name="category-item-layout" addfieldpath="/administrator/components/com_k2/elements">
<param name="" type="header" default="K2_LAYOUT_TEMPLATE" label="" description=""/>
<field name="theme" type="template" default="default" label="K2_SELECT_A_TEMPLATE"/>
<field name="" type="header" default="K2_LAYOUT_GRID" label="" description=""/>
<field name="num_leading_items" type="text" size="4" default="2" label="K2_LEADING_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LEADING"/>
<field name="num_leading_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LEADING" description=""/>
<field name="leadingImgSize" type="list" default="Large" label="K2_IMAGE_SIZE_FOR_LEADING_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</field>
<field name="@spacer" type="spacer" default="" label="" description=""/>
<field name="num_primary_items" type="text" size="4" default="4" label="K2_PRIMARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_PRIMARY"/>
<field name="num_primary_columns" type="text" size="4" default="2" label="K2_COLUMNS_FOR_PRIMARY" description=""/>
<field name="primaryImgSize" type="list" default="Medium" label="K2_IMAGE_SIZE_FOR_PRIMARY_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</field>
<field name="@spacer" type="spacer" default="" label="" description=""/>
<field name="num_secondary_items" type="text" size="4" default="4" label="K2_SECONDARY_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_SECONDARY"/>
<field name="num_secondary_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_SECONDARY" description=""/>
<field name="secondaryImgSize" type="list" default="Small" label="K2_IMAGE_SIZE_FOR_SECONDARY_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</field>
<field name="@spacer" type="spacer" default="" label="" description=""/>
<field name="num_links" type="text" size="4" default="4" label="K2_LINKS_COUNT" description="K2_NUMBER_OF_ITEMS_TO_DISPLAY_AS_LINKS"/>
<field name="num_links_columns" type="text" size="4" default="1" label="K2_COLUMNS_FOR_LINKS" description=""/>
<field name="linksImgSize" type="list" default="XSmall" label="K2_IMAGE_SIZE_FOR_LINK_ITEMS" description="K2_YOU_CAN_OVERRIDE_THE_GLOBAL_DIMENSIONS_FOR_EACH_SIZE_BY_ADJUSTING_THE_RELATED_SETTING_IN_THE_ITEM_IMAGE_OPTIONS_PANE_BELOW">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
<option value="none">K2_NO_IMAGE</option>
</field>
<field name="" type="header" default="K2_OTHER_LAYOUT_OPTIONS" label="" description=""/>
<field name="catCatalogMode" type="radio" default="0" label="K2_CATALOG_MODE" description="K2_IF_YOU_SELECT_YES_THEN_ONLY_THE_ITEMS_DIRECTLY_BELONGING_TO_THIS_CATEGORY_WILL_BE_RETRIEVED_IF_YOU_SELECT_NO_THEN_ITEMS_FROM_ALL_SUBCATEGORIES_WILL_BE_RETRIEVED_SETTING_THIS_OPTION_TO_NO_IS_IDEAL_FOR_NEWSPORTALMAGAZINEBLOG_LAYOUTS">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="catFeaturedItems" type="radio" default="1" label="K2_FEATURED_ITEMS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
<option value="2">K2_SHOW_ONLY_FEATURED_ITEMS</option>
</field>
<field name="catOrdering" type="list" default="" label="K2_ITEM_ORDERING" description="">
<option value="">K2_DEFAULT</option>
<option value="date">K2_OLDEST_FIRST</option>
<option value="rdate">K2_MOST_RECENT_FIRST</option>
<option value="publishUp">K2_RECENTLY_PUBLISHED</option>
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
<option value="order">K2_ORDERING</option>
<option value="rorder">K2_ORDERING_REVERSE</option>
<option value="featured">K2_FEATURED_FIRST</option>
<option value="hits">K2_MOST_POPULAR</option>
<option value="best">K2_HIGHEST_RATED</option>
<option value="modified">K2_LATEST_MODIFIED</option>
<option value="rand">K2_RANDOM_ORDERING</option>
</field>
<field name="catPagination" type="radio" default="2" label="K2_PAGINATION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
<option value="2">K2_AUTO</option>
</field>
<field name="catPaginationResults" type="radio" default="1" label="K2_PAGINATION_RESULTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
</fieldset>
<fieldset name="category-view-options" addfieldpath="/administrator/components/com_k2/elements">
<field name="catTitle" type="radio" default="1" label="K2_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catTitleItemCounter" type="radio" default="1" label="K2_ITEM_COUNTER_NEXT_TO_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catDescription" type="radio" default="1" label="K2_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catImage" type="radio" default="1" label="K2_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catFeedLink" type="radio" default="1" label="K2_RSS_FEED_LINK" description="">
<option value="0">K2_DISABLE</option>
<option value="1">K2_ENABLE</option>
</field>
<field name="catFeedIcon" type="radio" default="1" label="K2_RSS_FEED_ICON" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_SUBCATEGORY_HANDLING" label="" description=""/>
<field name="subCategories" type="radio" default="1" label="K2_SUBCATEGORY_BLOCKS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="subCatColumns" type="text" default="2" size="4" label="K2_COLUMNS" description=""/>
<field name="subCatOrdering" type="radio" default="" label="K2_SUBCATEGORY_ORDERING" description="">
<option value="">K2_DEFAULT_BY_ID_ASCENDING</option>
<option value="reversedefault">K2_REVERSE_DEFAULT_BY_ID_DESCENDING</option>
<option value="alpha">K2_TITLE_ALPHABETICAL</option>
<option value="ralpha">K2_TITLE_REVERSEALPHABETICAL</option>
<option value="order">K2_ORDERING</option>
</field>
<field name="subCatTitle" type="radio" default="1" label="K2_SUBCATEGORY_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="subCatTitleItemCounter" type="radio" default="1" label="K2_ITEM_COUNTER_NEXT_TO_SUBCATEGORY_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="subCatDescription" type="radio" default="1" label="K2_SUBCATEGORY_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="subCatImage" type="radio" default="1" label="K2_SUBCATEGORY_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
</fieldset>
<fieldset name="item-image-options" addfieldpath="/administrator/components/com_k2/elements">
<field name="itemImageXS" type="text" default="" label="K2_XSMALL_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<field name="itemImageS" type="text" default="" label="K2_SMALL_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<field name="itemImageM" type="text" default="" label="K2_MEDIUM_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<field name="itemImageL" type="text" default="" label="K2_LARGE_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
<field name="itemImageXL" type="text" default="" label="K2_XLARGE_IMAGE_WIDTH_IN_PX" size="4" description="K2_IF_NO_VALUE_IS_ENTERED_THE_RELATED_SETTING_FROM_THE_COMPONENTS_GLOBAL_PARAMETERS_WILL_BE_RETRIEVED"/>
</fieldset>
<fieldset name="item-view-options-listings" addfieldpath="/administrator/components/com_k2/elements">
<field name="catItemTitle" type="radio" default="1" label="K2_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemTitleLinked" type="radio" default="1" label="K2_LINK_ON_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemFeaturedNotice" type="radio" default="0" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemAuthor" type="radio" default="1" label="K2_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemDateCreated" type="radio" default="1" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemRating" type="radio" default="0" label="K2_RATING_VOTING" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemImage" type="radio" default="1" label="K2_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemIntroText" type="radio" default="1" label="K2_INTROTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemIntroTextWordLimit" type="text" default="" size="4" label="K2_INTROTEXT_WORD_LIMIT" description="K2_IF_THIS_OPTION_IS_ENABLED_ALL_HTML_TAGS_IN_THE_INTROTEXT_WILL_BE_CLEANED_UP_TO_MAKE_SURE_THE_SITE_MARKUP_WILL_NOT_BREAK"/>
<field name="catItemExtraFields" type="radio" default="0" label="K2_EXTRA_FIELDS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemHits" type="radio" default="0" label="K2_HITS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemCategory" type="radio" default="1" label="K2_CATEGORY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemTags" type="radio" default="1" label="K2_TAGS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemAttachments" type="radio" default="0" label="K2_ATTACHMENTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemAttachmentsCounter" type="radio" default="0" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemVideo" type="radio" default="0" label="K2_MEDIA" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<field name="catItemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<field name="catItemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<field name="catItemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<field name="catItemVideoAutoPlay" type="radio" default="0" label="K2_MEDIA_AUTOPLAY" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="catItemImageGallery" type="radio" default="0" label="K2_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<field name="catItemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<field name="catItemDateModified" type="radio" default="0" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemReadMore" type="radio" default="1" label="K2_READ_MORE_LINK" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemCommentsAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_ITEMS_COMMENT_FORM" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_ADVANCED" label="" description=""/>
<field name="catItemK2Plugins" type="radio" default="1" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
</fieldset>
<fieldset name="item-view-options" addfieldpath="/administrator/components/com_k2/elements">
<field name="itemDateCreated" type="radio" default="1" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemTitle" type="radio" default="1" label="K2_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFeaturedNotice" type="radio" default="1" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthor" type="radio" default="1" label="K2_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFontResizer" type="radio" default="1" label="K2_FONT_RESIZER" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemPrintButton" type="radio" default="1" label="K2_PRINT_BUTTON" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemEmailButton" type="radio" default="1" label="K2_EMAIL_BUTTON" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemSocialButton" type="radio" default="1" label="K2_SOCIAL_BUTTON_LIKE_SHARETHIS_ADDTHIS_ETC" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideoAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_TO_VIDEO" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageGalleryAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_TO_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemCommentsAnchor" type="radio" default="1" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_COMMENT_FORM" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRating" type="radio" default="1" label="K2_RATING_VOTING" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImage" type="radio" default="1" label="K2_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImgSize" type="list" default="Large" label="K2_IMAGE_SIZE" description="">
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</field>
<field name="itemImageMainCaption" type="radio" default="1" label="K2_IMAGE_CAPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageMainCredits" type="radio" default="1" label="K2_IMAGE_CREDITS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemIntroText" type="radio" default="1" label="K2_INTROTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFullText" type="radio" default="1" label="K2_FULLTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemExtraFields" type="radio" default="1" label="K2_EXTRA_FIELDS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemDateModified" type="radio" default="1" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemHits" type="radio" default="1" label="K2_HITS_PAGE_VIEWS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemCategory" type="radio" default="1" label="K2_CATEGORY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemTags" type="radio" default="1" label="K2_TAGS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAttachments" type="radio" default="1" label="K2_ATTACHMENTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAttachmentsCounter" type="radio" default="1" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideo" type="radio" default="1" label="K2_MEDIA" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<field name="itemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<field name="itemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<field name="itemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<field name="itemVideoAutoPlay" type="radio" default="0" label="K2_MEDIA_AUTOPLAY" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="itemVideoCaption" type="radio" default="1" label="K2_MEDIA_CAPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideoCredits" type="radio" default="1" label="K2_MEDIA_CREDITS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageGallery" type="radio" default="1" label="K2_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<field name="itemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<field name="itemNavigation" type="radio" default="1" label="K2_ITEM_NAVIGATION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemComments" type="radio" default="1" label="K2_COMMENTS" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_SOCIAL_SHARING" label="" description=""/>
<field name="itemTwitterButton" type="radio" default="1" label="K2_TWITTER_SHARE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFacebookButton" type="radio" default="1" label="K2_FACEBOOK_SHARE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemGooglePlusOneButton" type="radio" default="1" label="K2_GOOGLEPLUSONE_SHARE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_AUTHOR_OPTIONS" label="" description=""/>
<field name="itemAuthorBlock" type="radio" default="1" label="K2_DISPLAY_EXTENDED_AUTHOR_INFO" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorImage" type="radio" default="1" label="K2_AUTHOR_IMAGE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorDescription" type="radio" default="1" label="K2_AUTHOR_DESCRIPTION" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorURL" type="radio" default="1" label="K2_AUTHOR_URL" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorEmail" type="radio" default="0" label="K2_AUTHOR_EMAIL" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorLatest" type="radio" default="1" label="K2_LATEST_ITEMS_FROM_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorLatestLimit" type="text" default="5" size="4" label="K2_LIMIT_FOR_LATEST_ITEMS_FROM_AUTHOR" description=""/>
<field name="" type="header" default="K2_RELATED_ITEMS" label="" description=""/>
<field name="itemRelated" type="radio" default="1" label="K2_RELATED_ITEMS_BY_TAG" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedLimit" type="text" default="5" size="4" label="K2_RELATED_ITEMS_LIMIT" description=""/>
<field name="itemRelatedTitle" type="radio" default="1" label="K2_RELATED_ITEMS_TITLE" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedCategory" type="radio" default="0" label="K2_RELATED_ITEMS_CATEGORY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedImageSize" type="list" default="0" label="K2_RELATED_ITEMS_IMAGE" description="">
<option value="0">K2_NONE_SELECTED</option>
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</field>
<field name="itemRelatedIntrotext" type="radio" default="0" label="K2_RELATED_ITEMS_INTROTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedFulltext" type="radio" default="0" label="K2_RELATED_ITEMS_FULLTEXT" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedAuthor" type="radio" default="0" label="K2_RELATED_ITEMS_AUTHOR" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedMedia" type="radio" default="0" label="K2_RELATED_ITEMS_MEDIA" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedImageGallery" type="radio" default="0" label="K2_RELATED_ITEMS_IMAGE_GALLERY" description="">
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_ADVANCED" label="" description=""/>
<field name="itemK2Plugins" type="radio" default="1" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
</fieldset>
<!-- Metadata Information -->
<fieldset name="category-metadata-information" addfieldpath="/administrator/components/com_k2/elements">
<field name="catMetaDesc" type="k2textarea" chars="160" default="" label="K2_DESCRIPTION" description="" rows="4" cols="25" />
<field name="catMetaKey" type="textarea" default="" label="K2_KEYWORDS" description="" rows="4" cols="25" />
<field name="catMetaRobots" type="list" default="" label="K2_ROBOTS" description="">
<option value="">K2_USE_GLOBAL</option>
<option value="index, follow">K2_METADATA_ROBOTS_INDEX_FOLLOW</option>
<option value="index, nofollow">K2_METADATA_ROBOTS_INDEX_NOFOLLOW</option>
<option value="noindex, follow">K2_METADATA_ROBOTS_NOINDEX_FOLLOW</option>
<option value="noindex, nofollow">K2_METADATA_ROBOTS_NOINDEX_NOFOLLOW</option>
</field>
<field name="catMetaAuthor" type="text" default="" label="K2_AUTHOR" description="" />
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,479 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelComments extends K2Model {
function getData() {
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', 'c.id', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', 'DESC', 'word');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', -1, 'int');
$filter_category = $application->getUserStateFromRequest($option.$view.'filter_category', 'filter_category', 0, 'int');
$filter_author = $application->getUserStateFromRequest($option.$view.'filter_author', 'filter_author', 0, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\"\.\@\-_]/u', '', $search));
$query = "SELECT c.*, i.title , i.catid, i.alias AS itemAlias, i.created_by, cat.alias AS catAlias, cat.name as catName FROM #__k2_comments AS c LEFT JOIN #__k2_items AS i ON c.itemID=i.id LEFT JOIN #__k2_categories AS cat ON cat.id=i.catid LEFT JOIN #__k2_users AS u ON c.userID=u.userID WHERE c.id>0";
if ($filter_state > - 1) {
$query .= " AND c.published={$filter_state}";
}
if ($filter_category) {
$query .= " AND i.catid={$filter_category}";
}
if ($filter_author) {
$query .= " AND i.created_by={$filter_author}";
}
if ($search)
{
// Detect exact search phrase using double quotes in search string
if(substr($search, 0, 1)=='"' && substr($search, -1)=='"')
{
$exact = true;
}
else
{
$exact = false;
}
// Now completely strip double quotes
$search = trim(str_replace('"', '', $search));
// Escape remaining string
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
// Full phrase or set of words
if(strpos($escaped, ' ')!==false && !$exact)
{
$escaped=explode(' ', $escaped);
$quoted = array();
foreach($escaped as $key=>$escapedWord)
{
$quoted[] = $db->Quote('%'.$escapedWord.'%', false);
}
if ($params->get('adminSearch') == 'full')
{
foreach($quoted as $quotedWord)
{
$query .= " AND ( ".
"LOWER(c.commentText) LIKE ".$quotedWord." ".
"OR LOWER(c.userName) LIKE ".$quotedWord." ".
"OR LOWER(c.commentEmail) LIKE ".$quotedWord." ".
"OR LOWER(c.commentURL) LIKE ".$quotedWord." ".
"OR LOWER(i.title) LIKE ".$quotedWord." ".
"OR LOWER(u.userName) LIKE ".$quotedWord." ".
"OR LOWER(u.ip) LIKE ".$quotedWord." ".
" )";
}
}
else
{
foreach($quoted as $quotedWord)
{
$query .= " AND LOWER(c.commentText) LIKE ".$quotedWord;
}
}
}
// Single word or exact phrase to search for (wrapped in double quotes in the search block)
else
{
$quoted = $db->Quote('%'.$escaped.'%', false);
if ($params->get('adminSearch') == 'full')
{
$query .= " AND ( ".
"LOWER(c.commentText) LIKE ".$quoted." ".
"OR LOWER(c.userName) LIKE ".$quoted." ".
"OR LOWER(c.commentEmail) LIKE ".$quoted." ".
"OR LOWER(c.commentURL) LIKE ".$quoted." ".
"OR LOWER(i.title) LIKE ".$quoted." ".
"OR LOWER(u.userName) LIKE ".$quoted." ".
"OR LOWER(u.ip) LIKE ".$quoted." ".
" )";
}
else
{
$query .= " AND LOWER(c.commentText) LIKE ".$quoted;
}
}
}
if (!$filter_order) {
$filter_order = "c.commentDate";
}
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}";
$db->setQuery($query, $limitstart, $limit);
$rows = $db->loadObjectList();
return $rows;
}
function getTotal() {
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', 1, 'int');
$filter_category = $application->getUserStateFromRequest($option.$view.'filter_category', 'filter_category', 0, 'int');
$filter_author = $application->getUserStateFromRequest($option.$view.'filter_author', 'filter_author', 0, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\"\.\@\-_]/u', '', $search));
$query = "SELECT COUNT(*) FROM #__k2_comments AS c LEFT JOIN #__k2_items AS i ON c.itemID=i.id LEFT JOIN #__k2_users AS u ON c.userID=u.userID WHERE c.id>0";
if ($filter_state > - 1) {
$query .= " AND c.published={$filter_state}";
}
if ($filter_category) {
$query .= " AND i.catid={$filter_category}";
}
if ($filter_author) {
$query .= " AND i.created_by={$filter_author}";
}
if ($search)
{
// Detect exact search phrase using double quotes in search string
if(substr($search, 0, 1)=='"' && substr($search, -1)=='"')
{
$exact = true;
}
else
{
$exact = false;
}
// Now completely strip double quotes
$search = trim(str_replace('"', '', $search));
// Escape remaining string
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
// Full phrase or set of words
if(strpos($escaped, ' ')!==false && !$exact)
{
$escaped=explode(' ', $escaped);
$quoted = array();
foreach($escaped as $key=>$escapedWord)
{
$quoted[] = $db->Quote('%'.$escapedWord.'%', false);
}
if ($params->get('adminSearch') == 'full')
{
foreach($quoted as $quotedWord)
{
$query .= " AND ( ".
"LOWER(c.commentText) LIKE ".$quotedWord." ".
"OR LOWER(c.userName) LIKE ".$quotedWord." ".
"OR LOWER(c.commentEmail) LIKE ".$quotedWord." ".
"OR LOWER(c.commentURL) LIKE ".$quotedWord." ".
"OR LOWER(i.title) LIKE ".$quotedWord." ".
"OR LOWER(u.userName) LIKE ".$quotedWord." ".
"OR LOWER(u.ip) LIKE ".$quotedWord." ".
" )";
}
}
else
{
foreach($quoted as $quotedWord)
{
$query .= " AND LOWER(c.commentText) LIKE ".$quotedWord;
}
}
}
// Single word or exact phrase to search for (wrapped in double quotes in the search block)
else
{
$quoted = $db->Quote('%'.$escaped.'%', false);
if ($params->get('adminSearch') == 'full')
{
$query .= " AND ( ".
"LOWER(c.commentText) LIKE ".$quoted." ".
"OR LOWER(c.userName) LIKE ".$quoted." ".
"OR LOWER(c.commentEmail) LIKE ".$quoted." ".
"OR LOWER(c.commentURL) LIKE ".$quoted." ".
"OR LOWER(i.title) LIKE ".$quoted." ".
"OR LOWER(u.userName) LIKE ".$quoted." ".
"OR LOWER(u.ip) LIKE ".$quoted." ".
" )";
}
else
{
$query .= " AND LOWER(c.commentText) LIKE ".$quoted;
}
}
}
$db->setQuery($query);
$total = $db->loadresult();
return $total;
}
function publish() {
$application = JFactory::getApplication();
$user = JFactory::getUser();
$cid = JRequest::getVar('cid');
if(!count($cid)){
$cid[]=JRequest::getInt('commentID');
}
foreach ($cid as $id) {
$row = JTable::getInstance('K2Comment', 'Table');
$row->load($id);
if($application->isSite()){
$item = JTable::getInstance('K2Item', 'Table');
$item->load($row->itemID);
if ($item->created_by != $user->id) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
$application->close();
}
}
$row->published = 1;
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('format')=='raw'){
echo 'true';
$application->close();
}
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=comments&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=comments');
}
}
function unpublish() {
$application = JFactory::getApplication();
$user = JFactory::getUser();
$cid = JRequest::getVar('cid');
foreach ($cid as $id) {
$row = JTable::getInstance('K2Comment', 'Table');
$row->load($id);
if($application->isSite()){
$item = JTable::getInstance('K2Item', 'Table');
$item->load($row->itemID);
if ($item->created_by != $user->id) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
$application->close();
}
}
$row->published = 0;
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=comments&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=comments');
}
}
function remove() {
$application = JFactory::getApplication();
$user = JFactory::getUser();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
if(!count($cid)){
$cid[]=JRequest::getInt('commentID');
}
foreach ($cid as $id) {
$row = JTable::getInstance('K2Comment', 'Table');
$row->load($id);
if($application->isSite()){
$item = JTable::getInstance('K2Item', 'Table');
$item->load($row->itemID);
if ($item->created_by != $user->id) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
$application->close();
}
}
$row->delete($id);
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('format')=='raw'){
echo 'true';
$application->close();
}
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=comments&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=comments');
}
}
function deleteUnpublished() {
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$user = JFactory::getUser();
$userID = $user->id;
if($application->isSite()){
$query = "SELECT c.id FROM #__k2_comments AS c
LEFT JOIN #__k2_items AS i ON c.itemID=i.id
WHERE i.created_by = {$userID} AND c.published=0";
$db->setQuery($query);
$ids = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
if (count($ids)){
$query = "DELETE FROM #__k2_comments WHERE id IN(".implode(',', $ids).")";
$db->setQuery($query);
$db->query();
}
}
else {
$query = "DELETE FROM #__k2_comments WHERE published=0";
$db->setQuery($query);
$db->query();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=comments&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=comments');
}
}
function save() {
$application = JFactory::getApplication();
$user = JFactory::getUser();
$db = JFactory::getDbo();
$id = JRequest::getInt('commentID');
$item = JTable::getInstance('K2Item', 'Table');
$row = JTable::getInstance('K2Comment', 'Table');
$row->load($id);
if($application->isSite()){
$item->load($row->itemID);
if ($item->created_by != $user->id) {
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
}
}
$row->commentText = JRequest::getVar('commentText', '', 'default', 'string', 4);
$row->store();
$cache = JFactory::getCache('com_k2');
$cache->clean();
$response = new JObject;
$response->comment = $row->commentText;
$response->message = JText::_('K2_COMMENT_SAVED');
unset($response->_errors);
echo json_encode($response);
$application->close();
}
function report(){
$id = $this->getState('id');
$name = JString::trim($this->getState('name'));
$reportReason = JString::trim($this->getState('reportReason'));
$params = K2HelperUtilities::getParams('com_k2');
$user = JFactory::getUser();
$row = JTable::getInstance('K2Comment', 'Table');
$row->load($id);
if(!$row->published){
$this->setError(JText::_('K2_COMMENT_NOT_FOUND'));
return false;
}
if(empty($name)){
$this->setError(JText::_('K2_PLEASE_TYPE_YOUR_NAME'));
return false;
}
if(empty($reportReason)){
$this->setError(JText::_('K2_PLEASE_TYPE_THE_REPORT_REASON'));
return false;
}
if (($params->get('antispam') == 'recaptcha' || $params->get('antispam') == 'both') && $user->guest) {
if($params->get('recaptchaV2'))
{
require_once JPATH_SITE.'/components/com_k2/helpers/utilities.php';
if (!K2HelperUtilities::verifyRecaptcha())
{
$this->setError(JText::_('K2_COULD_NOT_VERIFY_THAT_YOU_ARE_NOT_A_ROBOT'));
return false;
}
}
else
{
if(!function_exists('_recaptcha_qsencode'))
{
require_once(JPATH_SITE.'/media/k2/assets/vendors/google/recaptcha_legacy/recaptcha.php');
}
$privatekey = $params->get('recaptcha_private_key');
$resp = recaptcha_check_answer($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
if (!$resp->is_valid) {
$this->setError(JText::_('K2_THE_WORDS_YOU_TYPED_DID_NOT_MATCH_THE_ONES_DISPLAYED_PLEASE_TRY_AGAIN'));
return false;
}
}
}
$application = JFactory::getApplication();
$mail = JFactory::getMailer();
$senderEmail = $application->getCfg('mailfrom');
$senderName = $application->getCfg('fromname');
$mail->setSender(array($senderEmail, $senderName));
$mail->setSubject(JText::_('K2_COMMENT_REPORT'));
$mail->IsHTML(true);
switch(substr(strtoupper(PHP_OS), 0, 3)) {
case 'WIN':
$mail->LE = "\r\n";
break;
case 'MAC':
case 'DAR':
$mail->LE = "\r";
default:
break;
}
// K2 embedded email template (to do: move to separate HTML template/override)
$body = "
<strong>".JText::_('K2_NAME')."</strong>: ".$name." <br/>
<strong>".JText::_('K2_REPORT_REASON')."</strong>: ".$reportReason." <br/>
<strong>".JText::_('K2_COMMENT')."</strong>: ".nl2br($row->commentText)." <br/>
";
$mail->setBody($body);
$mail->ClearAddresses();
$mail->AddAddress($params->get('commentsReportRecipient', $application->getCfg('mailfrom')));
$mail->Send();
return true;
}
}

View File

@ -0,0 +1,481 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelExtraField extends K2Model
{
function getData()
{
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($cid);
return $row;
}
function save()
{
$application = JFactory::getApplication();
$row = JTable::getInstance('K2ExtraField', 'Table');
if (!$row->bind(JRequest::get('post')))
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=extrafields');
}
$isNewGroup = JRequest::getInt('isNew');
if ($isNewGroup)
{
$group = JTable::getInstance('K2ExtraFieldsGroup', 'Table');
$group->set('name', JRequest::getVar('group'));
$group->store();
$row->group = $group->id;
}
if (!$row->id)
{
$row->ordering = $row->getNextOrder("`group` = ".(int)$row->group);
}
$objects = array();
$values = JRequest::getVar('option_value', null, 'default', 'none', 4);
$names = JRequest::getVar('option_name');
$target = JRequest::getVar('option_target');
$editor = JRequest::getVar('option_editor');
$rows = JRequest::getVar('option_rows');
$cols = JRequest::getVar('option_cols');
$alias = JRequest::getWord('alias');
$required = JRequest::getInt('required');
$showNull = JRequest::getInt('showNull');
$displayInFrontEnd = JRequest::getInt('displayInFrontEnd');
if (JString::strtolower($alias) == 'this')
{
$alias = '';
}
$lastOptionId = 1;
for ($i = 0; $i < sizeof($values); $i++)
{
$object = new JObject;
$object->set('name', $names[$i]);
if ($row->type == 'select' || $row->type == 'multipleSelect' || $row->type == 'radio')
{
if(!empty($values[$i]))
{
$object->set('value', $values[$i]);
$lastOptionId = intval($values[$i]);
}
else
{
$lastOptionId ++;
$object->set('value', $lastOptionId);
}
}
elseif ($row->type == 'link')
{
if (trim($values[$i]) != '')
{
if (substr($values[$i], 0, 7) == 'http://' || substr($values[$i], 0, 8) == 'https://' || substr($values[$i], 0, 2) == '//' || substr($values[$i], 0, 1) == '/' || substr($values[$i], 0, 7) == 'mailto:' || substr($values[$i], 0, 4) == 'tel:' )
{
$values[$i] = $values[$i];
}
else
{
$values[$i] = 'http://'.$values[$i];
}
}
$object->set('value', trim($values[$i]));
}
elseif ($row->type == 'csv')
{
$file = JRequest::getVar('csv_file', NULL, 'FILES');
$csvFile = $file['tmp_name'];
if (!empty($csvFile) && JFile::getExt($file['name']) == 'csv')
{
$handle = @fopen($csvFile, 'r');
$csvData = array();
while (($data = fgetcsv($handle, 1000)) !== FALSE)
{
$csvData[] = $data;
}
fclose($handle);
$object->set('value', $csvData);
}
else
{
$object->set('value', json_decode($values[$i]));
if (JRequest::getBool('K2ResetCSV'))
$object->set('value', null);
}
}
elseif ($row->type == 'textarea')
{
$object->set('value', $values[$i]);
$object->set('editor', $editor[$i]);
$object->set('rows', $rows[$i]);
$object->set('cols', $cols[$i]);
}
elseif ($row->type == 'image')
{
$object->set('value', $values[$i]);
}
elseif ($row->type == 'header')
{
$object->set('value', JRequest::getString('name'));
$object->set('displayInFrontEnd', $displayInFrontEnd);
}
else
{
$object->set('value', $values[$i]);
}
$object->set('target', $target[$i]);
$object->set('alias', $alias);
$object->set('required', $required);
$object->set('showNull', $showNull);
unset($object->_errors);
$objects[] = $object;
}
$row->value = json_encode($objects);
if (!$row->check())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=extrafield&cid='.$row->id);
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=extrafields');
}
$params = JComponentHelper::getParams('com_k2');
if (!$params->get('disableCompactOrdering'))
$row->reorder("`group` = ".(int)$row->group);
$cache = JFactory::getCache('com_k2');
$cache->clean();
switch(JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_EXTRA_FIELD_SAVED');
$link = 'index.php?option=com_k2&view=extrafield&cid='.$row->id;
break;
case 'save' :
default :
$msg = JText::_('K2_EXTRA_FIELD_SAVED');
$link = 'index.php?option=com_k2&view=extrafields';
break;
}
$application->enqueueMessage($msg);
$application->redirect($link);
}
function getExtraFieldsByGroup($group)
{
$db = JFactory::getDbo();
$group = (int)$group;
$query = "SELECT * FROM #__k2_extra_fields WHERE `group`={$group} AND published=1 ORDER BY ordering";
$db->setQuery($query);
$rows = $db->loadObjectList();
return $rows;
}
function renderExtraField($extraField, $itemID = NULL)
{
$application = JFactory::getApplication();
if (!is_null($itemID))
{
$item = JTable::getInstance('K2Item', 'Table');
$item->load($itemID);
}
$defaultValues = json_decode($extraField->value);
foreach ($defaultValues as $value)
{
$required = isset($value->required) ? $value->required : 0;
$showNull = isset($value->showNull) ? $value->showNull : 0;
if ($extraField->type == 'textfield' || $extraField->type == 'csv' || $extraField->type == 'labels' || $extraField->type == 'date' || $extraField->type == 'image')
{
$active = $value->value;
}
elseif ($extraField->type == 'textarea')
{
$active[0] = $value->value;
$active[1] = $value->editor;
$active[2] = (int)$value->rows ? (int)$value->rows : 10;
$active[3] = (int)$value->cols ? (int)$value->cols : 40;
}
elseif ($extraField->type == 'link')
{
$active[0] = $value->name;
$active[1] = $value->value;
$active[2] = $value->target;
}
else
{
$active = '';
}
}
if (!isset($active))
{
$active = '';
}
if (isset($item))
{
$currentValues = json_decode($item->extra_fields);
if (count($currentValues))
{
foreach ($currentValues as $value)
{
if ($value->id == $extraField->id)
{
if ($extraField->type == 'textarea')
{
$active[0] = $value->value;
}
else if ($extraField->type == 'date')
{
$active = (is_array($value->value)) ? $value->value[0] : $value->value;
}
else if ($extraField->type == 'header')
{
continue;
}
else
{
$active = $value->value;
}
}
}
}
}
$attributes = '';
$arrayAttributes = array();
if ($required)
{
$arrayAttributes['class'] = "k2Required";
$attributes .= 'class="k2Required"';
}
if ($showNull && in_array($extraField->type, array(
'select',
'multipleSelect'
)))
{
$nullOption = new stdClass;
$nullOption->name = JText::_('K2_PLEASE_SELECT');
$nullOption->value = '';
array_unshift($defaultValues, $nullOption);
}
if (in_array($extraField->type, array(
'textfield',
'labels',
'date',
'image'
)))
{
$active = htmlspecialchars($active, ENT_QUOTES, 'UTF-8');
}
switch ($extraField->type)
{
case 'textfield' :
$output = '<input type="text" name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" value="'.$active.'" '.$attributes.' />';
break;
case 'labels' :
$output = '<input type="text" name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" value="'.$active.'" '.$attributes.' /> '.JText::_('K2_COMMA_SEPARATED_VALUES');
break;
case 'textarea' :
if ($active[1])
{
if ($required)
{
$attributes = 'class="k2ExtraFieldEditor k2Required"';
}
else
{
$attributes = 'class="k2ExtraFieldEditor"';
}
}
$output = '<textarea name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" rows="'.$active[2].'" cols="'.$active[3].'" '.$attributes.'>'.htmlspecialchars($active[0], ENT_QUOTES, 'UTF-8').'</textarea>';
break;
case 'select' :
$attributes .= ' id="K2ExtraField_'.$extraField->id.'"';
$arrayAttributes['id'] = 'K2ExtraField_'.$extraField->id;
$attrs = version_compare(JVERSION, '3.2', 'ge') ? $arrayAttributes : $attributes;
$output = JHTML::_('select.genericlist', $defaultValues, 'K2ExtraField_'.$extraField->id, $attrs, 'value', 'name', $active);
break;
case 'multipleSelect' :
$attributes .= ' id="K2ExtraField_'.$extraField->id.'" multiple="multiple"';
$arrayAttributes['id'] = 'K2ExtraField_'.$extraField->id;
$arrayAttributes['multiple'] = "multiple";
$attrs = version_compare(JVERSION, '3.2', 'ge') ? $arrayAttributes : $attributes;
$output = JHTML::_('select.genericlist', $defaultValues, 'K2ExtraField_'.$extraField->id.'[]', $attrs, 'value', 'name', $active);
break;
case 'radio' :
if (!$active && isset($defaultValues[0]))
{
$active = $defaultValues[0]->value;
}
$attrs = version_compare(JVERSION, '3.2', 'ge') ? $arrayAttributes : $attributes;
$output = JHTML::_('select.radiolist', $defaultValues, 'K2ExtraField_'.$extraField->id, $attrs, 'value', 'name', $active);
break;
case 'link' :
$output = '<label>'.JText::_('K2_TEXT').'</label>';
$output .= '<input type="text" name="K2ExtraField_'.$extraField->id.'[]" value="'.htmlspecialchars($active[0], ENT_QUOTES, 'UTF-8').'" />';
$output .= '<label>'.JText::_('K2_URL').'</label>';
$output .= '<input type="text" name="K2ExtraField_'.$extraField->id.'[]" id="K2ExtraField_'.$extraField->id.'" value="'.htmlspecialchars($active[1], ENT_QUOTES, 'UTF-8').'" '.$attributes.'/>';
$output .= '<label>'.JText::_('K2_OPEN_IN').'</label>';
$targetOptions[] = JHTML::_('select.option', 'same', JText::_('K2_SAME_WINDOW'));
$targetOptions[] = JHTML::_('select.option', 'new', JText::_('K2_NEW_WINDOW'));
$targetOptions[] = JHTML::_('select.option', 'popup', JText::_('K2_CLASSIC_JAVASCRIPT_POPUP'));
$targetOptions[] = JHTML::_('select.option', 'lightbox', JText::_('K2_LIGHTBOX_POPUP'));
$output .= JHTML::_('select.genericlist', $targetOptions, 'K2ExtraField_'.$extraField->id.'[]', '', 'value', 'text', $active[2]);
break;
case 'csv' :
if ($active)
{
$attributes = '';
}
$output = '<input type="file" id="K2ExtraField_'.$extraField->id.'" name="K2ExtraField_'.$extraField->id.'[]" '.$attributes.' />';
if (is_array($active) && count($active))
{
$output .= '<input type="hidden" name="K2CSV_'.$extraField->id.'" value="'.htmlspecialchars(json_encode($active)).'" />';
$output .= '<table class="csvTable">';
foreach ($active as $key => $row)
{
$output .= '<tr>';
foreach ($row as $cell)
{
$output .= ($key > 0) ? '<td>'.$cell.'</td>' : '<th>'.$cell.'</th>';
}
$output .= '</tr>';
}
$output .= '</table>';
$output .= '<label>'.JText::_('K2_DELETE_CSV_DATA').'</label>';
$output .= '<input type="checkbox" name="K2ResetCSV_'.$extraField->id.'" />';
}
break;
case 'date' :
if ($required)
{
$cssClass = 'k2Calendar k2Required';
}
else
{
$cssClass = 'k2Calendar';
}
$output = '<input class="'.$cssClass.'" type="text" data-k2-datetimepicker="{allowInput:true}" name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" value="'.$active.'" />';
break;
case 'image' :
$output = '<input type="text" name="K2ExtraField_'.$extraField->id.'" id="K2ExtraField_'.$extraField->id.'" value="'.$active.'" '.$attributes.' />
<a class="k2ExtraFieldImageButton" href="'.JURI::base(true).'/index.php?option=com_k2&view=media&type=image&tmpl=component&fieldID=K2ExtraField_'.$extraField->id.'">'.JText::_('K2_SELECT').'</a>';
break;
case 'header' :
$output = '';
break;
}
return $output;
}
function getExtraFieldInfo($fieldID)
{
$db = JFactory::getDbo();
$fieldID = (int)$fieldID;
$query = "SELECT * FROM #__k2_extra_fields WHERE published=1 AND id = ".$fieldID;
$db->setQuery($query, 0, 1);
$row = $db->loadObject();
return $row;
}
function getSearchValue($id, $currentValue)
{
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($id);
$jsonObject = json_decode($row->value);
$value = '';
if ($row->type == 'textfield' || $row->type == 'textarea')
{
$value = $currentValue;
}
else if ($row->type == 'multipleSelect')
{
foreach ($jsonObject as $option)
{
if (in_array($option->value, $currentValue))
$value .= $option->name.' ';
}
}
else if ($row->type == 'link')
{
$value .= $currentValue[0].' ';
$value .= $currentValue[1].' ';
}
else if ($row->type == 'labels')
{
$parts = explode(',', $currentValue);
$value .= implode(' ', $parts);
}
else
{
foreach ($jsonObject as $option)
{
if ($option->value == $currentValue)
$value .= $option->name;
}
}
return $value;
}
}

View File

@ -0,0 +1,373 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelExtraFields extends K2Model
{
function getData()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', 'groupname', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', 'ASC', 'word');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', -1, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\-_]/u', '', $search));
$filter_type = $application->getUserStateFromRequest($option.$view.'filter_type', 'filter_type', '', 'string');
$filter_group = $application->getUserStateFromRequest($option.$view.'filter_group', 'filter_group', 0, 'int');
$query = "SELECT exf.*, exfg.name as groupname FROM #__k2_extra_fields AS exf LEFT JOIN #__k2_extra_fields_groups exfg ON exf.group=exfg.id WHERE exf.id>0";
if ($filter_state > -1)
{
$query .= " AND published={$filter_state}";
}
if ($search)
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$query .= " AND LOWER( exf.name ) LIKE ".$db->Quote('%'.$escaped.'%', false);
}
if ($filter_type)
{
$query .= " AND `type`=".$db->Quote($filter_type);
}
if ($filter_group)
{
$query .= " AND `group`={$filter_group}";
}
if (!$filter_order)
{
$filter_order = '`group`';
}
if ($filter_order == 'ordering')
{
$query .= " ORDER BY `group`, ordering {$filter_order_Dir}";
}
else
{
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}, `group`, ordering";
}
$db->setQuery($query, $limitstart, $limit);
$rows = $db->loadObjectList();
return $rows;
}
function getTotal()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', 1, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\-_]/u', '', $search));
$filter_type = $application->getUserStateFromRequest($option.$view.'filter_type', 'filter_type', '', 'string');
$filter_group = $application->getUserStateFromRequest($option.$view.'filter_group', 'filter_group', '', 'string');
$query = "SELECT COUNT(*) FROM #__k2_extra_fields WHERE id>0";
if ($filter_state > -1)
{
$query .= " AND published={$filter_state}";
}
if ($search)
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$query .= " AND LOWER( name ) LIKE ".$db->Quote('%'.$escaped.'%', false);
}
if ($filter_type)
{
$query .= " AND `type`=".$db->Quote($filter_type);
}
if ($filter_group)
{
$query .= " AND `group`=".$db->Quote($filter_group);
}
$db->setQuery($query);
$total = $db->loadresult();
return $total;
}
function publish()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($id);
$row->published = 1;
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->redirect('index.php?option=com_k2&view=extrafields');
}
function unpublish()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($id);
$row->published = 0;
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->redirect('index.php?option=com_k2&view=extrafields');
}
function saveorder()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid', array(0), 'post', 'array');
$total = count($cid);
$order = JRequest::getVar('order', array(0), 'post', 'array');
JArrayHelper::toInteger($order, array(0));
$groupings = array();
for ($i = 0; $i < $total; $i++)
{
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load((int)$cid[$i]);
$groupings[] = $row->group;
if ($row->ordering != $order[$i])
{
$row->ordering = $order[$i];
if (!$row->store())
{
JError::raiseError(500, $db->getErrorMsg());
}
}
}
$params = JComponentHelper::getParams('com_k2');
if (!$params->get('disableCompactOrdering'))
{
$groupings = array_unique($groupings);
foreach ($groupings as $group)
{
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->reorder("`group` = ".(int)$group);
}
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
return true;
}
function orderup()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($cid[0]);
$row->move(-1, "`group` = '{$row->group}'");
$params = JComponentHelper::getParams('com_k2');
if (!$params->get('disableCompactOrdering'))
$row->reorder("`group` = ".(int)$row->group);
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ORDERING_SAVED');
$application->enqueueMessage($msg);
$application->redirect('index.php?option=com_k2&view=extrafields');
}
function orderdown()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($cid[0]);
$row->move(1, "`group` = '{$row->group}'");
$params = JComponentHelper::getParams('com_k2');
if (!$params->get('disableCompactOrdering'))
$row->reorder("`group` = ".(int)$row->group);
$cache = JFactory::getCache('com_k2');
$cache->clean();
$msg = JText::_('K2_NEW_ORDERING_SAVED');
$application->enqueueMessage($msg);
$application->redirect('index.php?option=com_k2&view=extrafields');
}
function remove()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2ExtraField', 'Table');
$row->load($id);
$row->delete($id);
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=extrafields');
}
function getExtraFieldsGroup()
{
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2ExtraFieldsGroup', 'Table');
$row->load($cid);
return $row;
}
function getGroups($filter = false)
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$db = JFactory::getDbo();
$query = "SELECT * FROM #__k2_extra_fields_groups ORDER BY `name`";
if ($filter)
{
$db->setQuery($query);
}
else
{
$db->setQuery($query, $limitstart, $limit);
}
$rows = $db->loadObjectList();
for ($i = 0; $i < sizeof($rows); $i++)
{
$query = "SELECT name FROM #__k2_categories WHERE extraFieldsGroup=".(int)$rows[$i]->id;
$db->setQuery($query);
$categories = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
if (is_array($categories))
{
$rows[$i]->categories = implode(', ', $categories);
}
else
{
$rows[$i]->categories = '';
}
}
return $rows;
}
function getTotalGroups()
{
$db = JFactory::getDbo();
$query = "SELECT COUNT(*) FROM #__k2_extra_fields_groups";
$db->setQuery($query);
$total = $db->loadResult();
return $total;
}
function saveGroup()
{
$application = JFactory::getApplication();
$id = JRequest::getInt('id');
$row = JTable::getInstance('K2ExtraFieldsGroup', 'Table');
if (!$row->bind(JRequest::get('post')))
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=extrafieldsgroups');
}
if (!$row->check())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=extrafieldsgroup&cid='.$row->id);
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=extrafieldsgroup');
}
switch(JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_GROUP_SAVED');
$link = 'index.php?option=com_k2&view=extrafieldsgroup&cid='.$row->id;
break;
case 'save' :
default :
$msg = JText::_('K2_GROUP_SAVED');
$link = 'index.php?option=com_k2&view=extrafieldsgroups';
break;
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage($msg);
$application->redirect($link);
}
function removeGroups()
{
$application = JFactory::getApplication();
$db = &JFactory::getDbo();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
foreach ($cid as $id)
{
$row = JTable::getInstance('K2ExtraFieldsGroup', 'Table');
$row->load($id);
$query = "DELETE FROM #__k2_extra_fields WHERE `group`={$id}";
$db->setQuery($query);
$db->query();
$row->delete($id);
}
$cache = &JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=extrafieldsgroups');
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,786 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<name>K2_ITEM_EDIT_FORM</name>
<params group="item-view-options-listings" addpath="/administrator/components/com_k2/elements">
<param name="catItemTitle" type="radio" default="" label="K2_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemTitleLinked" type="radio" default="" label="K2_LINK_ON_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemFeaturedNotice" type="radio" default="" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemAuthor" type="radio" default="" label="K2_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemDateCreated" type="radio" default="" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemRating" type="radio" default="" label="K2_RATING_VOTING" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemImage" type="radio" default="" label="K2_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemIntroText" type="radio" default="" label="K2_INTROTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemExtraFields" type="radio" default="" label="K2_EXTRA_FIELDS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemHits" type="radio" default="" label="K2_HITS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemCategory" type="radio" default="" label="K2_CATEGORY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemTags" type="radio" default="" label="K2_TAGS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemAttachments" type="radio" default="" label="K2_ATTACHMENTS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemAttachmentsCounter" type="radio" default="" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemVideo" type="radio" default="" label="K2_MEDIA" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<param name="catItemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<param name="catItemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<param name="catItemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<param name="catItemVideoAutoPlay" type="radio" default="" label="K2_MEDIA_AUTOPLAY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="catItemImageGallery" type="radio" default="" label="K2_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<param name="catItemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<param name="catItemDateModified" type="radio" default="" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemReadMore" type="radio" default="" label="K2_READ_MORE_LINK" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="catItemCommentsAnchor" type="radio" default="" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_ITEMS_COMMENT_FORM" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_ADVANCED" label="" description=""/>
<param name="catItemK2Plugins" type="radio" default="" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
</params>
<params group="item-view-options" addpath="/administrator/components/com_k2/elements">
<param name="itemDateCreated" type="radio" default="" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemTitle" type="radio" default="" label="K2_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFeaturedNotice" type="radio" default="" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthor" type="radio" default="" label="K2_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFontResizer" type="radio" default="" label="K2_FONT_RESIZER" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemPrintButton" type="radio" default="" label="K2_PRINT_BUTTON" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemEmailButton" type="radio" default="" label="K2_EMAIL_BUTTON" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemSocialButton" type="radio" default="" label="K2_SOCIAL_BUTTON_LIKE_SHARETHIS_ADDTHIS_ETC" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideoAnchor" type="radio" default="" label="K2_ANCHOR_LINK_TO_VIDEO" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageGalleryAnchor" type="radio" default="" label="K2_ANCHOR_LINK_TO_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemCommentsAnchor" type="radio" default="" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_COMMENT_FORM" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRating" type="radio" default="" label="K2_RATING_VOTING" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImage" type="radio" default="" label="K2_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImgSize" type="radio" default="" label="K2_IMAGE_SIZE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</param>
<param name="itemImageMainCaption" type="radio" default="" label="K2_IMAGE_CAPTION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageMainCredits" type="radio" default="" label="K2_IMAGE_CREDITS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemIntroText" type="radio" default="" label="K2_INTROTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFullText" type="radio" default="" label="K2_FULLTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemExtraFields" type="radio" default="" label="K2_EXTRA_FIELDS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemDateModified" type="radio" default="" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemHits" type="radio" default="" label="K2_HITS_PAGE_VIEWS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemCategory" type="radio" default="" label="K2_CATEGORY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemTags" type="radio" default="" label="K2_TAGS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAttachments" type="radio" default="" label="K2_ATTACHMENTS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAttachmentsCounter" type="radio" default="" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideo" type="radio" default="" label="K2_MEDIA" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<param name="itemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<param name="itemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<param name="itemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<param name="itemVideoAutoPlay" type="radio" default="" label="K2_MEDIA_AUTOPLAY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="itemVideoCaption" type="radio" default="" label="K2_MEDIA_CAPTION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemVideoCredits" type="radio" default="" label="K2_MEDIA_CREDITS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageGallery" type="radio" default="" label="K2_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<param name="itemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<param name="itemNavigation" type="radio" default="" label="K2_ITEM_NAVIGATION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemComments" type="radio" default="" label="K2_COMMENTS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_SOCIAL_SHARING" label="" description=""/>
<param name="itemTwitterButton" type="radio" default="" label="K2_TWITTER_SHARE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemFacebookButton" type="radio" default="" label="K2_FACEBOOK_SHARE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemGooglePlusOneButton" type="radio" default="" label="K2_GOOGLEPLUSONE_SHARE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_AUTHOR_OPTIONS" label="" description=""/>
<param name="itemAuthorBlock" type="radio" default="" label="K2_DISPLAY_EXTENDED_AUTHOR_INFO" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorImage" type="radio" default="" label="K2_AUTHOR_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorDescription" type="radio" default="" label="K2_AUTHOR_DESCRIPTION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorURL" type="radio" default="" label="K2_AUTHOR_URL" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorEmail" type="radio" default="" label="K2_AUTHOR_EMAIL" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorLatest" type="radio" default="" label="K2_LATEST_ITEMS_FROM_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemAuthorLatestLimit" type="text" default="" size="4" label="K2_LIMIT_FOR_LATEST_ITEMS_FROM_AUTHOR" description="K2_LEAVE_BLANK_TO_INHERIT_FROM_CATEGORY"/>
<param name="" type="header" default="K2_RELATED_ITEMS" label="" description=""/>
<param name="itemRelated" type="radio" default="" label="K2_RELATED_ITEMS_BY_TAG" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedLimit" type="text" default="" size="4" label="K2_RELATED_ITEMS_LIMIT" description=""/>
<param name="itemRelatedTitle" type="radio" default="" label="K2_RELATED_ITEMS_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedCategory" type="radio" default="" label="K2_RELATED_ITEMS_CATEGORY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedImageSize" type="radio" default="" label="K2_RELATED_ITEMS_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NONE_SELECTED</option>
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</param>
<param name="itemRelatedIntrotext" type="radio" default="" label="K2_RELATED_ITEMS_INTROTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedFulltext" type="radio" default="" label="K2_RELATED_ITEMS_FULLTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedAuthor" type="radio" default="" label="K2_RELATED_ITEMS_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedMedia" type="radio" default="" label="K2_RELATED_ITEMS_MEDIA" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="itemRelatedImageGallery" type="radio" default="" label="K2_RELATED_ITEMS_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</param>
<param name="" type="header" default="K2_ADVANCED" label="" description=""/>
<param name="itemK2Plugins" type="radio" default="" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
</params>
<fields name="params">
<fieldset name="item-view-options-listings" addfieldpath="/administrator/components/com_k2/elements">
<field name="catItemTitle" type="radio" default="" label="K2_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemTitleLinked" type="radio" default="" label="K2_LINK_ON_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemFeaturedNotice" type="radio" default="" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemAuthor" type="radio" default="" label="K2_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemDateCreated" type="radio" default="" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemRating" type="radio" default="" label="K2_RATING_VOTING" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemImage" type="radio" default="" label="K2_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemIntroText" type="radio" default="" label="K2_INTROTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemExtraFields" type="radio" default="" label="K2_EXTRA_FIELDS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemHits" type="radio" default="" label="K2_HITS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemCategory" type="radio" default="" label="K2_CATEGORY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemTags" type="radio" default="" label="K2_TAGS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemAttachments" type="radio" default="" label="K2_ATTACHMENTS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemAttachmentsCounter" type="radio" default="" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemVideo" type="radio" default="" label="K2_MEDIA" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<field name="catItemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<field name="catItemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<field name="catItemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<field name="catItemVideoAutoPlay" type="radio" default="" label="K2_MEDIA_AUTOPLAY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="catItemImageGallery" type="radio" default="" label="K2_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<field name="catItemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<field name="catItemDateModified" type="radio" default="" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemReadMore" type="radio" default="" label="K2_READ_MORE_LINK" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="catItemCommentsAnchor" type="radio" default="" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_ITEMS_COMMENT_FORM" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_ADVANCED" label="" description=""/>
<field name="catItemK2Plugins" type="radio" default="" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
</fieldset>
<fieldset name="item-view-options" addfieldpath="/administrator/components/com_k2/elements">
<field name="itemDateCreated" type="radio" default="" label="K2_ITEM_CREATED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemTitle" type="radio" default="" label="K2_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFeaturedNotice" type="radio" default="" label="K2_FEATURED_NOTICE_NEXT_TO_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthor" type="radio" default="" label="K2_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFontResizer" type="radio" default="" label="K2_FONT_RESIZER" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemPrintButton" type="radio" default="" label="K2_PRINT_BUTTON" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemEmailButton" type="radio" default="" label="K2_EMAIL_BUTTON" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemSocialButton" type="radio" default="" label="K2_SOCIAL_BUTTON_LIKE_SHARETHIS_ADDTHIS_ETC" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideoAnchor" type="radio" default="" label="K2_ANCHOR_LINK_TO_VIDEO" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageGalleryAnchor" type="radio" default="" label="K2_ANCHOR_LINK_TO_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemCommentsAnchor" type="radio" default="" label="K2_ANCHOR_LINK_WITH_COMMENTS_COUNTER_TO_COMMENT_FORM" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRating" type="radio" default="" label="K2_RATING_VOTING" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImage" type="radio" default="" label="K2_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImgSize" type="list" default="" label="K2_IMAGE_SIZE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</field>
<field name="itemImageMainCaption" type="radio" default="" label="K2_IMAGE_CAPTION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageMainCredits" type="radio" default="" label="K2_IMAGE_CREDITS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemIntroText" type="radio" default="" label="K2_INTROTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFullText" type="radio" default="" label="K2_FULLTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemExtraFields" type="radio" default="" label="K2_EXTRA_FIELDS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemDateModified" type="radio" default="" label="K2_ITEM_MODIFIED_DATE_AND_TIME" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemHits" type="radio" default="" label="K2_HITS_PAGE_VIEWS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemCategory" type="radio" default="" label="K2_CATEGORY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemTags" type="radio" default="" label="K2_TAGS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAttachments" type="radio" default="" label="K2_ATTACHMENTS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAttachmentsCounter" type="radio" default="" label="K2_ATTACHMENTS_COUNTER" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideo" type="radio" default="" label="K2_MEDIA" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideoWidth" type="text" default="" size="4" label="K2_VIDEO_WIDTH" description=""/>
<field name="itemVideoHeight" type="text" default="" size="4" label="K2_VIDEO_HEIGHT" description=""/>
<field name="itemAudioWidth" type="text" default="" size="4" label="K2_AUDIO_WIDTH" description=""/>
<field name="itemAudioHeight" type="text" default="" size="4" label="K2_AUDIO_HEIGHT" description=""/>
<field name="itemVideoAutoPlay" type="radio" default="" label="K2_MEDIA_AUTOPLAY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="itemVideoCaption" type="radio" default="" label="K2_MEDIA_CAPTION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemVideoCredits" type="radio" default="" label="K2_MEDIA_CREDITS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageGallery" type="radio" default="" label="K2_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemImageGalleryWidth" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_WIDTH" description=""/>
<field name="itemImageGalleryHeight" type="text" default="" size="4" label="K2_IMAGE_GALLERY_THUMBNAIL_HEIGHT" description=""/>
<field name="itemNavigation" type="radio" default="" label="K2_ITEM_NAVIGATION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemComments" type="radio" default="" label="K2_COMMENTS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_SOCIAL_SHARING" label="" description=""/>
<field name="itemTwitterButton" type="radio" default="" label="K2_TWITTER_SHARE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemFacebookButton" type="radio" default="" label="K2_FACEBOOK_SHARE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemGooglePlusOneButton" type="radio" default="" label="K2_GOOGLEPLUSONE_SHARE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_AUTHOR_OPTIONS" label="" description=""/>
<field name="itemAuthorBlock" type="radio" default="" label="K2_DISPLAY_EXTENDED_AUTHOR_INFO" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorImage" type="radio" default="" label="K2_AUTHOR_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorDescription" type="radio" default="" label="K2_AUTHOR_DESCRIPTION" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorURL" type="radio" default="" label="K2_AUTHOR_URL" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorEmail" type="radio" default="" label="K2_AUTHOR_EMAIL" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorLatest" type="radio" default="" label="K2_LATEST_ITEMS_FROM_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemAuthorLatestLimit" type="text" default="" size="4" label="K2_LIMIT_FOR_LATEST_ITEMS_FROM_AUTHOR" description="K2_LEAVE_BLANK_TO_INHERIT_FROM_CATEGORY"/>
<field name="" type="header" default="K2_RELATED_ITEMS" label="" description=""/>
<field name="itemRelated" type="radio" default="" label="K2_RELATED_ITEMS_BY_TAG" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedLimit" type="text" default="" size="4" label="K2_RELATED_ITEMS_LIMIT" description=""/>
<field name="itemRelatedTitle" type="radio" default="" label="K2_RELATED_ITEMS_TITLE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedCategory" type="radio" default="" label="K2_RELATED_ITEMS_CATEGORY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedImageSize" type="list" default="" label="K2_RELATED_ITEMS_IMAGE" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NONE_SELECTED</option>
<option value="XSmall">K2_XSMALL</option>
<option value="Small">K2_SMALL</option>
<option value="Medium">K2_MEDIUM</option>
<option value="Large">K2_LARGE</option>
<option value="XLarge">K2_XLARGE</option>
</field>
<field name="itemRelatedIntrotext" type="radio" default="" label="K2_RELATED_ITEMS_INTROTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedFulltext" type="radio" default="" label="K2_RELATED_ITEMS_FULLTEXT" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedAuthor" type="radio" default="" label="K2_RELATED_ITEMS_AUTHOR" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedMedia" type="radio" default="" label="K2_RELATED_ITEMS_MEDIA" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="itemRelatedImageGallery" type="radio" default="" label="K2_RELATED_ITEMS_IMAGE_GALLERY" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_HIDE</option>
<option value="1">K2_SHOW</option>
</field>
<field name="" type="header" default="K2_ADVANCED" label="" description=""/>
<field name="itemK2Plugins" type="radio" default="" label="K2_ENABLE_K2_PLUGINS" description="">
<option value="">K2_INHERIT_FROM_CATEGORY</option>
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
</fieldset>
</fields>
</form>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,37 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
if (version_compare(JVERSION, '2.5', 'ge'))
{
class K2Model extends JModelLegacy
{
public static function addIncludePath($path = '', $prefix = 'K2Model')
{
return parent::addIncludePath($path, $prefix);
}
}
}
else
{
class K2Model extends JModel
{
public function addIncludePath($path = '', $prefix = 'K2Model')
{
return parent::addIncludePath($path);
}
}
}

View File

@ -0,0 +1,50 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
class K2ModelSettings extends K2Model
{
function save()
{
$application = JFactory::getApplication();
$component = JTable::getInstance('component');
$component->loadByOption('com_k2');
$post = JRequest::get('post');
$component->bind($post);
if (!$component->check())
{
$application->enqueueMessage($component->getError(), 'error');
return false;
}
if (!$component->store())
{
$application->enqueueMessage($component->getError(), 'error');
return false;
}
return true;
}
function & getParams()
{
static $instance;
if ($instance == null)
{
$component = JTable::getInstance('component');
$component->loadByOption('com_k2');
$instance = new JParameter($component->params, JPATH_ADMINISTRATOR.'/components/com_k2/config.xml');
}
return $instance;
}
}

View File

@ -0,0 +1,157 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelTag extends K2Model
{
function getData()
{
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2Tag', 'Table');
$row->load($cid);
return $row;
}
function save()
{
$application = JFactory::getApplication();
$row = JTable::getInstance('K2Tag', 'Table');
if (!$row->bind(JRequest::get('post')))
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=tags');
}
if (!$row->check())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=tag&cid='.$row->id);
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=tags');
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
switch(JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_TAG_SAVED');
$link = 'index.php?option=com_k2&view=tag&cid='.$row->id;
break;
case 'save' :
default :
$msg = JText::_('K2_TAG_SAVED');
$link = 'index.php?option=com_k2&view=tags';
break;
}
$application->enqueueMessage($msg);
$application->redirect($link);
}
function addTag()
{
$application = JFactory::getApplication();
$user = JFactory::getUser();
$params = JComponentHelper::getParams('com_k2');
if ($user->gid < 24 && $params->get('lockTags'))
JError::raiseError(403, JText::_('K2_ALERTNOTAUTH'));
$tag = JRequest::getString('tag');
$tag = str_replace('-', '', $tag);
$tag = str_replace('.', '', $tag);
$response = new JObject;
$response->set('name', $tag);
if (empty($tag))
{
$response->set('msg', JText::_('K2_YOU_NEED_TO_ENTER_A_TAG', true));
echo json_encode($response);
$application->close();
}
$db = JFactory::getDbo();
$query = "SELECT COUNT(*) FROM #__k2_tags WHERE name=".$db->Quote($tag);
$db->setQuery($query);
$result = $db->loadResult();
if ($result > 0)
{
$response->set('msg', JText::_('K2_TAG_ALREADY_EXISTS', true));
echo json_encode($response);
$application->close();
}
$row = JTable::getInstance('K2Tag', 'Table');
$row->name = $tag;
$row->published = 1;
$row->store();
$cache = JFactory::getCache('com_k2');
$cache->clean();
$response->set('id', $row->id);
$response->set('status', 'success');
$response->set('msg', JText::_('K2_TAG_ADDED_TO_AVAILABLE_TAGS_LIST', true));
echo json_encode($response);
$application->close();
}
function tags()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$word = JRequest::getString('q', null);
$id = JRequest::getInt('id');
if (K2_JVERSION == '15')
{
$word = $db->Quote($db->getEscaped($word, true).'%', false);
}
else
{
$word = $db->Quote($db->escape($word, true).'%', false);
}
if($id)
{
$query = "SELECT id,name FROM #__k2_tags WHERE name LIKE ".$word;
$db->setQuery($query);
$result = $db->loadObjectList();
}
else
{
$query = "SELECT name FROM #__k2_tags WHERE name LIKE ".$word;
$db->setQuery($query);
$result = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
}
echo json_encode($result);
$application->close();
}
}

View File

@ -0,0 +1,180 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelTags extends K2Model
{
function getData()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', 'id', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', 'DESC', 'word');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', -1, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\-_]/u', '', $search));
$query = "SELECT #__k2_tags.*, (SELECT COUNT(*) FROM #__k2_tags_xref WHERE #__k2_tags_xref.tagID = #__k2_tags.id) AS numOfItems FROM #__k2_tags";
$conditions = array();
if ($filter_state > -1)
{
$conditions[] = "published={$filter_state}";
}
if ($search)
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$conditions[] = "LOWER( name ) LIKE ".$db->Quote('%'.$escaped.'%', false);
}
if (count($conditions))
{
$query .= " WHERE ".implode(' AND ', $conditions);
}
if (!$filter_order)
{
$filter_order = "name";
}
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}";
$db->setQuery($query, $limitstart, $limit);
$rows = $db->loadObjectList();
return $rows;
}
function getTotal()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', 1, 'int');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\-_]/u', '', $search));
$query = "SELECT COUNT(*) FROM #__k2_tags WHERE id>0";
if ($filter_state > -1)
{
$query .= " AND published={$filter_state}";
}
if ($search)
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$query .= " AND LOWER( name ) LIKE ".$db->Quote('%'.$escaped.'%', false);
}
$db->setQuery($query);
$total = $db->loadresult();
return $total;
}
function publish()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Tag', 'Table');
$row->load($id);
$row->published = 1;
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=tags&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=tags');
}
}
function unpublish()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Tag', 'Table');
$row->load($id);
$row->published = 0;
$row->store();
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=tags&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=tags');
}
}
function remove()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2Tag', 'Table');
$row->load($id);
$row->delete($id);
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=tags');
}
function getFilter()
{
$db = JFactory::getDbo();
$query = "SELECT name, id FROM #__k2_tags ORDER BY name";
$db->setQuery($query);
$rows = $db->loadObjectList();
return $rows;
}
function countTagItems($id)
{
$db = JFactory::getDbo();
$query = "SELECT COUNT(*) FROM #__k2_tags_xref WHERE tagID = ".(int)$id;
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
function removeOrphans()
{
$db = JFactory::getDbo();
$db->setQuery("DELETE FROM #__k2_tags WHERE id NOT IN (SELECT DISTINCT tagID FROM #__k2_tags_xref)");
$db->query();
$application = JFactory::getApplication();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=tags');
}
}

View File

@ -0,0 +1,199 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelUser extends K2Model
{
function getData()
{
$cid = JRequest::getInt('cid');
$db = JFactory::getDbo();
$query = "SELECT * FROM #__k2_users WHERE userID = ".$cid;
$db->setQuery($query);
$row = $db->loadObject();
if (!$row)
{
$row = JTable::getInstance('K2User', 'Table');
}
return $row;
}
function save()
{
$application = JFactory::getApplication();
jimport('joomla.filesystem.file');
require_once(JPATH_SITE.'/media/k2/assets/vendors/verot/class.upload.php/src/class.upload.php');
$row = JTable::getInstance('K2User', 'Table');
$params = JComponentHelper::getParams('com_k2');
if (!$row->bind(JRequest::get('post')))
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=users');
}
$row->description = JRequest::getVar('description', '', 'post', 'string', 2);
if ($params->get('xssFiltering'))
{
$filter = new JFilterInput( array(), array(), 1, 1, 0);
$row->description = $filter->clean($row->description);
}
$jUser = JFactory::getUser($row->userID);
$row->userName = $jUser->name;
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=users');
}
// Image
if ((int)$params->get('imageMemoryLimit'))
{
ini_set('memory_limit', (int)$params->get('imageMemoryLimit').'M');
}
$file = JRequest::get('files');
$savepath = JPATH_ROOT.'/media/k2/users/';
if ($file['image']['error'] == 0 && !JRequest::getBool('del_image'))
{
$handle = new Upload($file['image']);
if ($handle->uploaded)
{
$handle->file_auto_rename = false;
$handle->file_overwrite = true;
$handle->file_new_name_body = $row->id;
$handle->image_resize = true;
$handle->image_ratio_y = true;
$handle->image_x = $params->get('userImageWidth', '100');
$handle->Process($savepath);
$handle->Clean();
}
else
{
$application->enqueueMessage($handle->error, 'error');
$application->redirect('index.php?option=com_k2&view=users');
}
$row->image = $handle->file_dst_name;
}
if (JRequest::getBool('del_image'))
{
$current = JTable::getInstance('K2User', 'Table');
$current->load($row->id);
if (JFile::exists(JPATH_ROOT.'/media/k2/users/'.$current->image))
{
JFile::delete(JPATH_ROOT.'/media/k2/users/'.$current->image);
}
$row->image = '';
}
if (!$row->check())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=user&cid='.$row->id);
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=users');
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
switch(JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_USER_SAVED');
$link = 'index.php?option=com_k2&view=user&cid='.$row->userID;
break;
case 'save' :
default :
$msg = JText::_('K2_USER_SAVED');
$link = 'index.php?option=com_k2&view=users';
break;
}
$application->enqueueMessage($msg);
$application->redirect($link);
}
function getUserGroups()
{
$db = JFactory::getDbo();
$query = "SELECT * FROM #__k2_user_groups";
$db->setQuery($query);
$rows = $db->loadObjectList();
return $rows;
}
function reportSpammer()
{
$application = JFactory::getApplication();
$params = JComponentHelper::getParams('com_k2');
$id = (int)$this->getState('id');
if (!$id)
{
return false;
}
$user = JFactory::getUser();
if ($user->id == $id)
{
$application->enqueueMessage(JText::_('K2_YOU_CANNOT_REPORT_YOURSELF'), 'error');
return false;
}
$db = JFactory::getDbo();
// Unpublish user comments
$db->setQuery("UPDATE #__k2_comments SET published = 0 WHERE userID = ".$id);
$db->query();
$application->enqueueMessage(JText::_('K2_USER_COMMENTS_UNPUBLISHED'));
// Unpublish user items
$db->setQuery("UPDATE #__k2_items SET published = 0 WHERE created_by = ".$id);
$db->query();
$application->enqueueMessage(JText::_('K2_USER_ITEMS_UNPUBLISHED'));
// Report the user to stopforumspam.com
// We need the IP for this, so the user has to be a registered K2 user
$spammer = JFactory::getUser($id);
$db->setQuery("SELECT ip FROM #__k2_users WHERE userID=".$id, 0, 1);
$ip = $db->loadResult();
$stopForumSpamApiKey = trim($params->get('stopForumSpamApiKey'));
if ($ip && function_exists('fsockopen') && $stopForumSpamApiKey)
{
$data = "username=".$spammer->username."&ip_addr=".$ip."&email=".$spammer->email."&api_key=".$stopForumSpamApiKey;
$fp = fsockopen("www.stopforumspam.com", 80);
fputs($fp, "POST /add.php HTTP/1.1\n");
fputs($fp, "Host: www.stopforumspam.com\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\n");
fputs($fp, "Content-length: ".strlen($data)."\n");
fputs($fp, "Connection: close\n\n");
fputs($fp, $data);
fclose($fp);
$application->enqueueMessage(JText::_('K2_USER_DATA_SUBMITTED_TO_STOPFORUMSPAM'));
}
// Finally block the user
$db->setQuery("UPDATE #__users SET block = 1 WHERE id=".$id);
$db->query();
$application->enqueueMessage(JText::_('K2_USER_BLOCKED'));
return true;
}
}

View File

@ -0,0 +1,70 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelUserGroup extends K2Model
{
function getData()
{
$cid = JRequest::getVar('cid');
$row = JTable::getInstance('K2UserGroup', 'Table');
$row->load($cid);
return $row;
}
function save()
{
$application = JFactory::getApplication();
$row = JTable::getInstance('K2UserGroup', 'Table');
if (!$row->bind(JRequest::get('post')))
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=usergroups');
}
if (!$row->check())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=usergroup&cid='.$row->id);
}
if (!$row->store())
{
$application->enqueueMessage($row->getError(), 'error');
$application->redirect('index.php?option=com_k2&view=usergroups');
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
switch(JRequest::getCmd('task'))
{
case 'apply' :
$msg = JText::_('K2_CHANGES_TO_USER_GROUP_SAVED');
$link = 'index.php?option=com_k2&view=usergroup&cid='.$row->id;
break;
case 'save' :
default :
$msg = JText::_('K2_USER_GROUP_SAVED');
$link = 'index.php?option=com_k2&view=usergroups';
break;
}
$application->enqueueMessage($msg);
$application->redirect($link);
}
}

View File

@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<form>
<name>K2_USER_GROUP_EDIT_FORM</name>
<params addpath="/administrator/components/com_k2/elements">
<param name="comment" type="radio" default="1" label="K2_POST_COMMENTS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="frontEdit" type="radio" default="0" label="K2_FRONTEND_ITEM_EDITING" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="add" type="radio" default="0" label="K2_ADD_ITEMS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="editOwn" type="radio" default="0" label="K2_EDIT_OWN_ITEMS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="editAll" type="radio" default="0" label="K2_EDIT_ANY_ITEM" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="publish" type="radio" default="0" label="K2_PUBLISH_ITEMS" description="K2_PERMISSION_TO_PUBLISH_NEW_OR_EDITED_ITEMS">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
<param name="editPublished" type="radio" default="0" label="K2_ALLOW_EDITING_OF_ALREADY_PUBLISHED_ITEMS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</param>
</params>
<fields name="params">
<fieldset name="user-permissions" addfieldpath="/administrator/components/com_k2/elements">
<field name="comment" type="radio" default="1" label="K2_POST_COMMENTS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="frontEdit" type="radio" default="0" label="K2_FRONTEND_ITEM_EDITING" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="add" type="radio" default="0" label="K2_ADD_ITEMS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="editOwn" type="radio" default="0" label="K2_EDIT_OWN_ITEMS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="editAll" type="radio" default="0" label="K2_EDIT_ANY_ITEM" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="publish" type="radio" default="0" label="K2_PUBLISH_ITEMS" description="K2_PERMISSION_TO_PUBLISH_NEW_OR_EDITED_ITEMS">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
<field name="editPublished" type="radio" default="0" label="K2_ALLOW_EDITING_OF_ALREADY_PUBLISHED_ITEMS" description="">
<option value="0">K2_NO</option>
<option value="1">K2_YES</option>
</field>
</fieldset>
</fields>
</form>

View File

@ -0,0 +1,79 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelUserGroups extends K2Model
{
function getData()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', '', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', '', 'word');
$query = "SELECT userGroup.*, (SELECT COUNT(DISTINCT userID) FROM #__k2_users WHERE `group`=userGroup.id) AS numOfUsers FROM #__k2_user_groups AS userGroup";
if (!$filter_order)
{
$filter_order = "name";
}
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}";
$db->setQuery($query, $limitstart, $limit);
$rows = $db->loadObjectList();
return $rows;
}
function getTotal()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$query = "SELECT COUNT(*) FROM #__k2_user_groups";
$db->setQuery($query);
$total = $db->loadresult();
return $total;
}
function remove()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
foreach ($cid as $id)
{
$row = JTable::getInstance('K2UserGroup', 'Table');
$row->load($id);
$row->delete($id);
}
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=usergroups');
}
}

View File

@ -0,0 +1,570 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.model');
JTable::addIncludePath(JPATH_COMPONENT.'/tables');
class K2ModelUsers extends K2Model
{
function getData()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', 'juser.name', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_status = $application->getUserStateFromRequest($option.$view.'filter_status', 'filter_status', -1, 'int');
$filter_group = $application->getUserStateFromRequest($option.$view.'filter_group', 'filter_group', '', 'string');
$filter_group_k2 = $application->getUserStateFromRequest($option.$view.'filter_group_k2', 'filter_group_k2', '', 'string');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\-_]/u', '', $search));
$query = "SELECT juser.*, k2user.group, k2group.name as groupname FROM #__users as juser "."LEFT JOIN #__k2_users as k2user ON juser.id=k2user.userID "."LEFT JOIN #__k2_user_groups as k2group ON k2user.group=k2group.id ";
if (K2_JVERSION != '15' && $filter_group)
{
$query .= " LEFT JOIN #__user_usergroup_map as `map` ON juser.id=map.user_id ";
}
$query .= " WHERE juser.id>0";
if ($filter_status > -1)
{
$query .= " AND juser.block = {$filter_status}";
}
if ($filter_group)
{
if (K2_JVERSION != '15')
{
$query .= " AND `map`.group_id =".(int)$filter_group;
}
else
{
switch($filter_group)
{
case 'Public Frontend' :
$query .= " AND juser.usertype IN ('Registered', 'Author', 'Editor', 'Publisher')";
break;
case 'Public Backend' :
$query .= " AND juser.usertype IN ('Manager', 'Administrator', 'Super Administrator')";
break;
default :
$filter_group = strtolower(trim($filter_group));
$query .= " AND juser.usertype = ".$db->Quote($filter_group);
}
}
}
if ($filter_group_k2)
{
$query .= " AND k2user.group = ".$db->Quote($filter_group_k2);
}
if ($search)
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$query .= " AND (LOWER( juser.name ) LIKE ".$db->Quote('%'.$escaped.'%', false)." OR LOWER( juser.email ) LIKE ".$db->Quote('%'.$escaped.'%', false).")";
}
if (!$filter_order)
{
$filter_order = "juser.name";
}
$query .= " ORDER BY {$filter_order} {$filter_order_Dir}";
$db->setQuery($query, $limitstart, $limit);
$rows = $db->loadObjectList();
if (K2_JVERSION != '15' && count($rows))
{
foreach ($rows as $row)
{
$IDs[] = $row->id;
}
$query = "SELECT map.user_id, COUNT(map.group_id) AS group_count,GROUP_CONCAT(g2.title SEPARATOR '\n') AS group_names
FROM #__user_usergroup_map AS map
LEFT JOIN #__usergroups AS g2
ON g2.id = map.group_id
WHERE map.user_id IN (".implode(',', $IDs).")
GROUP BY map.user_id";
$db->setQuery($query);
$groups = $db->loadObjectList();
foreach ($rows as $row)
{
foreach ($groups as $group)
{
if ($row->id == $group->user_id)
{
$row->usertype = nl2br($group->group_names);
}
}
}
}
return $rows;
}
function getTotal()
{
$application = JFactory::getApplication();
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$db = JFactory::getDbo();
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0, 'int');
$filter_status = $application->getUserStateFromRequest($option.$view.'filter_status', 'filter_status', -1, 'int');
$filter_group = $application->getUserStateFromRequest($option.$view.'filter_group', 'filter_group', '', 'string');
$filter_group_k2 = $application->getUserStateFromRequest($option.$view.'filter_group_k2', 'filter_group_k2', '', 'string');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\-_]/u', '', $search));
$query = "SELECT COUNT(DISTINCT juser.id) FROM #__users as juser "."LEFT JOIN #__k2_users as k2user ON juser.id=k2user.userID "."LEFT JOIN #__k2_user_groups as k2group ON k2user.group=k2group.id ";
if (K2_JVERSION != '15' && $filter_group)
{
$query .= " LEFT JOIN #__user_usergroup_map as `map` ON juser.id=map.user_id ";
}
$query .= " WHERE juser.id>0";
if ($filter_status > -1)
{
$query .= " AND juser.block = {$filter_status}";
}
if ($filter_group)
{
if (K2_JVERSION != '15')
{
$query .= " AND `map`.group_id =".(int)$filter_group;
}
else
{
switch($filter_group)
{
case 'Public Frontend' :
$query .= " AND juser.usertype IN ('Registered', 'Author', 'Editor', 'Publisher')";
break;
case 'Public Backend' :
$query .= " AND juser.usertype IN ('Manager', 'Administrator', 'Super Administrator')";
break;
default :
$filter_group = strtolower(trim($filter_group));
$query .= " AND juser.usertype = ".$db->Quote($filter_group);
}
}
}
if ($filter_group_k2)
{
$query .= " AND k2user.group = ".$db->Quote($filter_group_k2);
}
if ($search)
{
$escaped = K2_JVERSION == '15' ? $db->getEscaped($search, true) : $db->escape($search, true);
$query .= " AND (LOWER( juser.name ) LIKE ".$db->Quote('%'.$escaped.'%', false)." OR LOWER( juser.email ) LIKE ".$db->Quote('%'.$escaped.'%', false).")";
}
$db->setQuery($query);
$total = $db->loadResult();
return $total;
}
function remove()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
$db = JFactory::getDbo();
$query = "DELETE FROM #__k2_users WHERE userID IN(".implode(',', $cid).")";
$db->setQuery($query);
$db->query();
$cache = JFactory::getCache('com_k2');
$cache->clean();
$application->enqueueMessage(JText::_('K2_USER_PROFILE_DELETED'));
$application->redirect('index.php?option=com_k2&view=users');
}
function getUserGroups($type = 'joomla')
{
$db = JFactory::getDbo();
if ($type == 'joomla')
{
$query = 'SELECT (lft - 3) AS lft, name AS value, name AS text'.' FROM #__core_acl_aro_groups'.' WHERE name != "ROOT"'.' AND name != "USERS"'.' ORDER BY `lft` ASC';
if (K2_JVERSION != '15')
{
$query = "SELECT a.lft AS lft, a.id AS value, a.title AS text, COUNT(DISTINCT b.id) AS level
FROM #__usergroups AS a
LEFT JOIN #__usergroups AS b
ON a.lft > b.lft
AND a.rgt < b.rgt
GROUP BY a.id
ORDER BY a.lft ASC";
}
$db->setQuery($query);
$groups = $db->loadObjectList();
$userGroups = array();
foreach ($groups as $group)
{
if ($group->lft >= 10)
$group->lft = (int)$group->lft - 10;
if (K2_JVERSION != '15')
{
$group->text = $this->indent($group->level, '- ').$group->text;
}
else
{
$group->text = $this->indent($group->lft).$group->text;
}
array_push($userGroups, $group);
}
}
else
{
$query = "SELECT * FROM #__k2_user_groups";
$db->setQuery($query);
$userGroups = $db->loadObjectList();
}
return $userGroups;
}
function indent($times, $char = '&nbsp;&nbsp;&nbsp;&nbsp;', $start_char = '', $end_char = '')
{
$return = $start_char;
for ($i = 0; $i < $times; $i++)
$return .= $char;
$return .= $end_char;
return $return;
}
function checkLogin($id)
{
$db = JFactory::getDbo();
$query = "SELECT COUNT(s.userid) FROM #__session AS s WHERE s.userid = ".(int)$id;
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
function hasProfile($id)
{
$db = JFactory::getDbo();
$query = "SELECT id FROM #__k2_users WHERE userID = ".(int)$id;
$db->setQuery($query);
$result = $db->loadResult();
return $result;
}
function enable()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
$db = JFactory::getDbo();
$query = "UPDATE #__users SET block=0 WHERE id IN(".implode(',', $cid).")";
$db->setQuery($query);
$db->query();
$application->enqueueMessage(JText::_('K2_USERS_ENABLED'));
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=users&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=users');
}
}
function disable()
{
$application = JFactory::getApplication();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
$db = JFactory::getDbo();
$query = "UPDATE #__users SET block=1 WHERE id IN(".implode(',', $cid).")";
$db->setQuery($query);
$db->query();
$application->enqueueMessage(JText::_('K2_USERS_DISABLED'));
if(JRequest::getCmd('context') == "modalselector"){
$application->redirect('index.php?option=com_k2&view=users&tmpl=component&context=modalselector');
} else {
$application->redirect('index.php?option=com_k2&view=users');
}
}
function delete()
{
$application = JFactory::getApplication();
$user = JFactory::getUser();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
$db = JFactory::getDbo();
if (in_array($user->id, $cid))
{
foreach ($cid as $key => $id)
{
if ($id == $user->id)
{
unset($cid[$key]);
}
}
$application->enqueueMessage(JText::_('K2_YOU_CANNOT_DELETE_YOURSELF'), 'notice');
}
if (count($cid) < 1)
{
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=users');
}
if (K2_JVERSION != '15')
{
JPluginHelper::importPlugin('user');
$dispatcher = JDispatcher::getInstance();
$iAmSuperAdmin = $user->authorise('core.admin');
foreach ($cid as $key => $id)
{
$table = JTable::getInstance('user');
$table->load($id);
$allow = $user->authorise('core.delete', 'com_users');
// Don't allow non-super-admin to delete a super admin
$allow = (!$iAmSuperAdmin && JAccess::check($id, 'core.admin')) ? false : $allow;
if ($allow)
{
// Get users data for the users to delete.
$user_to_delete = JFactory::getUser($id);
// Fire the onUserBeforeDelete event.
$dispatcher->trigger('onUserBeforeDelete', array($table->getProperties()));
if (!$table->delete($id))
{
$this->setError($table->getError());
return false;
}
else
{
// Trigger the onUserAfterDelete event.
$dispatcher->trigger('onUserAfterDelete', array($user_to_delete->getProperties(), true, $this->getError()));
}
}
else
{
// Prune items that you can't change.
unset($cid[$key]);
JError::raiseWarning(403, JText::_('JERROR_CORE_DELETE_NOT_PERMITTED'));
}
}
$IDsToDelete = $cid;
}
else
{
$query = "SELECT * FROM #__users WHERE id IN(".implode(',', $cid).") AND gid<={$user->gid}";
$db->setQuery($query);
$IDsToDelete = K2_JVERSION == '30' ? $db->loadColumn() : $db->loadResultArray();
$query = "DELETE FROM #__users WHERE id IN(".implode(',', $IDsToDelete).") AND id!={$user->id}";
$db->setQuery($query);
$db->query();
}
$query = "DELETE FROM #__k2_users WHERE userID IN(".implode(',', $IDsToDelete).") AND userID!={$user->id}";
$db->setQuery($query);
$db->query();
$application->enqueueMessage(JText::_('K2_DELETE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=users');
}
function saveMove()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
$cid = JRequest::getVar('cid');
JArrayHelper::toInteger($cid);
$group = JRequest::getVar('group');
$k2group = JRequest::getInt('k2group');
if (K2_JVERSION != '15')
{
JArrayHelper::toInteger($group);
$group = array_filter($group);
if (count($group))
{
foreach ($cid as $id)
{
$query = "DELETE FROM #__user_usergroup_map WHERE user_id = ".$id;
$db->setQuery($query);
$db->query();
$query = "INSERT INTO #__user_usergroup_map VALUES (".$id.", ".implode("), (".$id.", ", $group).")";
$db->setQuery($query);
$db->query();
}
}
}
else
{
if ($group)
{
$query = "SELECT id FROM #__core_acl_aro_groups WHERE name=".$db->Quote($group);
$db->setQuery($query);
$gid = $db->loadResult();
$query = "UPDATE #__users SET gid={$gid}, usertype=".$db->Quote($group)." WHERE id IN(".implode(',', $cid).")";
$db->setQuery($query);
$db->query();
}
}
if ($k2group)
{
foreach ($cid as $id)
{
$query = "SELECT COUNT(*) FROM #__k2_users WHERE userID = ".$id;
$db->setQuery($query);
$result = $db->loadResult();
if ($result)
{
$query = "UPDATE #__k2_users SET `group`={$k2group} WHERE userID = ".$id;
}
else
{
$user = JFactory::getUser($id);
$query = "INSERT INTO #__k2_users VALUES ('', {$id}, {$db->Quote($user->username)}, '', '', '', '', {$k2group}, '', '', '', '')";
}
$db->setQuery($query);
$db->query();
}
}
$application->enqueueMessage(JText::_('K2_MOVE_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=users');
}
function import()
{
$application = JFactory::getApplication();
$db = JFactory::getDbo();
if (K2_JVERSION != '15')
{
$db->setQuery("SELECT id, title AS name FROM #__usergroups");
$usergroups = $db->loadObjectList();
$xml = new JXMLElement(JFile::read(JPATH_COMPONENT.'/models/usergroup.xml'));
$permissions = class_exists('JParameter') ? new JParameter('') : new JRegistry('');
foreach ($xml->params as $paramGroup)
{
foreach ($paramGroup->param as $param)
{
$attribute = K2_JVERSION == '30' ? $param->attributes()->type : $param->getAttribute('type');
if ($attribute != 'spacer')
{
if (K2_JVERSION == '30')
{
$permissions->set((string)$param->attributes()->name, (string)$param->attributes()->default);
}
else
{
$permissions->set($param->getAttribute('name'), $param->getAttribute('default'));
}
}
}
}
}
else
{
$acl = JFactory::getACL();
$frontEndGroups = $acl->_getBelow('#__core_acl_aro_groups', 'g1.id, g1.name, COUNT(g2.name) AS level', 'g1.name', false, 'Public Frontend', false);
$backEndGroups = $acl->_getBelow('#__core_acl_aro_groups', 'g1.id, g1.name, COUNT(g2.name) AS level', 'g1.name', false, 'Public Backend', false);
$usergroups = array_merge($frontEndGroups, $backEndGroups);
$xml = new JSimpleXML;
$xml->loadFile(JPATH_COMPONENT.'/models/usergroup.xml');
$permissions = class_exists('JParameter') ? new JParameter('') : new JRegistry('');
foreach ($xml->document->params as $paramGroup)
{
foreach ($paramGroup->param as $param)
{
if ($param->attributes('type') != 'spacer')
{
$permissions->set($param->attributes('name'), $param->attributes('default'));
}
}
}
}
$permissions->set('inheritance', 0);
$permissions->set('categories', 'all');
$permissions = $permissions->toString();
foreach ($usergroups as $usergroup)
{
$K2UserGroup = JTable::getInstance('K2UserGroup', 'Table');
$K2UserGroup->name = JString::trim($usergroup->name)." (Imported from Joomla)";
$K2UserGroup->permissions = $permissions;
$K2UserGroup->store();
if (K2_JVERSION != '15')
{
$query = "SELECT * FROM #__users AS user JOIN #__user_usergroup_map AS map ON user.id = map.user_id
WHERE map.group_id = ".$usergroup->id;
}
else
{
$query = "SELECT * FROM #__users WHERE gid={$usergroup->id}";
}
$db->setQuery($query);
$users = $db->loadObjectList();
foreach ($users as $user)
{
$query = "SELECT COUNT(*) FROM #__k2_users WHERE userID={$user->id}";
$db->setQuery($query);
$result = $db->loadResult();
if (!$result)
{
$K2User = JTable::getInstance('K2User', 'Table');
$K2User->userID = $user->id;
$K2User->group = $K2UserGroup->id;
$K2User->store();
}
}
}
$application->enqueueMessage(JText::_('K2_IMPORT_COMPLETED'));
$application->redirect('index.php?option=com_k2&view=users');
}
}

View File

@ -0,0 +1,452 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
class Com_K2InstallerScript
{
public function postflight($type, $parent)
{
$db = JFactory::getDbo();
$status = new stdClass;
$status->modules = array();
$status->plugins = array();
$src = $parent->getParent()->getPath('source');
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$path = $src.'/plugins/'.$group;
if (JFolder::exists($src.'/plugins/'.$group.'/'.$name))
{
$path = $src.'/plugins/'.$group.'/'.$name;
}
$installer = new JInstaller;
$result = $installer->install($path);
if ($result && $group != 'finder')
{
if (JFile::exists(JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.xml'))
{
JFile::delete(JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.xml');
}
JFile::move(JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.j25.xml', JPATH_SITE.'/plugins/'.$group.'/'.$name.'/'.$name.'.xml');
}
if($group != 'finder')
{
$query = "UPDATE #__extensions SET enabled=1 WHERE type='plugin' AND element=".$db->Quote($name)." AND folder=".$db->Quote($group);
$db->setQuery($query);
$db->query();
}
$status->plugins[] = array('name' => $name, 'group' => $group, 'result' => $result);
}
$modules = $manifest->xpath('modules/module');
foreach ($modules as $module)
{
$name = (string)$module->attributes()->module;
$client = (string)$module->attributes()->client;
if (is_null($client))
{
$client = 'site';
}
($client == 'administrator') ? $path = $src.'/administrator/modules/'.$name : $path = $src.'/modules/'.$name;
if($client == 'administrator')
{
$db->setQuery("SELECT id FROM #__modules WHERE `module` = ".$db->quote($name));
$isUpdate = (int)$db->loadResult();
}
$installer = new JInstaller;
$result = $installer->install($path);
if ($result)
{
$root = $client == 'administrator' ? JPATH_ADMINISTRATOR : JPATH_SITE;
if (JFile::exists($root.'/modules/'.$name.'/'.$name.'.xml'))
{
JFile::delete($root.'/modules/'.$name.'/'.$name.'.xml');
}
JFile::move($root.'/modules/'.$name.'/'.$name.'.j25.xml', $root.'/modules/'.$name.'/'.$name.'.xml');
}
$status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result);
if($client == 'administrator' && !$isUpdate)
{
$position = version_compare(JVERSION, '3.0', '<') && $name == 'mod_k2_quickicons'? 'icon' : 'cpanel';
$db->setQuery("UPDATE #__modules SET `position`=".$db->quote($position).",`published`='1' WHERE `module`=".$db->quote($name));
$db->query();
$db->setQuery("SELECT id FROM #__modules WHERE `module` = ".$db->quote($name));
$id = (int)$db->loadResult();
$db->setQuery("INSERT IGNORE INTO #__modules_menu (`moduleid`,`menuid`) VALUES (".$id.", 0)");
$db->query();
}
}
if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_k2/admin.k2.php'))
{
JFile::delete(JPATH_ADMINISTRATOR.'/components/com_k2/admin.k2.php');
}
if (JFile::exists(JPATH_ADMINISTRATOR.'/components/com_k2/models/cpanel.php'))
{
JFile::delete(JPATH_ADMINISTRATOR.'/components/com_k2/models/cpanel.php');
}
if (version_compare(JVERSION, '3.0', 'lt') && JFolder::exists(JPATH_ADMINISTRATOR.'/components/com_joomfish/contentelements'))
{
$elements = $manifest->xpath('joomfish/file');
foreach ($elements as $element)
{
JFile::copy($src.'/administrator/components/com_joomfish/contentelements/'.$element->data(), JPATH_ADMINISTRATOR.'/components/com_joomfish/contentelements/'.$element->data());
}
}
// Clean up empty entries in #__k2_users table caused by an issue in the K2 user plugin. Fix details: http://code.google.com/p/getk2/source/detail?r=1966
$query = "DELETE FROM #__k2_users WHERE userID = 0";
$db->setQuery($query);
$db->query();
/*
// TO DO: Check main folders for 0755 first and then apply this fix
// Fix media manager folder permissions
set_time_limit(0);
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.path');
$params = JComponentHelper::getParams('com_media');
$root = $params->get('file_path', 'media');
$mediaPath = JPATH_SITE.'/'.JPath::clean($root);
$folders = JFolder::folders($mediaPath, '.', true, true, array());
foreach($folders as $folder)
{
@chmod($folder, 0755);
}
if(JFolder::exists($mediaPath.'/'.'.tmb'))
{
@chmod($mediaPath.'/'.'.tmb', 0755);
}
if(JFolder::exists($mediaPath.'/'.'.quarantine'))
{
@chmod($mediaPath.'/'.'.quarantine', 0755);
}
*/
$this->installationResults($status);
}
public function uninstall($parent)
{
$db = JFactory::getDbo();
$status = new stdClass;
$status->modules = array();
$status->plugins = array();
$manifest = $parent->getParent()->manifest;
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin)
{
$name = (string)$plugin->attributes()->plugin;
$group = (string)$plugin->attributes()->group;
$query = "SELECT `extension_id` FROM #__extensions WHERE `type`='plugin' AND element = ".$db->Quote($name)." AND folder = ".$db->Quote($group);
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions))
{
foreach ($extensions as $id)
{
$installer = new JInstaller;
$result = $installer->uninstall('plugin', $id);
}
$status->plugins[] = array('name' => $name, 'group' => $group, 'result' => $result);
}
}
$modules = $manifest->xpath('modules/module');
foreach ($modules as $module)
{
$name = (string)$module->attributes()->module;
$client = (string)$module->attributes()->client;
$db = JFactory::getDbo();
$query = "SELECT `extension_id` FROM `#__extensions` WHERE `type`='module' AND element = ".$db->Quote($name)."";
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions))
{
foreach ($extensions as $id)
{
$installer = new JInstaller;
$result = $installer->uninstall('module', $id);
}
$status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result);
}
}
$this->uninstallationResults($status);
}
public function update($type)
{
$db = JFactory::getDbo();
$fields = $db->getTableColumns('#__k2_categories');
if (!array_key_exists('language', $fields))
{
$query = "ALTER TABLE #__k2_categories ADD `language` CHAR(7) NOT NULL";
$db->setQuery($query);
$db->query();
$query = "ALTER TABLE #__k2_categories ADD INDEX (`language`)";
$db->setQuery($query);
$db->query();
}
$fields = $db->getTableColumns('#__k2_items');
if (!array_key_exists('featured_ordering', $fields))
{
$query = "ALTER TABLE #__k2_items ADD `featured_ordering` INT(11) NOT NULL default '0' AFTER `featured`";
$db->setQuery($query);
$db->query();
}
if (!array_key_exists('language', $fields))
{
$query = "ALTER TABLE #__k2_items ADD `language` CHAR(7) NOT NULL";
$db->setQuery($query);
$db->query();
$query = "ALTER TABLE #__k2_items ADD INDEX (`language`)";
$db->setQuery($query);
$db->query();
}
if ($fields['video'] != 'text')
{
$query = "ALTER TABLE #__k2_items MODIFY `video` TEXT";
$db->setQuery($query);
$db->query();
}
if ($fields['introtext'] == 'text')
{
$query = "ALTER TABLE #__k2_items MODIFY `introtext` MEDIUMTEXT";
$db->setQuery($query);
$db->query();
}
if ($fields['fulltext'] == 'text')
{
$query = "ALTER TABLE #__k2_items MODIFY `fulltext` MEDIUMTEXT";
$db->setQuery($query);
$db->query();
}
/*
// TO DO: Use the following info to remove FULLTEXT attributes from the items & tags tables
$query = "SHOW INDEX FROM #__k2_items";
$db->setQuery($query);
$indexes = $db->loadObjectList();
$indexExists = false;
foreach ($indexes as $index)
{
if ($index->Key_name == 'search')
$indexExists = true;
}
if (!$indexExists)
{
$query = "ALTER TABLE #__k2_items ADD FULLTEXT `search` (`title`,`introtext`,`fulltext`,`extra_fields_search`,`image_caption`,`image_credits`,`video_caption`,`video_credits`,`metadesc`,`metakey`)";
$db->setQuery($query);
$db->query();
$query = "ALTER TABLE #__k2_items ADD FULLTEXT (`title`)";
$db->setQuery($query);
$db->query();
}
$query = "SHOW INDEX FROM #__k2_tags";
$db->setQuery($query);
$indexes = $db->loadObjectList();
$indexExists = false;
foreach ($indexes as $index)
{
if ($index->Key_name == 'name')
$indexExists = true;
}
if (!$indexExists)
{
$query = "ALTER TABLE #__k2_tags ADD FULLTEXT (`name`)";
$db->setQuery($query);
$db->query();
}
*/
// Add index for comments count
$query = "SHOW INDEX FROM #__k2_comments";
$db->setQuery($query);
$indexes = $db->loadObjectList();
$indexExists = false;
foreach ($indexes as $index)
{
if ($index->Key_name == 'countComments')
$indexExists = true;
}
if (!$indexExists)
{
$query = "ALTER TABLE #__k2_comments ADD INDEX `countComments` (`itemID`, `published`)";
$db->setQuery($query);
$db->query();
}
$query = "SELECT COUNT(*) FROM #__k2_user_groups";
$db->setQuery($query);
$num = $db->loadResult();
if ($num == 0)
{
$query = "INSERT INTO #__k2_user_groups (`id`, `name`, `permissions`) VALUES('', 'Registered', '{\"comment\":\"1\",\"frontEdit\":\"0\",\"add\":\"0\",\"editOwn\":\"0\",\"editAll\":\"0\",\"publish\":\"0\",\"inheritance\":0,\"categories\":\"all\"}')";
$db->setQuery($query);
$db->query();
$query = "INSERT INTO #__k2_user_groups (`id`, `name`, `permissions`) VALUES('', 'Site Owner', '{\"comment\":\"1\",\"frontEdit\":\"1\",\"add\":\"1\",\"editOwn\":\"1\",\"editAll\":\"1\",\"publish\":\"1\",\"inheritance\":1,\"categories\":\"all\"}')";
$db->setQuery($query);
$db->query();
}
$fields = $db->getTableColumns('#__k2_users');
if (!array_key_exists('ip', $fields))
{
$query = "ALTER TABLE `#__k2_users`
ADD `ip` VARCHAR( 15 ) NOT NULL ,
ADD `hostname` VARCHAR( 255 ) NOT NULL ,
ADD `notes` TEXT NOT NULL";
$db->setQuery($query);
$db->query();
}
$query = "CREATE TABLE IF NOT EXISTS `#__k2_log` (
`status` int(11) NOT NULL,
`response` text NOT NULL,
`timestamp` datetime NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
$db->setQuery($query);
$db->query();
}
private function installationResults($status)
{
$language = JFactory::getLanguage();
$language->load('com_k2');
$rows = 0; ?>
<img src="<?php echo JURI::root(true); ?>/media/k2/assets/images/backend/k2_logo_126x48.png" alt="K2" align="right" />
<h2><?php echo JText::_('K2_INSTALLATION_STATUS'); ?></h2>
<table class="adminlist table table-striped">
<thead>
<tr>
<th class="title" colspan="2"><?php echo JText::_('K2_EXTENSION'); ?></th>
<th width="30%"><?php echo JText::_('K2_STATUS'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"></td>
</tr>
</tfoot>
<tbody>
<tr class="row0">
<td class="key" colspan="2"><?php echo 'K2 '.JText::_('K2_COMPONENT'); ?></td>
<td><strong><?php echo JText::_('K2_INSTALLED'); ?></strong></td>
</tr>
<?php if (count($status->modules)): ?>
<tr>
<th><?php echo JText::_('K2_MODULE'); ?></th>
<th><?php echo JText::_('K2_CLIENT'); ?></th>
<th></th>
</tr>
<?php foreach ($status->modules as $module): ?>
<tr class="row<?php echo(++$rows % 2); ?>">
<td class="key"><?php echo $module['name']; ?></td>
<td class="key"><?php echo ucfirst($module['client']); ?></td>
<td><strong><?php echo ($module['result'])?JText::_('K2_INSTALLED'):JText::_('K2_NOT_INSTALLED'); ?></strong></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php if (count($status->plugins)): ?>
<tr>
<th><?php echo JText::_('K2_PLUGIN'); ?></th>
<th><?php echo JText::_('K2_GROUP'); ?></th>
<th></th>
</tr>
<?php foreach ($status->plugins as $plugin): ?>
<tr class="row<?php echo(++$rows % 2); ?>">
<td class="key"><?php echo ucfirst($plugin['name']); ?></td>
<td class="key"><?php echo ucfirst($plugin['group']); ?></td>
<td><strong><?php echo ($plugin['result'])?JText::_('K2_INSTALLED'):JText::_('K2_NOT_INSTALLED'); ?></strong></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php
}
private function uninstallationResults($status)
{
$language = JFactory::getLanguage();
$language->load('com_k2');
$rows = 0;
?>
<h2><?php echo JText::_('K2_REMOVAL_STATUS'); ?></h2>
<table class="adminlist table table-striped">
<thead>
<tr>
<th class="title" colspan="2"><?php echo JText::_('K2_EXTENSION'); ?></th>
<th width="30%"><?php echo JText::_('K2_STATUS'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"></td>
</tr>
</tfoot>
<tbody>
<tr class="row0">
<td class="key" colspan="2"><?php echo 'K2 '.JText::_('K2_COMPONENT'); ?></td>
<td><strong><?php echo JText::_('K2_REMOVED'); ?></strong></td>
</tr>
<?php if (count($status->modules)): ?>
<tr>
<th><?php echo JText::_('K2_MODULE'); ?></th>
<th><?php echo JText::_('K2_CLIENT'); ?></th>
<th></th>
</tr>
<?php foreach ($status->modules as $module): ?>
<tr class="row<?php echo(++$rows % 2); ?>">
<td class="key"><?php echo $module['name']; ?></td>
<td class="key"><?php echo ucfirst($module['client']); ?></td>
<td><strong><?php echo ($module['result'])?JText::_('K2_REMOVED'):JText::_('K2_NOT_REMOVED'); ?></strong></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
<?php if (count($status->plugins)): ?>
<tr>
<th><?php echo JText::_('K2_PLUGIN'); ?></th>
<th><?php echo JText::_('K2_GROUP'); ?></th>
<th></th>
</tr>
<?php foreach ($status->plugins as $plugin): ?>
<tr class="row<?php echo(++$rows % 2); ?>">
<td class="key"><?php echo ucfirst($plugin['name']); ?></td>
<td class="key"><?php echo ucfirst($plugin['group']); ?></td>
<td><strong><?php echo ($plugin['result'])?JText::_('K2_REMOVED'):JText::_('K2_NOT_REMOVED'); ?></strong></td>
</tr>
<?php endforeach; ?>
<?php endif; ?>
</tbody>
</table>
<?php
}
}

View File

@ -0,0 +1,30 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2Attachment extends K2Table
{
var $id = null;
var $itemID = null;
var $filename = null;
var $title = null;
var $titleAttribute = null;
var $hits = null;
function __construct(&$db)
{
parent::__construct('#__k2_attachments', 'id', $db);
}
}

View File

@ -0,0 +1,227 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2Category extends K2Table
{
var $id = null;
var $name = null;
var $alias = null;
var $description = null;
var $parent = null;
var $extraFieldsGroup = null;
var $published = null;
var $image = null;
var $access = null;
var $ordering = null;
var $params = null;
var $trash = null;
var $plugins = null;
var $language = null;
function __construct(&$db)
{
parent::__construct('#__k2_categories', 'id', $db);
}
function load($oid = null, $reset = false)
{
static $K2CategoriesInstances = array();
if (isset($K2CategoriesInstances[$oid]))
{
return $this->bind($K2CategoriesInstances[$oid]);
}
$k = $this->_tbl_key;
if ($oid !== null)
{
$this->$k = $oid;
}
$oid = $this->$k;
if ($oid === null)
{
return false;
}
$this->reset();
$db = $this->getDBO();
$query = 'SELECT *'.' FROM '.$this->_tbl.' WHERE '.$this->_tbl_key.' = '.$db->Quote($oid);
$db->setQuery($query);
$result = $db->loadAssoc();
if ($result)
{
$K2CategoriesInstances[$oid] = $result;
return $this->bind($K2CategoriesInstances[$oid]);
}
else
{
$this->setError($db->getErrorMsg());
return false;
}
}
function check()
{
jimport('joomla.filter.output');
$params = JComponentHelper::getParams('com_k2');
$this->name = JString::trim($this->name);
if ($this->name == '')
{
$this->setError(JText::_('K2_CATEGORY_MUST_HAVE_A_NAME'));
return false;
}
if (empty($this->alias))
{
$this->alias = $this->name;
}
if (K2_JVERSION == '15')
{
if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended'))
{
$this->alias = JFilterOutput::stringURLSafe($this->alias);
}
else
{
mb_internal_encoding("UTF-8");
mb_regex_encoding("UTF-8");
$this->alias = trim(mb_strtolower($this->alias));
$this->alias = str_replace('-', ' ', $this->alias);
$this->alias = str_replace('/', '-', $this->alias);
$this->alias = mb_ereg_replace('[[:space:]]+', ' ', $this->alias);
$this->alias = trim(str_replace(' ', '-', $this->alias));
$this->alias = str_replace('.', '', $this->alias);
$this->alias = str_replace('"', '', $this->alias);
$this->alias = str_replace("'", '', $this->alias);
$stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€<C3A2>|•|›|«|´|»|°|«|»|…';
$strips = explode('|', $stripthese);
foreach ($strips as $strip)
{
$this->alias = str_replace($strip, '', $this->alias);
}
if (trim(str_replace('-', '', $this->alias)) == '')
{
$datenow = JFactory::getDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
$this->alias = trim($this->alias, '-.');
}
}
else
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
$this->alias = JFilterOutput::stringURLUnicodeSlug($this->alias);
}
// Transliterate properly...
else
{
// Detect the site language we will transliterate
if ($this->language == '*')
{
$langParams = JComponentHelper::getParams('com_languages');
$languageTag = $langParams->get('site');
}
else
{
$languageTag = $this->language;
}
$language = JLanguage::getInstance($languageTag);
$this->alias = $language->transliterate($this->alias);
$this->alias = JFilterOutput::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
}
}
if (K2_JVERSION == '15' || $params->get('enforceSEFReplacements'))
{
$SEFReplacements = array();
$items = explode(',', $params->get('SEFReplacements'));
foreach ($items as $item)
{
if (!empty($item))
{
@list($src, $dst) = explode('|', trim($item));
$SEFReplacements[trim($src)] = trim($dst);
}
}
foreach ($SEFReplacements as $key => $value)
{
$this->alias = str_replace($key, $value, $this->alias);
}
$this->alias = trim($this->alias, '-.');
}
if (K2_JVERSION == '15')
{
if (trim(str_replace('-', '', $this->alias)) == '')
{
$datenow = JFactory::getDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
}
// Check if alias already exists. If so warn the user
$params = JComponentHelper::getParams('com_k2');
if ($params->get('k2Sef') && !$params->get('k2SefInsertCatId'))
{
$db = JFactory::getDbo();
$db->setQuery("SELECT id FROM #__k2_categories WHERE alias = ".$db->quote($this->alias)." AND id != ".(int)$this->id);
$result = count($db->loadObjectList());
if ($result > 0)
{
$this->alias .= '-'.((int)$result + 1);
$application = JFactory::getApplication();
$application->enqueueMessage(JText::_('K2_WARNING_DUPLICATE_TITLE_ALIAS_DETECTED'), 'notice');
}
}
return true;
}
function bind($array, $ignore = '')
{
if (key_exists('params', $array) && is_array($array['params']))
{
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = $registry->toString();
}
if (key_exists('plugins', $array) && is_array($array['plugins']))
{
$registry = new JRegistry();
$registry->loadArray($array['plugins']);
$array['plugins'] = $registry->toString();
}
return parent::bind($array, $ignore);
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2Comment extends K2Table
{
var $id = null;
var $itemID = null;
var $userID = null;
var $userName = null;
var $commentDate = null;
var $commentText = null;
var $commentEmail = null;
var $commentURL = null;
var $published = null;
function __construct(&$db)
{
parent::__construct('#__k2_comments', 'id', $db);
}
function check()
{
$this->commentText = JString::trim($this->commentText);
}
}

View File

@ -0,0 +1,41 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2ExtraField extends K2Table
{
var $id = null;
var $name = null;
var $value = null;
var $type = null;
var $group = null;
var $published = null;
var $ordering = null;
function __construct(&$db)
{
parent::__construct('#__k2_extra_fields', 'id', $db);
}
function check()
{
$this->name = JString::trim($this->name);
if ($this->name == '')
{
$this->setError(JText::_('K2_NAME_CANNOT_BE_EMPTY'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,37 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2ExtraFieldsGroup extends K2Table
{
var $id = null;
var $name = null;
function __construct(&$db)
{
parent::__construct('#__k2_extra_fields_groups', 'id', $db);
}
function check()
{
$this->name = JString::trim($this->name);
if ($this->name == '')
{
$this->setError(JText::_('K2_GROUP_MUST_HAVE_A_NAME'));
return false;
}
return true;
}
}

View File

@ -0,0 +1,326 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2Item extends K2Table
{
var $id = null;
var $title = null;
var $alias = null;
var $catid = null;
var $published = null;
var $introtext = null;
var $fulltext = null;
var $image_caption = null;
var $image_credits = null;
var $video = null;
var $video_caption = null;
var $video_credits = null;
var $gallery = null;
var $extra_fields = null;
var $extra_fields_search = null;
var $created = null;
var $created_by = null;
var $created_by_alias = null;
var $modified = null;
var $modified_by = null;
var $publish_up = null;
var $publish_down = null;
var $checked_out = null;
var $checked_out_time = null;
var $trash = null;
var $access = null;
var $ordering = null;
var $featured = null;
var $featured_ordering = null;
var $hits = null;
var $metadata = null;
var $metadesc = null;
var $metakey = null;
var $params = null;
var $plugins = null;
var $language = null;
function __construct(&$db)
{
parent::__construct('#__k2_items', 'id', $db);
}
function check()
{
jimport('joomla.filter.output');
$params = JComponentHelper::getParams('com_k2');
$this->title = JString::trim($this->title);
if ($this->title == '')
{
$this->setError(JText::_('K2_ITEM_MUST_HAVE_A_TITLE'));
return false;
}
if (!$this->catid)
{
$this->setError(JText::_('K2_ITEM_MUST_HAVE_A_CATEGORY'));
return false;
}
if (empty($this->alias))
{
$this->alias = $this->title;
}
if (K2_JVERSION == '15')
{
if (JPluginHelper::isEnabled('system', 'unicodeslug') || JPluginHelper::isEnabled('system', 'jw_unicodeSlugsExtended'))
{
$this->alias = JFilterOutput::stringURLSafe($this->alias);
}
else
{
mb_internal_encoding("UTF-8");
mb_regex_encoding("UTF-8");
$this->alias = trim(mb_strtolower($this->alias));
$this->alias = str_replace('-', ' ', $this->alias);
$this->alias = str_replace('/', '-', $this->alias);
$this->alias = mb_ereg_replace('[[:space:]]+', ' ', $this->alias);
$this->alias = trim(str_replace(' ', '-', $this->alias));
$this->alias = str_replace('.', '', $this->alias);
$this->alias = str_replace('"', '', $this->alias);
$this->alias = str_replace("'", '', $this->alias);
$stripthese = ',|~|!|@|%|^|(|)|<|>|:|;|{|}|[|]|&|`|„|‹|’|‘|“|â€<C3A2>|•|›|«|´|»|°|«|»|…';
$strips = explode('|', $stripthese);
foreach ($strips as $strip)
{
$this->alias = str_replace($strip, '', $this->alias);
}
if (trim(str_replace('-', '', $this->alias)) == '')
{
$datenow = JFactory::getDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
$this->alias = trim($this->alias, '-.');
}
}
else
{
if (JFactory::getConfig()->get('unicodeslugs') == 1)
{
$this->alias = JFilterOutput::stringURLUnicodeSlug($this->alias);
}
// Transliterate properly...
else
{
// Detect the site language we will transliterate
if ($this->language == '*')
{
$langParams = JComponentHelper::getParams('com_languages');
$languageTag = $langParams->get('site');
}
else
{
$languageTag = $this->language;
}
$language = JLanguage::getInstance($languageTag);
$this->alias = $language->transliterate($this->alias);
$this->alias = JFilterOutput::stringURLSafe($this->alias);
if (trim(str_replace('-', '', $this->alias)) == '')
{
$this->alias = JFactory::getDate()->format('Y-m-d-H-i-s');
}
}
}
if (K2_JVERSION == '15' || $params->get('enforceSEFReplacements'))
{
$SEFReplacements = array();
$items = explode(',', $params->get('SEFReplacements'));
foreach ($items as $item)
{
if (!empty($item))
{
@list($src, $dst) = explode('|', trim($item));
$SEFReplacements[trim($src)] = trim($dst);
}
}
foreach ($SEFReplacements as $key => $value)
{
$this->alias = str_replace($key, $value, $this->alias);
}
$this->alias = trim($this->alias, '-.');
}
if (K2_JVERSION == '15')
{
if (trim(str_replace('-', '', $this->alias)) == '')
{
$datenow = JFactory::getDate();
$this->alias = $datenow->toFormat("%Y-%m-%d-%H-%M-%S");
}
}
// Check if alias already exists. If so warn the user
$params = JComponentHelper::getParams('com_k2');
if ($params->get('k2Sef') && !$params->get('k2SefInsertItemId'))
{
$db = JFactory::getDbo();
$db->setQuery("SELECT id FROM #__k2_items WHERE alias = ".$db->quote($this->alias)." AND id != ".(int)$this->id);
$result = count($db->loadObjectList());
if ($result > 0)
{
$this->alias .= '-'.((int)$result + 1);
$application = JFactory::getApplication();
$application->enqueueMessage(JText::_('K2_WARNING_DUPLICATE_TITLE_ALIAS_DETECTED'), 'notice');
}
}
return true;
}
function bind($array, $ignore = '')
{
if (key_exists('params', $array) && is_array($array['params']))
{
$registry = new JRegistry();
$registry->loadArray($array['params']);
$array['params'] = $registry->toString();
}
if (key_exists('plugins', $array) && is_array($array['plugins']))
{
$registry = new JRegistry();
$registry->loadArray($array['plugins']);
$array['plugins'] = $registry->toString();
}
return parent::bind($array, $ignore);
}
function getNextOrder($where = '', $column = 'ordering')
{
$query = "SELECT MAX({$column}) FROM #__k2_items";
$query .= ($where ? " WHERE ".$where : "");
$this->_db->setQuery($query);
$maxord = $this->_db->loadResult();
if ($this->_db->getErrorNum())
{
$this->setError($this->_db->getErrorMsg());
return false;
}
return $maxord + 1;
}
function reorder($where = '', $column = 'ordering')
{
$k = $this->_tbl_key;
$query = "SELECT {$this->_tbl_key}, {$column} FROM #__k2_items WHERE {$column}>0";
$query .= ($where ? " AND ".$where : "");
$query .= " ORDER BY {$column}";
$this->_db->setQuery($query);
if (!($orders = $this->_db->loadObjectList()))
{
$this->setError($this->_db->getErrorMsg());
return false;
}
for ($i = 0, $n = count($orders); $i < $n; $i++)
{
if ($orders[$i]->$column >= 0)
{
if ($orders[$i]->$column != $i + 1)
{
$orders[$i]->$column = $i + 1;
$query = "UPDATE #__k2_items SET {$column}=".(int)$orders[$i]->$column;
$query .= ' WHERE '.$k.' = '.$this->_db->Quote($orders[$i]->$k);
$this->_db->setQuery($query);
$this->_db->query();
}
}
}
return true;
}
function move($dirn, $where = '', $column = 'ordering')
{
$k = $this->_tbl_key;
$sql = "SELECT $this->_tbl_key, {$column} FROM $this->_tbl";
if ($dirn < 0)
{
$sql .= ' WHERE '.$column.' < '.(int)$this->$column;
$sql .= ($where ? ' AND '.$where : '');
$sql .= ' ORDER BY '.$column.' DESC';
}
else if ($dirn > 0)
{
$sql .= ' WHERE '.$column.' > '.(int)$this->$column;
$sql .= ($where ? ' AND '.$where : '');
$sql .= ' ORDER BY '.$column;
}
else
{
$sql .= ' WHERE '.$column.' = '.(int)$this->$column;
$sql .= ($where ? ' AND '.$where : '');
$sql .= ' ORDER BY '.$column;
}
$this->_db->setQuery($sql, 0, 1);
$row = null;
$row = $this->_db->loadObject();
if (isset($row))
{
$query = 'UPDATE '.$this->_tbl.' SET '.$column.' = '.(int)$row->$column.' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($this->$k);
$this->_db->setQuery($query);
if (!$this->_db->query())
{
$err = $this->_db->getErrorMsg();
JError::raiseError(500, $err);
}
$query = 'UPDATE '.$this->_tbl.' SET '.$column.' = '.(int)$this->$column.' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($row->$k);
$this->_db->setQuery($query);
if (!$this->_db->query())
{
$err = $this->_db->getErrorMsg();
JError::raiseError(500, $err);
}
$this->$column = $row->$column;
}
else
{
$query = 'UPDATE '.$this->_tbl.' SET '.$column.' = '.(int)$this->$column.' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($this->$k);
$this->_db->setQuery($query);
if (!$this->_db->query())
{
$err = $this->_db->getErrorMsg();
JError::raiseError(500, $err);
}
}
return true;
}
}

View File

@ -0,0 +1,99 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2Tag extends K2Table
{
var $id = null;
var $name = null;
var $published = null;
function __construct(&$db)
{
parent::__construct('#__k2_tags', 'id', $db);
}
function check()
{
$this->name = JString::trim($this->name);
$this->name = JString::str_ireplace('-', '', $this->name);
$this->name = JString::str_ireplace('.', '', $this->name);
$params = JComponentHelper::getParams('com_k2');
if ($params->get('k2TagNorm'))
{
$searches = array('À', 'Á', 'Â', 'Ã', 'Ä', 'Å', 'à', 'á', 'â', 'ã', 'ä', 'å', 'Ā', 'ā', 'Ă', 'ă', 'Ą', 'ą', 'Ç', 'ç', 'Ć', 'ć', 'Ĉ', 'ĉ', 'Ċ', 'ċ', 'Č', 'č', 'Ð', 'ð', 'Ď', 'ď', 'Đ', 'đ', 'È', 'É', 'Ê', 'Ë', 'è', 'é', 'ê', 'ë', 'Ē', 'ē', 'Ĕ', 'ĕ', 'Ė', 'ė', 'Ę', 'ę', 'Ě', 'ě', 'Ĝ', 'ĝ', 'Ğ', 'ğ', 'Ġ', 'ġ', 'Ģ', 'ģ', 'Ĥ', 'ĥ', 'Ħ', 'ħ', 'Ì', 'Í', 'Î', 'Ï', 'ì', 'í', 'î', 'ï', 'Ĩ', 'ĩ', 'Ī', 'ī', 'Ĭ', 'ĭ', 'Į', 'į', 'İ', 'ı', 'Ĵ', 'ĵ', 'Ķ', 'ķ', 'ĸ', 'Ĺ', 'ĺ', 'Ļ', 'ļ', 'Ľ', 'ľ', 'Ŀ', 'ŀ', 'Ł', 'ł', 'Ñ', 'ñ', 'Ń', 'ń', 'Ņ', 'ņ', 'Ň', 'ň', 'ʼn', 'Ŋ', 'ŋ', 'Ò', 'Ó', 'Ô', 'Õ', 'Ö', 'Ø', 'ò', 'ó', 'ô', 'õ', 'ö', 'ø', 'Ō', 'ō', 'Ŏ', 'ŏ', 'Ő', 'ő', 'Ŕ', 'ŕ', 'Ŗ', 'ŗ', 'Ř', 'ř', 'Ś', 'ś', 'Ŝ', 'ŝ', 'Ş', 'ş', 'Š', 'š', 'ſ', 'Ţ', 'ţ', 'Ť', 'ť', 'Ŧ', 'ŧ', 'Ù', 'Ú', 'Û', 'Ü', 'ù', 'ú', 'û', 'ü', 'Ũ', 'ũ', 'Ū', 'ū', 'Ŭ', 'ŭ', 'Ů', 'ů', 'Ű', 'ű', 'Ų', 'ų', 'Ŵ', 'ŵ', 'Ý', 'ý', 'ÿ', 'Ŷ', 'ŷ', 'Ÿ', 'Ź', 'ź', 'Ż', 'ż', 'Ž', 'ž', 'Ά', 'ά', 'Έ', 'έ', 'Ή', 'ή', 'Ί', 'ί', 'Ό', 'ό', 'Ύ', 'ύ', 'Ώ', 'ώ', 'ϋ', 'ϊ', 'ΐ');
$replacements = array('A', 'A', 'A', 'A', 'A', 'A', 'a', 'a', 'a', 'a', 'a', 'a', 'A', 'a', 'A', 'a', 'A', 'a', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'C', 'c', 'D', 'd', 'D', 'd', 'D', 'd', 'E', 'E', 'E', 'E', 'e', 'e', 'e', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'E', 'e', 'G', 'g', 'G', 'g', 'G', 'g', 'G', 'g', 'H', 'h', 'H', 'h', 'I', 'I', 'I', 'I', 'i', 'i', 'i', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'I', 'i', 'J', 'j', 'K', 'k', 'k', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'L', 'l', 'N', 'n', 'N', 'n', 'N', 'n', 'N', 'n', 'n', 'N', 'n', 'O', 'O', 'O', 'O', 'O', 'O', 'o', 'o', 'o', 'o', 'o', 'o', 'O', 'o', 'O', 'o', 'O', 'o', 'R', 'r', 'R', 'r', 'R', 'r', 'S', 's', 'S', 's', 'S', 's', 'S', 's', 's', 'T', 't', 'T', 't', 'T', 't', 'U', 'U', 'U', 'U', 'u', 'u', 'u', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'U', 'u', 'W', 'w', 'Y', 'y', 'y', 'Y', 'y', 'Y', 'Z', 'z', 'Z', 'z', 'Z', 'z', 'Α', 'α', 'Ε', 'ε', 'Η', 'η', 'Ι', 'ι', 'Ο', 'ο', 'Υ', 'υ', 'Ω', 'ω', 'υ', 'ι', 'ι');
$additionalReplacements = $params->get('k2TagNormAdditionalReplacements');
$pairs = @explode(',', $additionalReplacements);
if(is_array($pairs))
{
foreach ($pairs as $pair) {
@list($search, $replace) = @explode('|', $pair);
if(isset($search) && $search && isset($replace) && $replace)
{
$searches[] = $search;
$replacements[] = $replace;
}
}
}
//$this->name = JString::str_ireplace($searches, $replacements, $this->name); // This causes character stripping in J!1.5!!
$this->name = str_ireplace($searches, $replacements, $this->name);
// Switch case
if ($params->get('k2TagNormCase') == 'upper')
{
$this->name = JString::strtoupper($this->name);
}
else
{
$this->name = JString::strtolower($this->name);
// Special case for Greek letter s final
$this->name = JString::str_ireplace('σ ', 'ς ', $this->name);
if(JString::substr($this->name, -1) == 'σ')
{
$this->name = JString::substr($this->name, 0, -1);
$this->name .= 'ς';
}
}
}
$this->name = JString::trim($this->name);
if ($this->name == '')
{
$this->setError(JText::_('K2_TAG_CANNOT_BE_EMPTY'));
return false;
}
if (strlen(utf8_decode($this->name)) < 2)
{
$this->setError(JText::_('K2_TAG_CANNOT_BE_A_SINGLE_CHARACTER'));
return false;
}
// Check if a tag exists already before adding a new one
if (!$this->id)
{
$this->_db->setQuery("SELECT id FROM #__k2_tags WHERE name = ".$this->_db->Quote($this->name));
if ($this->_db->loadResult())
{
$this->setError(JText::_('K2_THIS_TAG_EXISTS_ALREADY'));
return false;
}
}
return true;
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2User extends K2Table
{
var $id = null;
var $userID = null;
var $userName = null;
var $gender = null;
var $description = null;
var $image = null;
var $url = null;
var $group = null;
var $plugins = null;
var $ip = null;
var $hostname = null;
var $notes = null;
function __construct(&$db)
{
parent::__construct('#__k2_users', 'id', $db);
}
function check()
{
if (JString::trim($this->url) != '' && substr($this->url, 0, 7) != 'http://')
$this->url = 'http://'.$this->url;
return true;
}
function bind($array, $ignore = '')
{
if (key_exists('plugins', $array) && is_array($array['plugins']))
{
$registry = new JRegistry();
$registry->loadArray($array['plugins']);
$array['plugins'] = $registry->toString();
}
return parent::bind($array, $ignore);
}
}

View File

@ -0,0 +1,53 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
require_once JPATH_ADMINISTRATOR.'/components/com_k2/tables/table.php';
class TableK2UserGroup extends K2Table
{
var $id = null;
var $name = null;
var $permissions = null;
function __construct(&$db)
{
parent::__construct('#__k2_user_groups', 'id', $db);
}
function check()
{
$this->name = JString::trim($this->name);
if ($this->name == '')
{
$this->setError(JText::_('K2_GROUP_CANNOT_BE_EMPTY'));
return false;
}
return true;
}
function bind($array, $ignore = '')
{
if (key_exists('params', $array) && is_array($array['params']))
{
$registry = new JRegistry();
$registry->loadArray($array['params']);
if (JRequest::getVar('categories') == 'all' || JRequest::getVar('categories') == 'none')
$registry->set('categories', JRequest::getVar('categories'));
$array['permissions'] = $registry->toString();
}
return parent::bind($array, $ignore);
}
}

View File

@ -0,0 +1,27 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
class K2Table extends JTable
{
public function load($keys = null, $reset = true)
{
if (K2_JVERSION == '15')
{
return parent::load($keys);
}
else
{
return parent::load($keys, $reset);
}
}
}

View File

@ -0,0 +1,11 @@
DROP TABLE IF EXISTS `#__k2_attachments`;
DROP TABLE IF EXISTS `#__k2_categories`;
DROP TABLE IF EXISTS `#__k2_comments`;
DROP TABLE IF EXISTS `#__k2_extra_fields`;
DROP TABLE IF EXISTS `#__k2_extra_fields_groups`;
DROP TABLE IF EXISTS `#__k2_items`;
DROP TABLE IF EXISTS `#__k2_rating`;
DROP TABLE IF EXISTS `#__k2_tags`;
DROP TABLE IF EXISTS `#__k2_tags_xref`;
DROP TABLE IF EXISTS `#__k2_users`;
DROP TABLE IF EXISTS `#__k2_user_groups`;

Binary file not shown.

View File

@ -0,0 +1,302 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
$app = JFactory::getApplication();
$context = JRequest::getCmd('context');
?>
<?php if($app->isSite() || $context == "modalselector"): ?>
<!-- Modal View -->
<div id="k2ModalContainer">
<div id="k2ModalHeader">
<h2 id="k2ModalLogo"><?php echo JText::_('K2_CATEGORIES'); ?></h2>
<table id="k2ModalToolbar" cellpadding="2" cellspacing="4">
<tr>
<td id="toolbar-close" class="button">
<a href="#" id="k2CloseMfp">
<i class="fa fa-times-circle" aria-hidden="true"></i> <?php echo JText::_('K2_CLOSE'); ?>
</a>
</td>
</tr>
</table>
</div>
<?php endif; ?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<table class="k2AdminTableFilters table">
<tr>
<td class="k2AdminTableFiltersSearch">
<label class="visually-hidden"><?php echo JText::_('K2_FILTER'); ?></label>
<div class="btn-wrapper input-append">
<input type="text" name="search" value="<?php echo htmlspecialchars($this->lists['search'], ENT_QUOTES, 'UTF-8'); ?>" class="text_area" title="<?php echo JText::_('K2_FILTER_BY_TITLE'); ?>" placeholder="<?php echo JText::_('K2_FILTER'); ?>" />
<button id="k2SubmitButton" class="btn"><?php echo JText::_('K2_GO'); ?></button>
<button id="k2ResetButton" class="btn"><?php echo JText::_('K2_RESET'); ?></button>
</div>
</td>
<td class="k2AdminTableFiltersSelects">
<?php echo $this->lists['trash']; ?>
<?php echo $this->lists['state']; ?>
<?php echo $this->lists['categories']; ?>
<?php if(isset($this->lists['language'])): ?>
<?php echo $this->lists['language']; ?>
<?php endif; ?>
</td>
</tr>
</table>
<div class="table-responsive-wrap">
<div class="table-responsive">
<table class="adminlist table table-striped" id="k2CategoriesList">
<thead>
<tr>
<?php if(K2_JVERSION == '30'): ?>
<th width="1%" class="center hidden-phone">
<?php echo JHtml::_('grid.sort', '<i class="icon-menu-2"></i>', 'c.ordering', @$this->lists['order_Dir'], @$this->lists['order'], null, 'asc', 'K2_ORDER'); ?>
</th>
<?php else: ?>
<th>#</th>
<?php endif; ?>
<th<?php if($context == "modalselector") echo ' class="k2VisuallyHidden"'; ?>>
<input id="jToggler" type="checkbox" name="toggle" value="" />
</th>
<th>
<?php echo JHTML::_('grid.sort', 'K2_TITLE', 'c.name', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<?php if(K2_JVERSION != '30'): ?>
<th>
<?php echo JHTML::_('grid.sort', 'K2_ORDER', 'c.ordering', @$this->lists['order_Dir'], @$this->lists['order'] ); ?> <?php echo $this->ordering ?JHTML::_('grid.order', $this->rows ,'filesave.png' ):''; ?>
</th>
<?php endif ;?>
<th class="center hidden-phone">
<?php echo JText::_('K2_PARAMETER_INHERITANCE'); ?>
</th>
<th class="center hidden-phone">
<?php echo JHTML::_('grid.sort', 'K2_ASSOCIATED_EXTRA_FIELD_GROUPS', 'extra_fields_group', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th class="center hidden-phone">
<?php echo JText::_('K2_TEMPLATE'); ?>
</th>
<th class="hidden-phone center">
<?php echo JHTML::_('grid.sort', 'K2_ACCESS_LEVEL', 'c.access', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th class="center">
<?php echo JHTML::_('grid.sort', 'K2_PUBLISHED', 'c.published', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
<th class="center hidden-phone">
<?php echo JText::_('K2_IMAGE'); ?>
</th>
<?php if(isset($this->lists['language'])): ?>
<th class="hidden-phone"> <?php echo JHTML::_('grid.sort', 'K2_LANGUAGE', 'c.language', @$this->lists['order_Dir'], @$this->lists['order']); ?> </th>
<?php endif; ?>
<th class="hidden-phone center">
<?php echo JHTML::_('grid.sort', 'K2_ID', 'c.id', @$this->lists['order_Dir'], @$this->lists['order'] ); ?>
</th>
</tr>
</thead>
<?php
$tfootColspan = 10;
if(K2_JVERSION != '30') $tfootColspan++;
if(isset($this->lists['language'])) $tfootColspan++;
if($context == "modalselector") $tfootColspan--;
?>
<tfoot>
<tr>
<td colspan="<?php echo $tfootColspan; ?>">
<?php if(K2_JVERSION == '30'): ?>
<div class="k2LimitBox">
<?php echo $this->page->getLimitBox(); ?>
</div>
<?php endif; ?>
<?php echo $this->page->getListFooter(); ?>
</td>
</tr>
</tfoot>
<tbody>
<?php foreach ($this->rows as $key => $row) : ?>
<tr class="row<?php echo ($key%2); ?>" sortable-group-id="<?php echo $row->parent; ?>">
<?php if(K2_JVERSION == '30'): ?>
<td class="order center hidden-phone">
<?php if($row->canChange): ?>
<span class="sortable-handler <?php echo ($this->ordering) ? '' : 'inactive tip-top' ;?>" title="<?php echo ($this->ordering) ? '' :JText::_('JORDERINGDISABLED');?>" rel="tooltip"><i class="icon-menu"></i></span>
<input type="text" style="display:none" name="order[]" size="5" value="<?php echo $row->ordering;?>" class="width-20 text-area-order " />
<?php else: ?>
<span class="sortable-handler inactive" ><i class="icon-menu"></i></span>
<?php endif; ?>
</td>
<?php else: ?>
<td><?php echo $key+1; ?></td>
<?php endif; ?>
<td class="k2Center center<?php if($context == "modalselector") echo ' k2VisuallyHidden'; ?>">
<?php if(!$this->filter_trash || $row->trash) { $row->checked_out = 0; echo @JHTML::_('grid.checkedout', $row, $key );}?>
</td>
<td>
<?php if ($this->filter_trash): ?>
<?php if ($row->trash): ?>
<strong><?php echo $row->treename; ?> (<?php echo $row->numOfTrashedItems; ?>)</strong>
<?php else: ?>
<?php echo $row->treename; ?> (<?php echo $row->numOfItems.' '.JText::_('K2_ACTIVE'); ?> / <?php echo $row->numOfTrashedItems.' '.JText::_('K2_TRASHED'); ?>)
<?php endif; ?>
<?php else: ?>
<?php if($context == "modalselector"): ?>
<?php
if(JRequest::getCmd('output') == 'list'){
$onClick = 'window.parent.k2ModalSelector(\''.$row->id.'\', \''.str_replace(array("'", "\""), array("\\'", ""), $row->name).'\', \''.JRequest::getCmd('fid').'\', \''.JRequest::getVar('fname').'\', \''.JRequest::getCmd('output').'\'); return false;';
} else {
$onClick = 'window.parent.k2ModalSelector(\''.$row->id.'\', \''.str_replace(array("'", "\""), array("\\'", ""), $row->name).'\'); return false;';
}
?>
<a class="k2ListItemDisabled" title="<?php echo JText::_('K2_CLICK_TO_ADD_THIS_ENTRY'); ?>" href="#" onclick="<?php echo $onClick; ?>">
<?php echo $row->treename; ?>
<?php if($this->params->get('showItemsCounterAdmin')): ?>
<span class="small">(<?php echo $row->numOfItems.' '.JText::_('K2_ACTIVE'); ?> / <?php echo $row->numOfTrashedItems.' '.JText::_('K2_TRASHED'); ?>)</span>
<?php endif; ?>
</a>
<?php else: ?>
<a href="<?php echo JRoute::_('index.php?option=com_k2&view=category&cid='.$row->id); ?>">
<?php echo $row->treename; ?>
<?php if($this->params->get('showItemsCounterAdmin')): ?>
<span class="small">(<?php echo $row->numOfItems.' '.JText::_('K2_ACTIVE'); ?> / <?php echo $row->numOfTrashedItems.' '.JText::_('K2_TRASHED'); ?>)</span>
<?php endif; ?>
</a>
<?php endif; ?>
<?php endif; ?>
</td>
<?php if(K2_JVERSION != '30'): ?>
<td class="order k2Order">
<span><?php echo $this->page->orderUpIcon( $key, $row->parent == 0 || $row->parent == @$this->rows[$key-1]->parent, 'orderup', 'K2_MOVE_UP', $this->ordering); ?></span> <span><?php echo $this->page->orderDownIcon( $key, count($this->rows), $row->parent == 0 || $row->parent == @$this->rows[$key+1]->parent, 'orderdown', 'K2_MOVE_DOWN', $this->ordering ); ?></span>
<input type="text" name="order[]" size="5" value="<?php echo $row->ordering; ?>" <?php echo ($this->ordering)?'':'disabled="disabled"'; ?> class="text_area k2OrderBox" />
</td>
<?php endif; ?>
<td class="k2Center center hidden-phone">
<?php echo $row->inheritFrom; ?>
</td>
<td class="k2Center center hidden-phone">
<?php echo $row->extra_fields_group; ?>
</td>
<td class="k2Center center hidden-phone">
<?php echo $row->template; ?>
</td>
<td class="k2Center hidden-phone center">
<?php echo ($this->filter_trash || K2_JVERSION != '15')? $row->groupname:JHTML::_('grid.access', $row, $key ); ?>
</td>
<td class="k2Center center">
<?php echo $row->status; ?>
</td>
<td class="k2Center center hidden-phone">
<?php if($row->image): ?>
<a href="<?php echo JURI::root(true).'/media/k2/categories/'.$row->image; ?>" title="<?php echo JText::_('K2_PREVIEW_IMAGE'); ?>" data-fancybox="gallery" data-caption="<?php echo $row->title; ?>">
<?php if (K2_JVERSION == '30') : ?>
<i class="icon-picture" title="<?php echo JText::_('K2_PREVIEW_IMAGE'); ?>"></i>
<?php else: ?>
<img src="templates/<?php echo $this->template; ?>/images/menu/icon-16-media.png" alt="<?php echo JText::_('K2_PREVIEW_IMAGE'); ?>" />
<?php endif; ?>
</a>
<?php endif; ?>
</td>
<?php if(isset($this->lists['language'])): ?>
<td class="center hidden-phone"><?php echo $row->language; ?></td>
<?php endif; ?>
<td class="k2Center center hidden-phone">
<?php echo $row->id; ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</div>
<!-- Batch Operations Modal -->
<div id="k2BatchOperations" class="jw-modal">
<div class="jw-modal-content">
<div class="jw-modal-header">
<div class="row row-nomax">
<h3 class="k2FLeft"><?php echo JText::_('K2_BATCH_OPERATIONS'); ?></h3>
<span class="k2FRight">
<strong><span id="k2BatchOperationsCounter">0</span></strong>
<?php echo JText::_('K2_SELECTED_ITEMS'); ?>
</span>
</div>
</div>
<div class="subheader-alt">
<div class="row">
<div class="column small-12 large-9 small-centered">
<div class="row">
<div class="column small-12 large-6">
<input type="radio" name="batchMode" value="apply" id="assign" checked="checked" />
<label for="assign"><?php echo JText::_('K2_ASSIGN'); ?></label>
</div>
<div class="column small-12 large-6 clearfix">
<input type="radio" name="batchMode" value="clone" id="clone" />
<label for="clone"><?php echo JText::_('K2_CREATE_DUPLICATE'); ?></label>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="column small-12 large-9 small-centered">
<div class="row">
<div class="column small-12 large-6 action-alt">
<label class="label-alt"><i class="fa fa-folder-open"></i> <?php echo JText::_('K2_PARENT_CATEGORY'); ?></label>
<?php echo $this->lists['batchCategories']; ?>
</div>
<div class="column small-12 large-6 clearfix action-alt">
<label class="label-alt"><i class="fa fa-unlock-alt"></i> <?php echo JText::_('K2_ACCESS_LEVEL'); ?></label>
<?php echo $this->lists['batchAccess']; ?>
</div>
<div class="column small-12 large-6 action-alt">
<label class="label-alt"><i class="fa fa-th-list"></i> <?php echo JText::_('K2_EXTRA_FIELD_GROUPS'); ?></label>
<?php echo $this->lists['batchExtraFieldsGroups']; ?>
</div>
<div class="column small-12 large-6 clearfix action-alt">
<?php if(isset($this->lists['language'])): ?>
<label class="label-alt"><i class="fa fa-globe"></i> <?php echo JText::_('K2_LANGUAGE'); ?></label>
<?php echo $this->lists['batchLanguage']; ?>
<?php endif; ?>
</div>
</div>
</div>
</div>
<div class="jw-modal-footer text-right">
<div class="column large-9 small-centered">
<?php if(K2_JVERSION == '15'): ?>
<button class="jw-btn jw-btn-save" onclick="javascript:submitbutton('saveBatch')"><?php echo JText::_('K2_APPLY'); ?></button>
<?php else: ?>
<button class="jw-btn jw-btn-save" onclick="Joomla.submitbutton('saveBatch')" class="btn btn-small"><?php echo JText::_('K2_APPLY'); ?></button>
<?php endif; ?>
<button class="jw-btn jw-btn-close" onclick="$K2('.jw-modal-open').removeClass('jw-modal-open'); return false;"><?php echo JText::_('K2_CANCEL'); ?></button>
</div>
</div>
</div>
</div>
<input type="hidden" name="option" value="com_k2" />
<input type="hidden" name="view" value="<?php echo JRequest::getVar('view'); ?>" />
<input type="hidden" name="task" value="" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<input type="hidden" name="boxchecked" value="0" />
<?php if($context == "modalselector"): ?>
<input type="hidden" name="context" value="modalselector" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="fid" value="<?php echo JRequest::getCmd('fid'); ?>" />
<input type="hidden" name="fname" value="<?php echo JRequest::getVar('fname'); ?>" />
<input type="hidden" name="output" value="<?php echo JRequest::getCmd('output'); ?>" />
<?php endif; ?>
<?php echo JHTML::_( 'form.token' ); ?>
</form>
<?php if($app->isSite() || $context == "modalselector"): ?>
</div>
<?php endif; ?>

View File

@ -0,0 +1,73 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<h1><?php echo JText::_('K2_SELECT_CATEGORIES'); ?></h1>
<table class="k2AdminTableFilters">
<tr>
<td class="k2AdminTableFiltersSearch">
<label class="visually-hidden"><?php echo JText::_('K2_FILTER'); ?></label>
<div class="btn-wrapper input-append">
<input type="text" name="search" value="<?php echo $this->lists['search'] ?>" class="text_area" title="<?php echo JText::_('K2_FILTER_BY_TITLE'); ?>" placeholder="<?php echo JText::_('K2_FILTER'); ?>" />
<button id="k2SubmitButton" class="btn"><?php echo JText::_('K2_GO'); ?></button>
<button id="k2ResetButton" class="btn"><?php echo JText::_('K2_RESET'); ?></button>
</div>
</td>
<td class="k2AdminTableFiltersSelects">
<?php echo $this->lists['state']; ?>
</td>
</tr>
</table>
<table class="adminlist table table-striped">
<thead>
<tr>
<th>#</th>
<th> <?php echo JHTML::_('grid.sort', 'K2_TITLE', 'c.name', @$this->lists['order_Dir'], @$this->lists['order'], 'element'); ?></th>
<th><?php echo JHTML::_('grid.sort', 'K2_ASSOCIATED_EXTRA_FIELD_GROUPS', 'extra_fields_group', @$this->lists['order_Dir'], @$this->lists['order'], 'element' ); ?></th>
<th><?php echo JHTML::_('grid.sort', 'K2_ACCESS_LEVEL', 'c.access', @$this->lists['order_Dir'], @$this->lists['order'], 'element' ); ?></th>
<th><?php echo JHTML::_('grid.sort', 'K2_PUBLISHED', 'c.published', @$this->lists['order_Dir'], @$this->lists['order'], 'element' ); ?></th>
<th><?php echo JHTML::_('grid.sort', 'K2_ID', 'c.id', @$this->lists['order_Dir'], @$this->lists['order'], 'element' ); ?></th>
</tr>
</thead>
<tbody>
<?php foreach ($this->rows as $key => $row): ?>
<tr class="row<?php echo ($key%2); ?>">
<td><?php echo $key+1; ?></td>
<td><a class="k2ListItemDisabled" title="<?php echo JText::_('K2_CLICK_TO_ADD_THIS_ITEM'); ?>" onclick="window.parent.jSelectCategory('<?php echo $row->id; ?>', '<?php echo str_replace(array("'", "\""), array("\\'", ""),$row->name); ?>', 'id');"><?php echo $row->treename; ?></a></td>
<td class="k2Center"><?php echo $row->extra_fields_group; ?></td>
<td class="k2Center"><?php echo $row->groupname; ?></td>
<td class="k2Center"><?php echo $row->status; ?></td>
<td><?php echo $row->id; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
<tfoot>
<tr>
<td colspan="6">
<?php if(K2_JVERSION == '30'): ?>
<div class="k2LimitBox">
<?php echo $this->page->getLimitBox(); ?>
</div>
<?php endif; ?>
<?php echo $this->page->getListFooter(); ?>
</td>
</tr>
</tfoot>
</table>
<input type="hidden" name="option" value="com_k2" />
<input type="hidden" name="view" value="<?php echo JRequest::getVar('view'); ?>" />
<input type="hidden" name="task" value="element" />
<input type="hidden" name="tmpl" value="component" />
<input type="hidden" name="filter_order" value="<?php echo $this->lists['order']; ?>" />
<input type="hidden" name="filter_order_Dir" value="<?php echo $this->lists['order_Dir']; ?>" />
<?php echo JHTML::_( 'form.token' ); ?>
</form>

View File

@ -0,0 +1,46 @@
<?php
/**
* @version 2.7.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2016 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
$document = JFactory::getDocument();
$document->addScriptDeclaration("
Joomla.submitbutton = function(pressbutton) {
if (pressbutton == 'cancel') {
submitform( pressbutton );
return;
}
if (\$K2.trim(\$K2('#category').val()) == '') {
alert( '".JText::_('K2_YOU_MUST_SELECT_A_PARENT_CATEGORY', true)."' );
} else {
submitform( pressbutton );
}
};
");
?>
<form action="index.php" method="post" name="adminForm" id="adminForm">
<fieldset>
<legend><?php echo JText::_('K2_PARENT_CATEGORY'); ?></legend>
<?php echo $this->lists['categories']; ?>
</fieldset>
<fieldset>
<legend>(<?php echo count($this->rows); ?>) <?php echo JText::_('K2_CATEGORIES_BEING_MOVED'); ?></legend>
<ol>
<?php foreach ($this->rows as $row): ?>
<li><?php echo $row->name; ?><input type="hidden" name="cid[]" value="<?php echo $row->id; ?>" /></li>
<?php endforeach; ?>
</ol>
</fieldset>
<input type="hidden" name="option" value="com_k2" />
<input type="hidden" name="view" value="<?php echo JRequest::getVar('view'); ?>" />
<input type="hidden" name="task" value="<?php echo JRequest::getVar('task'); ?>" />
</form>

View File

@ -0,0 +1,274 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
jimport('joomla.application.component.view');
class K2ViewCategories extends K2View
{
function display($tpl = null)
{
$application = JFactory::getApplication();
$document = JFactory::getDocument();
$user = JFactory::getUser();
$params = JComponentHelper::getParams('com_k2');
$option = JRequest::getCmd('option');
$view = JRequest::getCmd('view');
$limit = $application->getUserStateFromRequest('global.list.limit', 'limit', $application->getCfg('list_limit'), 'int');
$limitstart = $application->getUserStateFromRequest($option.$view.'.limitstart', 'limitstart', 0, 'int');
$filter_order = $application->getUserStateFromRequest($option.$view.'filter_order', 'filter_order', 'c.ordering', 'cmd');
$filter_order_Dir = $application->getUserStateFromRequest($option.$view.'filter_order_Dir', 'filter_order_Dir', '', 'word');
$filter_trash = $application->getUserStateFromRequest($option.$view.'filter_trash', 'filter_trash', 0, 'int');
$filter_category = $application->getUserStateFromRequest($option.$view.'filter_category', 'filter_category', 0, 'int');
$filter_state = $application->getUserStateFromRequest($option.$view.'filter_state', 'filter_state', -1, 'int');
$language = $application->getUserStateFromRequest($option.$view.'language', 'language', '', 'string');
$search = $application->getUserStateFromRequest($option.$view.'search', 'search', '', 'string');
$search = JString::strtolower($search);
$search = trim(preg_replace('/[^\p{L}\p{N}\s\"\-_]/u', '', $search));
$model = $this->getModel();
$total = $model->getTotal();
$task = JRequest::getCmd('task');
if ($limitstart > $total - $limit)
{
$limitstart = max(0, (int)(ceil($total / $limit) - 1) * $limit);
JRequest::setVar('limitstart', $limitstart);
}
$categories = $model->getData();
$categoryModel = K2Model::getInstance('Category', 'K2Model');
// JS
$document->addScriptDeclaration("
var K2SelectItemsError = '".JText::_('K2_SELECT_SOME_ITEMS_FIRST')."';
Joomla.submitbutton = function(pressbutton) {
if (pressbutton == 'trash') {
var answer = confirm('".JText::_('K2_WARNING_YOU_ARE_ABOUT_TO_TRASH_THE_SELECTED_CATEGORIES_THEIR_CHILDREN_CATEGORIES_AND_ALL_THEIR_INCLUDED_ITEMS', true)."')
if (answer){
submitform(pressbutton);
} else {
return;
}
} else {
submitform(pressbutton);
}
};
");
$this->assignRef('params', $params);
if (K2_JVERSION != '15')
{
$langs = JLanguageHelper::getLanguages();
$langsMapping = array();
$langsMapping['*'] = JText::_('K2_ALL');
foreach ($langs as $lang)
{
$langsMapping[$lang->lang_code] = $lang->title;
}
}
for ($i = 0; $i < sizeof($categories); $i++)
{
$categories[$i]->status = K2_JVERSION == '15' ? JHTML::_('grid.published', $categories[$i], $i) : JHtml::_('jgrid.published', $categories[$i]->published, $i, '', $filter_trash == 0 && $task != 'element');
if ($params->get('showItemsCounterAdmin'))
{
$categories[$i]->numOfItems = $categoryModel->countCategoryItems($categories[$i]->id);
$categories[$i]->numOfTrashedItems = $categoryModel->countCategoryItems($categories[$i]->id, 1);
}
if (K2_JVERSION == '30')
{
$categories[$i]->canChange = $user->authorise('core.edit.state', 'com_k2.category.'.$categories[$i]->id);
}
// Detect the category template
if (K2_JVERSION != '15')
{
$categoryParams = json_decode($categories[$i]->params);
$categories[$i]->template = $categoryParams->theme;
$categories[$i]->language = $categories[$i]->language ? $categories[$i]->language : '*';
if (isset($langsMapping))
{
$categories[$i]->language = $langsMapping[$categories[$i]->language];
}
}
else
{
if (function_exists('parse_ini_string'))
{
$categoryParams = parse_ini_string($categories[$i]->params);
$categories[$i]->template = $categoryParams['theme'];
}
else
{
$categoryParams = new JParameter($categories[$i]->params);
$categories[$i]->template = $categoryParams->get('theme');
}
}
if (!$categories[$i]->template)
{
$categories[$i]->template = 'default';
}
}
$this->assignRef('rows', $categories);
// Show message for trash entries in Categories
if(count($categories) && $filter_trash) {
$application->enqueueMessage(JText::_('K2_ALL_TRASHED_ITEMS_IN_A_CATEGORY_MUST_BE_DELETED_FIRST'));
}
jimport('joomla.html.pagination');
$pageNav = new JPagination($total, $limitstart, $limit);
$this->assignRef('page', $pageNav);
$lists = array();
// Detect exact search phrase using double quotes in search string
if(substr($search, 0, 1)=='"' && substr($search, -1)=='"')
{
$lists['search'] = "\"".trim(str_replace('"', '', $search))."\"";
}
else
{
$lists['search'] = trim(str_replace('"', '', $search));
}
$lists['order_Dir'] = $filter_order_Dir;
$lists['order'] = $filter_order;
$filter_trash_options[] = JHTML::_('select.option', 0, JText::_('K2_CURRENT'));
$filter_trash_options[] = JHTML::_('select.option', 1, JText::_('K2_TRASHED'));
$lists['trash'] = JHTML::_('select.genericlist', $filter_trash_options, 'filter_trash', '', 'value', 'text', $filter_trash);
$filter_state_options[] = JHTML::_('select.option', -1, JText::_('K2_SELECT_STATE'));
$filter_state_options[] = JHTML::_('select.option', 1, JText::_('K2_PUBLISHED'));
$filter_state_options[] = JHTML::_('select.option', 0, JText::_('K2_UNPUBLISHED'));
$lists['state'] = JHTML::_('select.genericlist', $filter_state_options, 'filter_state', '', 'value', 'text', $filter_state);
require_once JPATH_ADMINISTRATOR.'/components/com_k2/models/categories.php';
$categoriesModel = K2Model::getInstance('Categories', 'K2Model');
$categories_option[] = JHTML::_('select.option', 0, JText::_('K2_SELECT_CATEGORY'));
$categoriesFilter = $categoriesModel->categoriesTree(NULL, true, false);
$categoriesTree = $categoriesFilter;
$categories_options = @array_merge($categories_option, $categoriesFilter);
$lists['categories'] = JHTML::_('select.genericlist', $categories_options, 'filter_category', '', 'value', 'text', $filter_category);
// Batch Operations
$extraFieldsModel = K2Model::getInstance('ExtraFields', 'K2Model');
$extraFieldsGroups = $extraFieldsModel->getGroups();
$options = array();
$options[] = JHTML::_('select.option', '', JText::_('K2_LEAVE_UNCHANGED'));
$options[] = JHTML::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS'));
foreach ($extraFieldsGroups as $extraFieldsGroup)
{
$name = $extraFieldsGroup->name;
$options[] = JHTML::_('select.option', $extraFieldsGroup->id, $name);
}
$lists['batchExtraFieldsGroups'] = JHTML::_('select.genericlist', $options, 'batchExtraFieldsGroups', '', 'value', 'text', null);
array_unshift($categoriesTree, JHtml::_('select.option', '0', JText::_('K2_NONE_ONSELECTLISTS')));
array_unshift($categoriesTree, JHtml::_('select.option', '', JText::_('K2_LEAVE_UNCHANGED')));
$lists['batchCategories'] = JHTML::_('select.genericlist', $categoriesTree, 'batchCategory', 'class="inputbox" size="8"', 'value', 'text', null);
$lists['batchAccess'] = version_compare(JVERSION, '2.5', 'ge') ? JHTML::_('access.level', 'batchAccess', null, '', array(JHtml::_('select.option', '', JText::_('K2_LEAVE_UNCHANGED')))) : str_replace('size="3"', "", JHTML::_('list.accesslevel', ''));
if (version_compare(JVERSION, '2.5.0', 'ge'))
{
$languages = JHTML::_('contentlanguage.existing', true, true);
array_unshift($languages, JHtml::_('select.option', '', JText::_('K2_LEAVE_UNCHANGED')));
$lists['batchLanguage'] = JHTML::_('select.genericlist', $languages, 'batchLanguage', '', 'value', 'text', null);
}
if (version_compare(JVERSION, '1.6.0', 'ge'))
{
$languages = JHTML::_('contentlanguage.existing', true, true);
array_unshift($languages, JHTML::_('select.option', '', JText::_('K2_SELECT_LANGUAGE')));
$lists['language'] = JHTML::_('select.genericlist', $languages, 'language', '', 'value', 'text', $language);
}
$this->assignRef('lists', $lists);
// Toolbar
JToolBarHelper::title(JText::_('K2_CATEGORIES'), 'k2.png');
$toolbar = JToolBar::getInstance('toolbar');
if ($filter_trash == 1)
{
JToolBarHelper::deleteList('K2_ARE_YOU_SURE_YOU_WANT_TO_DELETE_SELECTED_CATEGORIES', 'remove', 'K2_DELETE');
JToolBarHelper::custom('restore', 'publish.png', 'publish_f2.png', 'K2_RESTORE', true);
}
else
{
JToolBarHelper::addNew();
JToolBarHelper::editList();
JToolBarHelper::publishList();
JToolBarHelper::unpublishList();
JToolBarHelper::trash('trash');
JToolBarHelper::custom('copy', 'copy.png', 'copy_f2.png', 'K2_COPY', true);
if (K2_JVERSION == '30')
{
$batchButton = '<a id="K2BatchButton" class="btn btn-small" href="#"><i class="icon-edit "></i>'.JText::_('K2_BATCH').'</a>';
}
else
{
$batchButton = '<a id="K2BatchButton" href="#"><span class="icon-32-edit" title="'.JText::_('K2_BATCH').'"></span>'.JText::_('K2_BATCH').'</a>';
}
$toolbar->appendButton('Custom', $batchButton);
}
// Preferences (Parameters/Settings)
if (K2_JVERSION != '15')
{
JToolBarHelper::preferences('com_k2', 580, 800, 'K2_PARAMETERS');
}
else
{
$toolbar->appendButton('Popup', 'config', 'K2_PARAMETERS', 'index.php?option=com_k2&view=settings', 800, 580);
}
$this->loadHelper('html');
K2HelperHTML::subMenu();
$this->assignRef('filter_trash', $filter_trash);
$template = $application->getTemplate();
$this->assignRef('template', $template);
$ordering = (($this->lists['order'] == 'c.ordering' || $this->lists['order'] == 'c.parent, c.ordering') && (!$this->filter_trash));
$this->assignRef('ordering', $ordering);
// Joomla 3.0 drag-n-drop sorting variables
if (K2_JVERSION == '30')
{
if ($ordering)
{
JHtml::_('sortablelist.sortable', 'k2CategoriesList', 'adminForm', strtolower($this->lists['order_Dir']), 'index.php?option=com_k2&view=categories&task=saveorder&format=raw');
}
$document->addScriptDeclaration('
Joomla.orderTable = function() {
table = document.getElementById("sortTable");
direction = document.getElementById("directionTable");
order = table.options[table.selectedIndex].value;
if (order != \''.$this->lists['order'].'\') {
dirn = \'asc\';
} else {
dirn = direction.options[direction.selectedIndex].value;
}
Joomla.tableOrdering(order, dirn, "");
}
');
}
parent::display($tpl);
}
}

View File

@ -0,0 +1,414 @@
<?php
/**
* @version 2.8.x
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2017 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
?>
<form action="index.php" enctype="multipart/form-data" method="post" name="adminForm" id="adminForm" class="k2CategoryForm">
<!-- Top Nav Tabs START here -->
<div id="k2FormTopNav" class="k2Tabs">
<ul class="k2NavTabs">
<li id="tabContent"><a href="#k2TabBasic"><i class="fa fa-home"></i><?php echo JText::_('K2_BASIC'); ?></a></li>
<li><a href="#k2TabPubAndMeta"><i class="fa fa-info-circle"></i><?php echo JText::_('K2_PUBLISHING_AND_METADATA'); ?></a></li>
<li id="tabContent"><a href="#k2TabDisplaySet"><i class="fa fa-desktop"></i><?php echo JText::_('K2_DISPLAY_SETTINGS'); ?></a></li>
</ul>
<!-- Top Nav Tabs content -->
<div class="k2NavTabContent" id="k2TabBasic">
<div class="k2Table ">
<div class="k2TableLabel">
<label for="name"><?php echo JText::_('K2_TITLE'); ?></label>
</div>
<div class="k2TableValue">
<input class="text_area k2TitleBox" type="text" name="name" id="name" value="<?php echo $this->row->name; ?>" maxlength="250" />
</div>
<div class="k2TableLabel">
<label for="alias"><?php echo JText::_('K2_TITLE_ALIAS'); ?></label>
</div>
<div class="k2TableValue">
<input class="text_area k2TitleAliasBox" type="text" name="alias" value="<?php echo $this->row->alias; ?>" maxlength="250" />
</div>
<div class="k2SubTable k2CatTableLeft">
<div class="k2SubTableLabel">
<label for="parent"><?php echo JText::_('K2_PARENT_CATEGORY'); ?></label>
</div>
<div class="k2SubTableValue">
<?php echo $this->lists['parent']; ?>
</div>
<div class="k2SubTableLabel">
<label for="paramsinheritFrom"><?php echo JText::_('K2_INHERIT_PARAMETER_OPTIONS_FROM_CATEGORY'); ?></label>
</div>
<div class="k2SubTableValue">
<?php echo $this->lists['inheritFrom']; ?> <span class="hasTip k2Notice" title="<?php echo JText::_('K2_INHERIT_PARAMETER_OPTIONS_FROM_CATEGORY'); ?>::<?php echo JText::_('K2_SETTING_THIS_OPTION_WILL_MAKE_THIS_CATEGORY_INHERIT_ALL_PARAMETERS_FROM_ANOTHER_CATEGORY_THUS_YOU_DONT_HAVE_TO_RESET_ALL_OPTIONS_IN_THIS_ONE_IF_THEY_ARE_THE_SAME_WITH_ANOTHER_CATEGORYS_THIS_SETTING_IS_VERY_USEFUL_WHEN_YOU_ARE_CREATING_CHILD_CATEGORIES_WHICH_SHARE_THE_SAME_PARAMETERS_WITH_THEIR_PARENT_CATEGORY_EG_IN_THE_CASE_OF_A_CATALOG_OR_A_NEWS_PORTALMAGAZINE'); ?>">
<br /><?php echo JText::_('K2_LEARN_WHAT_THIS_MEANS'); ?></span>
</div>
</div>
<div class="k2SubTable k2CatTableRight">
<div class="k2SubTableLabel">
<label for="extraFieldsGroup"><?php echo JText::_('K2_ASSOCIATED_EXTRA_FIELDS_GROUP'); ?></label>
</div>
<div class="k2SubTableValue">
<?php echo $this->lists['extraFieldsGroup']; ?>
</div>
<div class="k2SubTableLabel">
<label><?php echo JText::_('K2_PUBLISHED'); ?></label>
</div>
<div class="k2SubTableValue">
<?php echo $this->lists['published']; ?>
</div>
</div>
<div class="clr"></div>
<div class="k2SubTable k2CatTableLeft">
<div class="k2SubTableLabel">
<label for="access"><?php echo JText::_('K2_ACCESS_LEVEL'); ?></label>
</div>
<div class="k2SubTableValue">
<?php echo $this->lists['access']; ?>
</div>
<?php if(isset($this->lists['language'])): ?>
<div class="k2SubTableLabel">
<label><?php echo JText::_('K2_LANGUAGE'); ?></label>
</div>
<div class="k2SubTableValue">
<?php echo $this->lists['language']; ?>
</div>
<?php endif; ?>
</div>
</div>
<div class="clr"></div>
<!-- Tabs start here -->
<div class="k2Tabs" id="k2Tabs">
<ul class="k2TabsNavigation">
<li id="tabContent"><a href="#k2Tab1">
<i class="fa fa-file-text-o"></i>
<?php echo JText::_('K2_DESCRIPTION'); ?></a>
</li>
<li id="tabImage"><a href="#k2Tab2">
<i class="fa fa-camera"></i><?php echo JText::_('K2_IMAGE'); ?></a>
</li>
</ul>
<!-- Tab content -->
<div class="k2TabsContent" id="k2Tab1">
<div class="k2ItemFormEditor"> <span class="k2ItemFormEditorTitle"> <?php echo JText::_('K2_CATEGORY_DESCRIPTION'); ?> </span> <?php echo $this->editor; ?>
<div class="dummyHeight"></div>
<div class="clr"></div>
</div>
<div class="clr"></div>
</div>
<!-- Tab image -->
<div class="k2TabsContent k2TabsContentLower" id="k2Tab2">
<?php if (!empty($this->row->image)): ?>
<div class="itemAdditionalField">
<div class="k2FLeft k2Right itemAdditionalValue">
<label><?php echo JText::_('K2_ITEM_IMAGE_PREVIEW'); ?></label>
</div>
<div class="itemAdditionalData">
<img src="<?php echo JURI::root(true); ?>/media/k2/categories/<?php echo $this->row->image; ?>" alt="<?php echo $this->row->name; ?>" class="k2AdminImage" />
<input type="checkbox" name="del_image" id="del_image" />
<label for="del_image"><?php echo JText::_('K2_CHECK_THIS_BOX_TO_DELETE_CURRENT_IMAGE_OR_JUST_UPLOAD_A_NEW_IMAGE_TO_REPLACE_THE_EXISTING_ONE'); ?></label>
</div>
</div>
<?php endif; ?>
<div class="itemAdditionalField">
<div class="k2FLeft k2Right itemAdditionalValue">
<label><?php echo JText::_('K2_CATEGORY_IMAGE'); ?></label>
</div>
<div class="itemAdditionalData">
<input type="file" name="image" class="fileUpload" />
<i>(<?php echo JText::_('K2_MAX_UPLOAD_SIZE'); ?>: <?php echo ini_get('upload_max_filesize'); ?>)</i>
<span class="sep"><?php echo JText::_('K2_OR'); ?></span>
<input type="text" name="existingImage" id="existingImageValue" class="text_area" readonly />
<input type="button" value="<?php echo JText::_('K2_BROWSE_SERVER'); ?>" id="k2ImageBrowseServer" />
</div>
</div>
</div>
<!-- image tab ends here -->
</div>
<!-- Tabs end here -->
<!-- K2 Category Plugins -->
<?php if (count($this->K2Plugins)): ?>
<div class="itemPlugins">
<?php foreach ($this->K2Plugins as $K2Plugin): ?>
<?php if(!is_null($K2Plugin)): ?>
<fieldset class="adminform">
<legend><?php echo $K2Plugin->name; ?></legend>
<?php echo $K2Plugin->fields; ?>
</fieldset>
<?php endif; ?>
<?php endforeach; ?>
</div>
<?php endif; ?>
<div class="clr"></div>
</div>
<!-- END of Basic parameters -->
<div class="k2NavTabContent" id="k2TabPubAndMeta">
<div class="xmlParamsFields limitWidth">
<h3><?php echo JText::_('K2_METADATA_INFORMATION'); ?></h3>
<fieldset class="panelform">
<ul class="adminformlist">
<?php if(version_compare( JVERSION, '1.6.0', 'ge' )): ?>
<?php foreach ($this->form->getFieldset('category-metadata-information') as $field): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if($field->type=='header'): ?>
<div class="paramValueHeader"><?php echo $field->input; ?></div>
<?php elseif($field->type=='Spacer'): ?>
<div class="paramValueSpacer">&nbsp;</div>
<div class="clr"></div>
<?php else: ?>
<div class="paramLabel"><?php echo $field->label; ?></div>
<div class="paramValue"><?php echo $field->input; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($this->form->getParams('params', 'category-metadata-information') as $param): ?>
<li>
<?php if((string)$param[1]=='' || $param[5] == ''): ?>
<div class="paramValueHeader"><?php echo $param[1]; ?></div>
<?php else: ?>
<div class="paramLabel"><?php echo $param[0]; ?></div>
<div class="paramValue"><?php echo $param[1]; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
</div>
<!-- END of Publishing and metadata tab -->
<div class="k2NavTabContent" id="k2TabDisplaySet">
<ul class="k2ScrollSpyMenu">
<li><a href="#catLayoutOptions"><?php echo JText::_('K2_CATEGORY_ITEM_LAYOUT'); ?></a></li>
<li><a href="#catViewOptions"><?php echo JText::_('K2_CATEGORY_VIEW_OPTIONS'); ?></a></li>
<li><a href="#catImageOptions"><?php echo JText::_('K2_ITEM_IMAGE_OPTIONS'); ?></a></li>
<li><a href="#catItemsOptions"><?php echo JText::_('K2_ITEM_VIEW_OPTIONS_IN_CATEGORY_LISTINGS'); ?></a></li>
<li><a href="#catItemOptions"><?php echo JText::_('K2_ITEM_VIEW_OPTIONS'); ?></a></li>
</ul>
<div class="k2ScrollingContent xmlParamsFields">
<h3><?php echo JText::_('K2_CATEGORY_ITEM_LAYOUT'); ?></h3>
<div id="catLayoutOptions">
<fieldset class="panelform">
<ul class="adminformlist">
<?php if(version_compare( JVERSION, '1.6.0', 'ge' )): ?>
<?php foreach ($this->form->getFieldset('category-item-layout') as $field): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if($field->type=='header'): ?>
<div class="paramValueHeader"><?php echo $field->input; ?></div>
<?php elseif($field->type=='Spacer'): ?>
<div class="paramValueSpacer">&nbsp;</div>
<div class="clr"></div>
<?php else: ?>
<div class="paramLabel"><?php echo $field->label; ?></div>
<div class="paramValue"><?php echo $field->input; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($this->form->getParams('params', 'category-item-layout') as $param): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if((string)$param[1]=='' || $param[5] == ''): ?>
<div class="paramValueHeader"><?php echo $param[1]; ?></div>
<?php else: ?>
<div class="paramLabel"><?php echo $param[0]; ?></div>
<div class="paramValue"><?php echo $param[1]; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
<h3><a href="#"><?php echo JText::_('K2_CATEGORY_VIEW_OPTIONS'); ?></a></h3>
<div id="catViewOptions">
<fieldset class="panelform">
<ul class="adminformlist">
<?php if(version_compare( JVERSION, '1.6.0', 'ge' )): ?>
<?php foreach ($this->form->getFieldset('category-view-options') as $field): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if($field->type=='header'): ?>
<div class="paramValueHeader"><?php echo $field->input; ?></div>
<?php elseif($field->type=='Spacer'): ?>
<div class="paramValueSpacer">&nbsp;</div>
<div class="clr"></div>
<?php else: ?>
<div class="paramLabel"><?php echo $field->label; ?></div>
<div class="paramValue"><?php echo $field->input; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($this->form->getParams('params', 'category-view-options') as $param): ?>
<li>
<?php if((string)$param[1]=='' || $param[5] == ''): ?>
<div class="paramValueHeader"><?php echo $param[1]; ?></div>
<?php else: ?>
<div class="paramLabel"><?php echo $param[0]; ?></div>
<div class="paramValue"><?php echo $param[1]; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
<h3><?php echo JText::_('K2_ITEM_IMAGE_OPTIONS'); ?></h3>
<div id="catImageOptions">
<fieldset class="panelform">
<ul class="adminformlist">
<?php if(version_compare( JVERSION, '1.6.0', 'ge' )): ?>
<?php foreach ($this->form->getFieldset('item-image-options') as $field): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if($field->type=='header'): ?>
<div class="paramValueHeader"><?php echo $field->input; ?></div>
<?php elseif($field->type=='Spacer'): ?>
<div class="paramValueSpacer">&nbsp;</div>
<div class="clr"></div>
<?php else: ?>
<div class="paramLabel"><?php echo $field->label; ?></div>
<div class="paramValue"><?php echo $field->input; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($this->form->getParams('params', 'item-image-options') as $param): ?>
<li>
<?php if((string)$param[1]=='' || $param[5] == ''): ?>
<div class="paramValueHeader"><?php echo $param[1]; ?></div>
<?php else: ?>
<div class="paramLabel"><?php echo $param[0]; ?></div>
<div class="paramValue"><?php echo $param[1]; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
<h3><?php echo JText::_('K2_ITEM_VIEW_OPTIONS_IN_CATEGORY_LISTINGS'); ?></h3>
<div id="catItemsOptions">
<fieldset class="panelform">
<ul class="adminformlist">
<?php if(version_compare( JVERSION, '1.6.0', 'ge' )): ?>
<?php foreach ($this->form->getFieldset('item-view-options-listings') as $field): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if($field->type=='header'): ?>
<div class="paramValueHeader"><?php echo $field->input; ?></div>
<?php elseif($field->type=='Spacer'): ?>
<div class="paramValueSpacer">&nbsp;</div>
<div class="clr"></div>
<?php else: ?>
<div class="paramLabel"><?php echo $field->label; ?></div>
<div class="paramValue"><?php echo $field->input; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($this->form->getParams('params', 'item-view-options-listings') as $param): ?>
<li>
<?php if((string)$param[1]=='' || $param[5] == ''): ?>
<div class="paramValueHeader"><?php echo $param[1]; ?></div>
<?php else: ?>
<div class="paramLabel"><?php echo $param[0]; ?></div>
<div class="paramValue"><?php echo $param[1]; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
<h3><?php echo JText::_('K2_ITEM_VIEW_OPTIONS'); ?></h3>
<div id="catItemOptions">
<fieldset class="panelform">
<ul class="adminformlist">
<?php if(version_compare( JVERSION, '1.6.0', 'ge' )): ?>
<?php foreach ($this->form->getFieldset('item-view-options') as $field): ?>
<li<?php if($field->type=='header') echo ' class="headerElement"';?>>
<?php if($field->type=='header'): ?>
<div class="paramValueHeader"><?php echo $field->input; ?></div>
<?php elseif($field->type=='Spacer'): ?>
<div class="paramValueSpacer">&nbsp;</div>
<div class="clr"></div>
<?php else: ?>
<div class="paramLabel"><?php echo $field->label; ?></div>
<div class="paramValue"><?php echo $field->input; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php else: ?>
<?php foreach($this->form->getParams('params', 'item-view-options') as $param): ?>
<li>
<?php if((string)$param[1]=='' || $param[5] == ''): ?>
<div class="paramValueHeader"><?php echo $param[1]; ?></div>
<?php else: ?>
<div class="paramLabel"><?php echo $param[0]; ?></div>
<div class="paramValue"><?php echo $param[1]; ?></div>
<div class="clr"></div>
<?php endif; ?>
</li>
<?php endforeach; ?>
<?php endif; ?>
</ul>
</fieldset>
</div>
</div><!-- END of the scrollable -->
</div><!-- END of the Display settings tab -->
</div>
<input type="hidden" name="id" value="<?php echo $this->row->id; ?>" />
<input type="hidden" name="option" value="com_k2" />
<input type="hidden" name="view" value="category" />
<input type="hidden" name="task" value="<?php echo JRequest::getVar('task'); ?>" />
<?php echo JHTML::_('form.token'); ?>
</form>

Some files were not shown because too many files have changed in this diff Show More