first commit

This commit is contained in:
alazhar
2020-01-02 22:20:31 +07:00
commit 10eb3340ad
5753 changed files with 631345 additions and 0 deletions

View File

@ -0,0 +1,28 @@
<?php
/**
* @version $Id: k2attachment.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
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,225 @@
<?php
/**
* @version $Id: k2category.php 1901 2013-02-08 19:29:12Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
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 > 1)
{
$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,35 @@
<?php
/**
* @version $Id: k2comment.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
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,39 @@
<?php
/**
* @version $Id: k2extrafield.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
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,35 @@
<?php
/**
* @version $Id: k2extrafieldsgroup.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
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,324 @@
<?php
/**
* @version $Id: k2item.php 1901 2013-02-08 19:29:12Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
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 > 1)
{
$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,100 @@
<?php
/**
* @version $Id: k2tag.php 1909 2013-02-08 21:02:38Z joomlaworks $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die ;
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 tag exists already for new tags
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,56 @@
<?php
/**
* @version $Id: k2user.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
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,51 @@
<?php
/**
* @version $Id: k2usergroup.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: http://www.gnu.org/copyleft/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
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 $Id: table.php 1812 2013-01-14 18:45:06Z lefteris.kavadas $
* @package K2
* @author JoomlaWorks http://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2013 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);
}
}
}