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,149 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Authentication.gmail
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* GMail Authentication Plugin
*
* @package Joomla.Plugin
* @subpackage Authentication.gmail
* @since 1.5
*/
class PlgAuthenticationGMail extends JPlugin
{
/**
* This method should handle any authentication and report back to the subject
*
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object &$response Authentication response object
*
* @return boolean
*
* @since 1.5
*/
public function onUserAuthenticate($credentials, $options, &$response)
{
$success = 0;
// Check if we have curl or not
if (function_exists('curl_init'))
{
// Check if we have a username and password
if (strlen($credentials['username']) && strlen($credentials['password']))
{
$blacklist = explode(',', $this->params->get('user_blacklist', ''));
// Check if the username isn't blacklisted
if (!in_array($credentials['username'], $blacklist))
{
$suffix = $this->params->get('suffix', '');
$applysuffix = $this->params->get('applysuffix', 0);
$offset = strpos($credentials['username'], '@');
// Check if we want to do suffix stuff, typically for Google Apps for Your Domain
if ($suffix && $applysuffix)
{
if ($applysuffix == 1 && $offset === false)
{
// Apply suffix if missing
$credentials['username'] .= '@' . $suffix;
}
elseif ($applysuffix == 2)
{
// Always use suffix
if ($offset)
{
// If we already have an @, get rid of it and replace it
$credentials['username'] = substr($credentials['username'], 0, $offset);
}
$credentials['username'] .= '@' . $suffix;
}
}
$curl = curl_init('https://mail.google.com/mail/feed/atom');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->params->get('verifypeer', 1));
//curl_setopt($curl, CURLOPT_HEADER, 1);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($curl, CURLOPT_USERPWD, $credentials['username'] . ':' . $credentials['password']);
curl_exec($curl);
$code = curl_getinfo($curl, CURLINFO_HTTP_CODE);
switch ($code)
{
case 200:
$message = JText::_('JGLOBAL_AUTH_ACCESS_GRANTED');
$success = 1;
break;
case 401:
$message = JText::_('JGLOBAL_AUTH_ACCESS_DENIED');
break;
default:
$message = JText::_('JGLOBAL_AUTH_UNKNOWN_ACCESS_DENIED');
break;
}
}
else
{
// The username is black listed
$message = 'User is blacklisted';
}
}
else
{
$message = JText::_('JGLOBAL_AUTH_USER_BLACKLISTED');
}
}
else
{
$message = 'curl isn\'t insalled';
}
$response->type = 'GMail';
if ($success)
{
$response->status = JAuthentication::STATUS_SUCCESS;
$response->error_message = '';
if (strpos($credentials['username'], '@') === false)
{
if ($suffix)
{
// If there is a suffix then we want to apply it
$response->email = $credentials['username'] . '@' . $suffix;
}
else
{
// If there isn't a suffix just use the default gmail one
$response->email = $credentials['username'] . '@gmail.com';
}
}
else
{
// The username looks like an email address (probably is) so use that
$response->email = $credentials['username'];
}
// Reset the username to what we ended up using
$response->username = $credentials['username'];
$response->fullname = $credentials['username'];
}
else
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::sprintf('JGLOBAL_AUTH_FAILED', $message);
}
}
}

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="authentication">
<name>plg_authentication_gmail</name>
<author>Joomla! Project</author>
<creationDate>February 2006</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_GMAIL_XML_DESCRIPTION</description>
<files>
<filename plugin="gmail">gmail.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_authentication_gmail.ini</language>
<language tag="en-GB">en-GB.plg_authentication_gmail.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="applysuffix" type="list"
default="0"
description="PLG_GMAIL_FIELD_APPLYSUFFIX_DESC"
label="PLG_GMAIL_FIELD_APPLYSUFFIX_LABEL"
>
<option value="0">PLG_GMAIL_FIELD_VALUE_NOAPPLYSUFFIX</option>
<option value="1">PLG_GMAIL_FIELD_VALUE_APPLYSUFFIXMISSING</option>
<option value="2">PLG_GMAIL_FIELD_VALUE_APPLYSUFFIXALWAYS</option>
</field>
<field name="suffix" type="text"
description="PLG_GMAIL_FIELD_SUFFIX_DESC"
label="PLG_GMAIL_FIELD_SUFFIX_LABEL"
size="20"
/>
<field name="verifypeer" type="radio"
default="1"
class="btn-group"
description="PLG_GMAIL_FIELD_VERIFYPEER_DESC"
label="PLG_GMAIL_FIELD_VERIFYPEER_LABEL"
>
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="user_blacklist" type="text"
description="PLG_GMAIL_FIELD_USER_BLACKLIST_DESC"
label="PLG_GMAIL_FIELD_USER_BLACKLIST_LABEL"
size="20"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,93 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Authentication.joomla
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla Authentication plugin
*
* @package Joomla.Plugin
* @subpackage Authentication.joomla
* @since 1.5
*/
class PlgAuthenticationJoomla extends JPlugin
{
/**
* This method should handle any authentication and report back to the subject
*
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object &$response Authentication response object
*
* @return boolean
*
* @since 1.5
*/
public function onUserAuthenticate($credentials, $options, &$response)
{
$response->type = 'Joomla';
// Joomla does not like blank passwords
if (empty($credentials['password']))
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_EMPTY_PASS_NOT_ALLOWED');
return false;
}
// Get a database object
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('id, password')
->from('#__users')
->where('username=' . $db->quote($credentials['username']));
$db->setQuery($query);
$result = $db->loadObject();
if ($result)
{
$parts = explode(':', $result->password);
$crypt = $parts[0];
$salt = @$parts[1];
$testcrypt = JUserHelper::getCryptedPassword($credentials['password'], $salt);
if ($crypt == $testcrypt)
{
// Bring this in line with the rest of the system
$user = JUser::getInstance($result->id);
$response->email = $user->email;
$response->fullname = $user->name;
if (JFactory::getApplication()->isAdmin())
{
$response->language = $user->getParam('admin_language');
}
else
{
$response->language = $user->getParam('language');
}
$response->status = JAuthentication::STATUS_SUCCESS;
$response->error_message = '';
}
else
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_INVALID_PASS');
}
}
else
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_NO_USER');
}
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="authentication">
<name>plg_authentication_joomla</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_AUTH_JOOMLA_XML_DESCRIPTION</description>
<files>
<filename plugin="joomla">joomla.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_authentication_joomla.ini</language>
<language tag="en-GB">en-GB.plg_authentication_joomla.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,160 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Authentication.ldap
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* LDAP Authentication Plugin
*
* @package Joomla.Plugin
* @subpackage Authentication.ldap
* @since 1.5
*/
class PlgAuthenticationLdap extends JPlugin
{
/**
* This method should handle any authentication and report back to the subject
*
* @param array $credentials Array holding the user credentials
* @param array $options Array of extra options
* @param object &$response Authentication response object
*
* @return boolean
*
* @since 1.5
*/
public function onUserAuthenticate($credentials, $options, &$response)
{
$userdetails = null;
$success = 0;
$userdetails = array();
// For JLog
$response->type = 'LDAP';
// LDAP does not like Blank passwords (tries to Anon Bind which is bad)
if (empty($credentials['password']))
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_PASS_BLANK');
return false;
}
// Load plugin params info
$ldap_email = $this->params->get('ldap_email');
$ldap_fullname = $this->params->get('ldap_fullname');
$ldap_uid = $this->params->get('ldap_uid');
$auth_method = $this->params->get('auth_method');
$ldap = new JClientLdap($this->params);
if (!$ldap->connect())
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_NO_CONNECT');
return;
}
switch ($auth_method)
{
case 'search':
{
// Bind using Connect Username/password
// Force anon bind to mitigate misconfiguration like [#7119]
if (strlen($this->params->get('username')))
{
$bindtest = $ldap->bind();
}
else
{
$bindtest = $ldap->anonymous_bind();
}
if ($bindtest)
{
// Search for users DN
$binddata = $ldap->simple_search(str_replace("[search]", $credentials['username'], $this->params->get('search_string')));
if (isset($binddata[0]) && isset($binddata[0]['dn']))
{
// Verify Users Credentials
$success = $ldap->bind($binddata[0]['dn'], $credentials['password'], 1);
// Get users details
$userdetails = $binddata;
}
else
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_USER_NOT_FOUND');
}
}
else
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_NO_BIND');
}
} break;
case 'bind':
{
// We just accept the result here
$success = $ldap->bind($credentials['username'], $credentials['password']);
if ($success)
{
$userdetails = $ldap->simple_search(str_replace("[search]", $credentials['username'], $this->params->get('search_string')));
}
else
{
$response->status = JAuthentication::STATUS_FAILURE;
$response->error_message = JText::_('JGLOBAL_AUTH_BIND_FAILED');
}
} break;
}
if (!$success)
{
$response->status = JAuthentication::STATUS_FAILURE;
if (!strlen($response->error_message))
{
$response->error_message = JText::_('JGLOBAL_AUTH_INCORRECT');
}
}
else
{
// Grab some details from LDAP and return them
if (isset($userdetails[0][$ldap_uid][0]))
{
$response->username = $userdetails[0][$ldap_uid][0];
}
if (isset($userdetails[0][$ldap_email][0]))
{
$response->email = $userdetails[0][$ldap_email][0];
}
if (isset($userdetails[0][$ldap_fullname][0]))
{
$response->fullname = $userdetails[0][$ldap_fullname][0];
} else {
$response->fullname = $credentials['username'];
}
// Were good - So say so.
$response->status = JAuthentication::STATUS_SUCCESS;
$response->error_message = '';
}
$ldap->close();
}
}

View File

@ -0,0 +1,132 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="authentication">
<name>plg_authentication_ldap</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_LDAP_XML_DESCRIPTION</description>
<files>
<filename plugin="ldap">ldap.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_authentication_ldap.ini</language>
<language tag="en-GB">en-GB.plg_authentication_ldap.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="host" type="text"
description="PLG_LDAP_FIELD_HOST_DESC"
label="PLG_LDAP_FIELD_HOST_LABEL"
size="20"
/>
<field name="port" type="text"
default="389"
description="PLG_LDAP_FIELD_PORT_DESC"
label="PLG_LDAP_FIELD_PORT_LABEL"
size="20"
/>
<field name="use_ldapV3" type="radio"
default="0"
class="btn-group"
description="PLG_LDAP_FIELD_V3_DESC"
label="PLG_LDAP_FIELD_V3_LABEL"
>
<option value="0">JNo</option>
<option value="1">JYes</option>
</field>
<field name="negotiate_tls" type="radio"
default="0"
class="btn-group"
description="PLG_LDAP_FIELD_NEGOCIATE_DESC"
label="PLG_LDAP_FIELD_NEGOCIATE_LABEL"
>
<option value="0">JNo</option>
<option value="1">JYes</option>
</field>
<field name="no_referrals" type="radio"
default="0"
class="btn-group"
description="PLG_LDAP_FIELD_REFERRALS_DESC"
label="PLG_LDAP_FIELD_REFERRALS_LABEL"
>
<option value="0">JNo</option>
<option value="1">JYes</option>
</field>
<field name="auth_method" type="list"
default="bind"
description="PLG_LDAP_FIELD_AUTHMETHOD_DESC"
label="PLG_LDAP_FIELD_AUTHMETHOD_LABEL"
>
<option value="search">PLG_LDAP_FIELD_VALUE_BINDSEARCH</option>
<option value="bind">PLG_LDAP_FIELD_VALUE_BINDUSER</option>
</field>
<field name="base_dn" type="text"
description="PLG_LDAP_FIELD_BASEDN_DESC"
label="PLG_LDAP_FIELD_BASEDN_LABEL"
size="20"
/>
<field name="search_string" type="text"
description="PLG_LDAP_FIELD_SEARCHSTRING_DESC"
label="PLG_LDAP_FIELD_SEARCHSTRING_LABEL"
size="20"
/>
<field name="users_dn" type="text"
description="PLG_LDAP_FIELD_USERSDN_DESC"
label="PLG_LDAP_FIELD_USERSDN_LABEL"
size="20"
/>
<field name="username" type="text"
description="PLG_LDAP_FIELD_USERNAME_DESC"
label="PLG_LDAP_FIELD_USERNAME_LABEL"
size="20"
/>
<field name="password" type="password"
description="PLG_LDAP_FIELD_PASSWORD_DESC"
label="PLG_LDAP_FIELD_PASSWORD_LABEL"
size="20"
/>
<field name="ldap_fullname" type="text"
default="fullName"
description="PLG_LDAP_FIELD_FULLNAME_DESC"
label="PLG_LDAP_FIELD_FULLNAME_LABEL"
size="20"
/>
<field name="ldap_email" type="text"
default="mail"
description="PLG_LDAP_FIELD_EMAIL_DESC"
label="PLG_LDAP_FIELD_EMAIL_LABEL"
size="20"
/>
<field name="ldap_uid" type="text"
default="uid"
description="PLG_LDAP_FIELD_UID_DESC"
label="PLG_LDAP_FIELD_UID_LABEL"
size="20"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,264 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Captcha
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Recaptcha Plugin.
* Based on the oficial recaptcha library( http://recaptcha.net/plugins/php/ )
*
* @package Joomla.Plugin
* @subpackage Captcha
* @since 2.5
*/
class PlgCaptchaRecaptcha extends JPlugin
{
const RECAPTCHA_API_SERVER = "http://api.recaptcha.net";
const RECAPTCHA_API_SECURE_SERVER = "https://www.google.com/recaptcha/api";
const RECAPTCHA_VERIFY_SERVER = "api-verify.recaptcha.net";
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Initialise the captcha
*
* @param string $id The id of the field.
*
* @return Boolean True on success, false otherwise
*
* @since 2.5
*/
public function onInit($id)
{
$document = JFactory::getDocument();
$app = JFactory::getApplication();
$lang = $this->_getLanguage();
$pubkey = $this->params->get('public_key', '');
$theme = $this->params->get('theme', 'clean');
if ($pubkey == null || $pubkey == '')
{
throw new Exception(JText::_('PLG_RECAPTCHA_ERROR_NO_PUBLIC_KEY'));
}
$server = self::RECAPTCHA_API_SERVER;
if ($app->isSSLConnection())
{
$server = self::RECAPTCHA_API_SECURE_SERVER;
}
JHtml::_('script', $server . '/js/recaptcha_ajax.js');
$document->addScriptDeclaration('window.addEvent(\'domready\', function()
{
Recaptcha.create("' . $pubkey . '", "dynamic_recaptcha_1", {theme: "' . $theme . '",' . $lang . 'tabindex: 0});});'
);
return true;
}
/**
* Gets the challenge HTML
*
* @param string $name The name of the field.
* @param string $id The id of the field.
* @param string $class The class of the field.
*
* @return string The HTML to be embedded in the form.
*
* @since 2.5
*/
public function onDisplay($name, $id, $class)
{
return '<div id="dynamic_recaptcha_1"></div>';
}
/**
* Calls an HTTP POST function to verify if the user's guess was correct
*
* @return True if the answer is correct, false otherwise
*
* @since 2.5
*/
public function onCheckAnswer($code)
{
$input = JFactory::getApplication()->input;
$privatekey = $this->params->get('private_key');
$remoteip = $input->server->get('REMOTE_ADDR', '', 'string');
$challenge = $input->get('recaptcha_challenge_field', '', 'string');
$response = $input->get('recaptcha_response_field', '', 'string');
// Check for Private Key
if (empty($privatekey))
{
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_NO_PRIVATE_KEY'));
return false;
}
// Check for IP
if (empty($remoteip))
{
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_NO_IP'));
return false;
}
// Discard spam submissions
if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0)
{
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_EMPTY_SOLUTION'));
return false;
}
$response = $this->_recaptcha_http_post(
self::RECAPTCHA_VERIFY_SERVER, "/verify",
array(
'privatekey' => $privatekey,
'remoteip' => $remoteip,
'challenge' => $challenge,
'response' => $response
)
);
$answers = explode("\n", $response[1]);
if (trim($answers[0]) == 'true')
{
return true;
}
else
{
// @todo use exceptions here
$this->_subject->setError(JText::_('PLG_RECAPTCHA_ERROR_' . strtoupper(str_replace('-', '_', $answers[1]))));
return false;
}
}
/**
* Encodes the given data into a query string format.
*
* @param string $data Array of string elements to be encoded
*
* @return string Encoded request
*
* @since 2.5
*/
private function _recaptcha_qsencode($data)
{
$req = "";
foreach ($data as $key => $value)
{
$req .= $key . '=' . urlencode(stripslashes($value)) . '&';
}
// Cut the last '&'
$req = rtrim($req, '&');
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
*
* @since 2.5
*/
private function _recaptcha_http_post($host, $path, $data, $port = 80)
{
$req = $this->_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 (($fs = @fsockopen($host, $port, $errno, $errstr, 10)) == false )
{
die('Could not open socket');
}
fwrite($fs, $http_request);
while (!feof($fs))
{
// One TCP-IP packet
$response .= fgets($fs, 1160);
}
fclose($fs);
$response = explode("\r\n\r\n", $response, 2);
return $response;
}
/**
* Get the language tag or a custom translation
*
* @return string
*
* @since 2.5
*/
private function _getLanguage()
{
$language = JFactory::getLanguage();
$tag = explode('-', $language->getTag());
$tag = $tag[0];
$available = array('en', 'pt', 'fr', 'de', 'nl', 'ru', 'es', 'tr');
if (in_array($tag, $available))
{
return "lang : '" . $tag . "',";
}
// If the default language is not available, let's search for a custom translation
if ($language->hasKey('PLG_RECAPTCHA_CUSTOM_LANG'))
{
$custom[] = 'custom_translations : {';
$custom[] = "\t" . 'instructions_visual : "' . JText::_('PLG_RECAPTCHA_INSTRUCTIONS_VISUAL') . '",';
$custom[] = "\t" . 'instructions_audio : "' . JText::_('PLG_RECAPTCHA_INSTRUCTIONS_AUDIO') . '",';
$custom[] = "\t" . 'play_again : "' . JText::_('PLG_RECAPTCHA_PLAY_AGAIN') . '",';
$custom[] = "\t" . 'cant_hear_this : "' . JText::_('PLG_RECAPTCHA_CANT_HEAR_THIS') . '",';
$custom[] = "\t" . 'visual_challenge : "' . JText::_('PLG_RECAPTCHA_VISUAL_CHALLENGE') . '",';
$custom[] = "\t" . 'audio_challenge : "' . JText::_('PLG_RECAPTCHA_AUDIO_CHALLENGE') . '",';
$custom[] = "\t" . 'refresh_btn : "' . JText::_('PLG_RECAPTCHA_REFRESH_BTN') . '",';
$custom[] = "\t" . 'help_btn : "' . JText::_('PLG_RECAPTCHA_HELP_BTN') . '",';
$custom[] = "\t" . 'incorrect_try_again : "' . JText::_('PLG_RECAPTCHA_INCORRECT_TRY_AGAIN') . '",';
$custom[] = '},';
$custom[] = "lang : '" . $tag . "',";
return implode("\n", $custom);
}
// If nothing helps fall back to english
return '';
}
}

View File

@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="captcha">
<name>plg_captcha_recaptcha</name>
<version>3.0.0</version>
<creationDate>December 2011</creationDate>
<author>Joomla! Project</author>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<description>PLG_CAPTCHA_RECAPTCHA_XML_DESCRIPTION</description>
<files>
<filename
plugin="recaptcha">recaptcha.php</filename>
</files>
<config>
<fields name="params">
<fieldset name="basic">
<field
name="public_key"
type="text"
default=""
label="PLG_RECAPTCHA_PUBLIC_KEY_LABEL"
description="PLG_RECAPTCHA_PUBLIC_KEY_DESC"
required="true"
filter="string"
size="50" />
<field
name="private_key"
type="text"
default=""
label="PLG_RECAPTCHA_PRIVATE_KEY_LABEL"
description="PLG_RECAPTCHA_PRIVATE_KEY_DESC"
required="true"
filter="string"
size="50" />
<field
name="theme"
type="list"
default="clean"
label="PLG_RECAPTCHA_THEME_LABEL"
description="PLG_RECAPTCHA_THEME_DESC"
required="true"
filter="">
<option
value="clean">PLG_RECAPTCHA_THEME_CLEAN</option>
<option
value="white">PLG_RECAPTCHA_THEME_WHITE</option>
<option
value="blackglass">PLG_RECAPTCHA_THEME_BLACKGLASS</option>
<option
value="red">PLG_RECAPTCHA_THEME_RED</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,299 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.emailcloak
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Email cloack plugin class.
*
* @package Joomla.Plugin
* @subpackage Content.emailcloak
* @since 1.5
*/
class PlgContentEmailcloak extends JPlugin
{
/**
* Plugin that cloaks all emails in content from spambots via Javascript.
*
* @param string $context The context of the content being passed to the plugin.
* @param mixed &$row An object with a "text" property or the string to be cloaked.
* @param mixed &$params Additional parameters. See {@see PlgContentEmailcloak()}.
* @param integer $page Optional page number. Unused. Defaults to zero.
*
* @return boolean True on success.
*/
public function onContentPrepare($context, &$row, &$params, $page = 0)
{
// Don't run this plugin when the content is being indexed
if ($context == 'com_finder.indexer')
{
return true;
}
if (is_object($row))
{
return $this->_cloak($row->text, $params);
}
return $this->_cloak($row, $params);
}
/**
* Generate a search pattern based on link and text.
*
* @param string $link The target of an email link.
* @param string $text The text enclosed by the link.
*
* @return string A regular expression that matches a link containing the parameters.
*/
protected function _getPattern ($link, $text)
{
$pattern = '~(?:<a ([\w "\'=\@\.\-:;]*)href\s*=\s*"mailto:'
. $link . '"([\w "\'=\@\.\-:;]*))>' . $text . '</a>~i';
return $pattern;
}
/**
* Adds an attributes to the js cloaked email.
*
* @param string $jsEmail Js cloaked email.
* @param string $before Attributes before email.
* @param string $after Attributes after email.
*
* @return string Js cloaked email with attributes.
*/
protected function _addAttributesToEmail($jsEmail, $before, $after)
{
if ($before !== "")
{
$before = str_replace("'", "\'", $before);
$jsEmail = str_replace("document.write('<a '", "document.write('<a {$before}'", $jsEmail);
}
if ($after !== "")
{
$after = str_replace("'", "\'", $after);
$jsEmail = str_replace("'\'>');", "'\'{$after}>');", $jsEmail);
}
return $jsEmail;
}
/**
* Cloak all emails in text from spambots via Javascript.
*
* @param string &$text The string to be cloaked.
* @param mixed &$params Additional parameters. Parameter "mode" (integer, default 1)
* replaces addresses with "mailto:" links if nonzero.
*
* @return boolean True on success.
*/
protected function _cloak(&$text, &$params)
{
/*
* Check for presence of {emailcloak=off} which is explicits disables this
* bot for the item.
*/
if (JString::strpos($text, '{emailcloak=off}') !== false)
{
$text = JString::str_ireplace('{emailcloak=off}', '', $text);
return true;
}
// Simple performance check to determine whether bot should process further.
if (JString::strpos($text, '@') === false)
{
return true;
}
$mode = $this->params->def('mode', 1);
// any@email.address.com
$searchEmail = '([\w\.\-]+\@(?:[a-z0-9\.\-]+\.)+(?:[a-zA-Z0-9\-]{2,10}))';
// any@email.address.com?subject=anyText
$searchEmailLink = $searchEmail . '([?&][\x20-\x7f][^"<>]+)';
// Any Text
$searchText = '([\x20-\x7f][^<>]+)';
// Any Image link
$searchImage = "(<img[^>]+>)";
/*
* Search and fix derivatives of link code <a href="http://mce_host/ourdirectory/email@amail.com"
* >email@email.com</a>. This happens when inserting an email in TinyMCE, cancelling its suggestion to add
* the mailto: prefix...
*/
$pattern = $this->_getPattern($searchEmail, $searchEmail);
$pattern = str_replace('"mailto:', '"http://mce_host([\x20-\x7f][^<>]+/)', $pattern);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[3][0];
$mailText = $regs[5][0];
// Check to see if mail text is different from mail addy
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[4][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
/*
* Search and fix derivatives of link code <a href="http://mce_host/ourdirectory/email@amail.com"
* >anytext</a>. This happens when inserting an email in TinyMCE, cancelling its suggestion to add
* the mailto: prefix...
*/
$pattern = $this->_getPattern($searchEmail, $searchText);
$pattern = str_replace('"mailto:', '"http://mce_host([\x20-\x7f][^<>]+/)', $pattern);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[3][0];
$mailText = $regs[5][0];
// Check to see if mail text is different from mail addy
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText, 0);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[4][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
/*
* Search for derivatives of link code <a href="mailto:email@amail.com"
* >email@amail.com</a>
*/
$pattern = $this->_getPattern($searchEmail, $searchEmail);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[2][0];
$mailText = $regs[4][0];
// Check to see if mail text is different from mail addy
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[3][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
/*
* Search for derivatives of link code <a href="mailto:email@amail.com">
* anytext</a>
*/
$pattern = $this->_getPattern($searchEmail, $searchText);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[2][0];
$mailText = $regs[4][0];
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText, 0);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[3][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
/*
* Search for derivatives of link code <a href="mailto:email@amail.com">
* <img anything></a>
*/
$pattern = $this->_getPattern($searchEmail, $searchImage);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[2][0];
$mailText = $regs[4][0];
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText, 0);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[3][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
/*
* Search for derivatives of link code <a href="mailto:email@amail.com?
* subject=Text">email@amail.com</a>
*/
$pattern = $this->_getPattern($searchEmailLink, $searchEmail);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[2][0] . $regs[3][0];
$mailText = $regs[5][0];
// Needed for handling of Body parameter
$mail = str_replace('&amp;', '&', $mail);
// Check to see if mail text is different from mail addy
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[4][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
/*
* Search for derivatives of link code <a href="mailto:email@amail.com?
* subject=Text">anytext</a>
*/
$pattern = $this->_getPattern($searchEmailLink, $searchText);
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[2][0] . $regs[3][0];
$mailText = $regs[5][0];
// Needed for handling of Body parameter
$mail = str_replace('&amp;', '&', $mail);
$replacement = JHtml::_('email.cloak', $mail, $mode, $mailText, 0);
// Ensure that attributes is not stripped out by email cloaking
$replacement = $this->_addAttributesToEmail($replacement, $regs[1][0], $regs[4][0]);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[0][1], strlen($regs[0][0]));
}
// Search for plain text email@amail.com
$pattern = '~' . $searchEmail . '([^a-z0-9]|$)~i';
while (preg_match($pattern, $text, $regs, PREG_OFFSET_CAPTURE))
{
$mail = $regs[1][0];
$replacement = JHtml::_('email.cloak', $mail, $mode);
// Replace the found address with the js cloaked email
$text = substr_replace($text, $replacement, $regs[1][1], strlen($mail));
}
return true;
}
}

View File

@ -0,0 +1,36 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_emailcloak</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_CONTENT_EMAILCLOAK_XML_DESCRIPTION</description>
<files>
<filename plugin="emailcloak">emailcloak.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_emailcloak.ini</language>
<language tag="en-GB">en-GB.plg_content_emailcloak.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="mode" type="list"
default="1"
description="PLG_CONTENT_EMAILCLOAK_MODE_DESC"
label="PLG_CONTENT_EMAILCLOAK_MODE_LABEL"
>
<option value="0">PLG_CONTENT_EMAILCLOAK_NONLINKABLE</option>
<option value="1">PLG_CONTENT_EMAILCLOAK_LINKABLE</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,120 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.finder
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Finder Content Plugin
*
* @package Joomla.Plugin
* @subpackage Content.finder
* @since 2.5
*/
class PlgContentFinder extends JPlugin
{
/**
* Finder after save content method
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
*
* @param string $context The context of the content passed to the plugin (added in 1.6)
* @param object $article A JTableContent object
* @param bool $isNew If the content has just been created
*
* @since 2.5
*/
public function onContentAfterSave($context, $article, $isNew)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderAfterSave event.
$dispatcher->trigger('onFinderAfterSave', array($context, $article, $isNew));
}
/**
* Finder before save content method
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
*
* @param string $context The context of the content passed to the plugin (added in 1.6)
* @param object $article A JTableContent object
* @param bool $isNew If the content is just about to be created
*
* @since 2.5
*/
public function onContentBeforeSave($context, $article, $isNew)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderBeforeSave event.
$dispatcher->trigger('onFinderBeforeSave', array($context, $article, $isNew));
}
/**
* Finder after delete content method
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
*
* @param string $context The context of the content passed to the plugin (added in 1.6)
* @param object $article A JTableContent object
*
* @since 2.5
*/
public function onContentAfterDelete($context, $article)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderAfterDelete event.
$dispatcher->trigger('onFinderAfterDelete', array($context, $article));
}
/**
* Finder change state content method
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @since 2.5
*/
public function onContentChangeState($context, $pks, $value)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderChangeState event.
$dispatcher->trigger('onFinderChangeState', array($context, $pks, $value));
}
/**
* Finder change category state content method
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
*
* @param string $extension The extension whose category has been updated.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @since 2.5
*/
public function onCategoryChangeState($extension, $pks, $value)
{
$dispatcher = JEventDispatcher::getInstance();
JPluginHelper::importPlugin('finder');
// Trigger the onFinderCategoryChangeState event.
$dispatcher->trigger('onFinderCategoryChangeState', array($extension, $pks, $value));
}
}

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_finder</name>
<author>Joomla! Project</author>
<creationDate>December 2011</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_CONTENT_FINDER_XML_DESCRIPTION</description>
<files>
<filename plugin="finder">finder.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_finder.ini</language>
<language tag="en-GB">en-GB.plg_content_finder.sys.ini</language>
</languages>
<config>
<fields name="params">
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,293 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.joomla
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Example Content Plugin
*
* @package Joomla.Plugin
* @subpackage Content.joomla
* @since 1.6
*/
class PlgContentJoomla extends JPlugin
{
/**
* Example after save content method
* Article is passed by reference, but after the save, so no changes will be saved.
* Method is called right after the content is saved
*
* @param string $context The context of the content passed to the plugin (added in 1.6)
* @param object $article A JTableContent object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean true if function not enabled, is in front-end or is new. Else true or
* false depending on success of save function.
*
* @since 1.6
*/
public function onContentAfterSave($context, $article, $isNew)
{
// Check we are handling the frontend edit form.
if ($context != 'com_content.form')
{
return true;
}
// Check if this function is enabled.
if (!$this->params->def('email_new_fe', 1))
{
return true;
}
// Check this is a new article.
if (!$isNew)
{
return true;
}
$user = JFactory::getUser();
// Messaging for new items
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/models', 'MessagesModel');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_messages/tables');
$db = JFactory::getDbo();
$db->setQuery('SELECT id FROM #__users WHERE sendEmail = 1');
$users = (array) $db->loadColumn();
$default_language = JComponentHelper::getParams('com_languages')->get('administrator');
$debug = JFactory::getConfig()->get('debug_lang');
foreach ($users as $user_id)
{
if ($user_id != $user->id)
{
// Load language for messaging
$receiver = JUser::getInstance($user_id);
$lang = JLanguage::getInstance($receiver->getParam('admin_language', $default_language), $debug);
$lang->load('com_content');
$message = array(
'user_id_to' => $user_id,
'subject' => $lang->_('COM_CONTENT_NEW_ARTICLE'),
'message' => sprintf($lang->_('COM_CONTENT_ON_NEW_CONTENT'), $user->get('name'), $article->title)
);
$model_message = JModelLegacy::getInstance('Message', 'MessagesModel');
$result = $model_message->save($message);
}
}
return $result;
}
/**
* Don't allow categories to be deleted if they contain items or subcategories with items
*
* @param string $context The context for the content passed to the plugin.
* @param object $data The data relating to the content that was deleted.
*
* @return boolean
*
* @since 1.6
*/
public function onContentBeforeDelete($context, $data)
{
// Skip plugin if we are deleting something other than categories
if ($context != 'com_categories.category')
{
return true;
}
// Check if this function is enabled.
if (!$this->params->def('check_categories', 1))
{
return true;
}
$extension = JFactory::getApplication()->input->getString('extension');
// Default to true if not a core extension
$result = true;
$tableInfo = array(
'com_banners' => array('table_name' => '#__banners'),
'com_contact' => array('table_name' => '#__contact_details'),
'com_content' => array('table_name' => '#__content'),
'com_newsfeeds' => array('table_name' => '#__newsfeeds'),
'com_weblinks' => array('table_name' => '#__weblinks')
);
// Now check to see if this is a known core extension
if (isset($tableInfo[$extension]))
{
// Get table name for known core extensions
$table = $tableInfo[$extension]['table_name'];
// See if this category has any content items
$count = $this->_countItemsInCategory($table, $data->get('id'));
// Return false if db error
if ($count === false)
{
$result = false;
}
else
{
// Show error if items are found in the category
if ($count > 0)
{
$msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) .
JText::plural('COM_CATEGORIES_N_ITEMS_ASSIGNED', $count);
JError::raiseWarning(403, $msg);
$result = false;
}
// Check for items in any child categories (if it is a leaf, there are no child categories)
if (!$data->isLeaf())
{
$count = $this->_countItemsInChildren($table, $data->get('id'), $data);
if ($count === false)
{
$result = false;
}
elseif ($count > 0)
{
$msg = JText::sprintf('COM_CATEGORIES_DELETE_NOT_ALLOWED', $data->get('title')) .
JText::plural('COM_CATEGORIES_HAS_SUBCATEGORY_ITEMS', $count);
JError::raiseWarning(403, $msg);
$result = false;
}
}
}
return $result;
}
}
/**
* Get count of items in a category
*
* @param string $table table name of component table (column is catid)
* @param integer $catid id of the category to check
*
* @return mixed count of items found or false if db error
*
* @since 1.6
*/
private function _countItemsInCategory($table, $catid)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true);
// Count the items in this category
$query->select('COUNT(id)')
->from($table)
->where('catid = ' . $catid);
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
return $count;
}
/**
* Get count of items in a category's child categories
*
* @param string $table table name of component table (column is catid)
* @param integer $catid id of the category to check
* @param object $data The data relating to the content that was deleted.
*
* @return mixed count of items found or false if db error
*
* @since 1.6
*/
private function _countItemsInChildren($table, $catid, $data)
{
$db = JFactory::getDbo();
// Create subquery for list of child categories
$childCategoryTree = $data->getTree();
// First element in tree is the current category, so we can skip that one
unset($childCategoryTree[0]);
$childCategoryIds = array();
foreach ($childCategoryTree as $node)
{
$childCategoryIds[] = $node->id;
}
// Make sure we only do the query if we have some categories to look in
if (count($childCategoryIds))
{
// Count the items in this category
$query = $db->getQuery(true)
->select('COUNT(id)')
->from($table)
->where('catid IN (' . implode(',', $childCategoryIds) . ')');
$db->setQuery($query);
try
{
$count = $db->loadResult();
}
catch (RuntimeException $e)
{
JError::raiseWarning(500, $e->getMessage());
return false;
}
return $count;
}
else
// If we didn't have any categories to check, return 0
{
return 0;
}
}
/**
* Change the state in core_content if the state in a table is changed
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return boolean
*
* @since 3.1
*/
public function onContentChangeState($context, $pks, $value)
{
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select($db->quoteName('core_content_id'))
->from($db->quoteName('#__ucm_content'))
->where($db->quoteName('core_type_alias') . ' = ' . $db->quote($context))
->where($db->quoteName('core_content_item_id') . ' IN (' . $pksImploded = implode(',', $pks) . ')');
$db->setQuery($query);
$ccIds = $db->loadColumn();
$cctable = new JTableCorecontent($db);
$cctable->publish($ccIds, $value);
return true;
}
}

View File

@ -0,0 +1,47 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_joomla</name>
<author>Joomla! Project</author>
<creationDate>November 2010</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_CONTENT_JOOMLA_XML_DESCRIPTION</description>
<files>
<filename plugin="joomla">joomla.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_joomla.ini</language>
<language tag="en-GB">en-GB.plg_content_joomla.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="check_categories"
type="radio"
class="btn-group"
default="1"
description="PLG_CONTENT_JOOMLA_FIELD_CHECK_CATEGORIES_DESC"
label="PLG_CONTENT_JOOMLA_FIELD_CHECK_CATEGORIES_LABEL">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
<field name="email_new_fe"
type="radio"
class="btn-group"
default="1"
description="PLG_CONTENT_JOOMLA_FIELD_EMAIL_NEW_FE_DESC"
label="PLG_CONTENT_JOOMLA_FIELD_EMAIL_NEW_FE_LABEL">
<option value="0">JNO</option>
<option value="1">JYES</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,189 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.loadmodule
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Plug-in to enable loading modules into content (e.g. articles)
* This uses the {loadmodule} syntax
*
* @package Joomla.Plugin
* @subpackage Content.loadmodule
* @since 1.5
*/
class PlgContentLoadmodule extends JPlugin
{
protected static $modules = array();
protected static $mods = array();
/**
* Plugin that loads module positions within content
*
* @param string $context The context of the content being passed to the plugin.
* @param object &$article The article object. Note $article->text is also available
* @param mixed &$params The article params
* @param integer $page The 'page' number
*
* @return mixed true if there is an error. Void otherwise.
*
* @since 1.6
*/
public function onContentPrepare($context, &$article, &$params, $page = 0)
{
// Don't run this plugin when the content is being indexed
if ($context == 'com_finder.indexer')
{
return true;
}
// Simple performance check to determine whether bot should process further
if (strpos($article->text, 'loadposition') === false && strpos($article->text, 'loadmodule') === false)
{
return true;
}
// Expression to search for (positions)
$regex = '/{loadposition\s(.*?)}/i';
$style = $this->params->def('style', 'none');
// Expression to search for(modules)
$regexmod = '/{loadmodule\s(.*?)}/i';
$stylemod = $this->params->def('style', 'none');
// Find all instances of plugin and put in $matches for loadposition
// $matches[0] is full pattern match, $matches[1] is the position
preg_match_all($regex, $article->text, $matches, PREG_SET_ORDER);
// No matches, skip this
if ($matches)
{
foreach ($matches as $match)
{
$matcheslist = explode(',', $match[1]);
// We may not have a module style so fall back to the plugin default.
if (!array_key_exists(1, $matcheslist))
{
$matcheslist[1] = $style;
}
$position = trim($matcheslist[0]);
$style = trim($matcheslist[1]);
$output = $this->_load($position, $style);
// We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
$article->text = preg_replace("|$match[0]|", addcslashes($output, '\\$'), $article->text, 1);
$style = $this->params->def('style', 'none');
}
}
// Find all instances of plugin and put in $matchesmod for loadmodule
preg_match_all($regexmod, $article->text, $matchesmod, PREG_SET_ORDER);
// If no matches, skip this
if ($matchesmod)
{
foreach ($matchesmod as $matchmod)
{
$matchesmodlist = explode(',', $matchmod[1]);
// We may not have a specific module so set to null
if (!array_key_exists(1, $matchesmodlist))
{
$matchesmodlist[1] = null;
}
// We may not have a module style so fall back to the plugin default.
if (!array_key_exists(2, $matchesmodlist))
{
$matchesmodlist[2] = $stylemod;
}
$module = trim($matchesmodlist[0]);
$name = htmlspecialchars_decode(trim($matchesmodlist[1]));
$stylemod = trim($matchesmodlist[2]);
// $match[0] is full pattern match, $match[1] is the module,$match[2] is the title
$output = $this->_loadmod($module, $name, $stylemod);
// We should replace only first occurrence in order to allow positions with the same name to regenerate their content:
$article->text = preg_replace("|$matchmod[0]|", addcslashes($output, '\\$'), $article->text, 1);
$stylemod = $this->params->def('style', 'none');
}
}
}
/**
* Loads and renders the module
*
* @param string $position The position assigned to the module
* @param string $style The style assigned to the module
*
* @return mixed
*
* @since 1.6
*/
protected function _load($position, $style = 'none')
{
self::$modules[$position] = '';
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$modules = JModuleHelper::getModules($position);
$params = array('style' => $style);
ob_start();
foreach ($modules as $module)
{
echo $renderer->render($module, $params);
}
self::$modules[$position] = ob_get_clean();
return self::$modules[$position];
}
/**
* This is always going to get the first instance of the module type unless
* there is a title.
*
* @param string $module The module title
* @param string $title The title of the module
* @param string $style The style of the module
*
* @return mixed
*
* @since 1.6
*/
protected function _loadmod($module, $title, $style = 'none')
{
self::$mods[$module] = '';
$document = JFactory::getDocument();
$renderer = $document->loadRenderer('module');
$mod = JModuleHelper::getModule($module, $title);
// If the module without the mod_ isn't found, try it with mod_.
// This allows people to enter it either way in the content
if (!isset($mod))
{
$name = 'mod_'.$module;
$mod = JModuleHelper::getModule($name, $title);
}
$params = array('style' => $style);
ob_start();
echo $renderer->render($mod, $params);
self::$mods[$module] = ob_get_clean();
return self::$mods[$module];
}
}

View File

@ -0,0 +1,38 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_loadmodule</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_LOADMODULE_XML_DESCRIPTION</description>
<files>
<filename plugin="loadmodule">loadmodule.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_loadmodule.ini</language>
<language tag="en-GB">en-GB.plg_content_loadmodule.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="style" type="list"
default="table"
description="PLG_LOADMODULE_FIELD_STYLE_DESC"
label="PLG_LOADMODULE_FIELD_STYLE_LABEL">
<option value="table">PLG_LOADMODULE_FIELD_VALUE_TABLE</option>
<option value="horz">PLG_LOADMODULE_FIELD_VALUE_HORIZONTAL</option>
<option value="xhtml">PLG_LOADMODULE_FIELD_VALUE_DIVS</option>
<option value="rounded">PLG_LOADMODULE_FIELD_VALUE_MULTIPLEDIVS</option>
<option value="none">PLG_LOADMODULE_FIELD_VALUE_RAW</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,397 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.pagebreak
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
jimport('joomla.utilities.utility');
/**
* Page break plugin
*
* <b>Usage:</b>
* <code><hr class="system-pagebreak" /></code>
* <code><hr class="system-pagebreak" title="The page title" /></code>
* or
* <code><hr class="system-pagebreak" alt="The first page" /></code>
* or
* <code><hr class="system-pagebreak" title="The page title" alt="The first page" /></code>
* or
* <code><hr class="system-pagebreak" alt="The first page" title="The page title" /></code>
*
* @package Joomla.Plugin
* @subpackage Content.pagebreak
* @since 1.6
*/
class PlgContentPagebreak extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Plugin that adds a pagebreak into the text and truncates text at that point
*
* @param string $context The context of the content being passed to the plugin.
* @param object &$row The article object. Note $article->text is also available
* @param mixed &$params The article params
* @param integer $page The 'page' number
*
* @return mixed Always returns void or true
*
* @since 1.6
*/
public function onContentPrepare($context, &$row, &$params, $page = 0)
{
$canProceed = $context == 'com_content.article';
if (!$canProceed)
{
return;
}
$style = $this->params->get('style', 'pages');
// Expression to search for.
$regex = '#<hr(.*)class="system-pagebreak"(.*)\/>#iU';
$input = JFactory::getApplication()->input;
$print = $input->getBool('print');
$showall = $input->getBool('showall');
if (!$this->params->get('enabled', 1))
{
$print = true;
}
if ($print)
{
$row->text = preg_replace($regex, '<br />', $row->text);
return true;
}
// Simple performance check to determine whether bot should process further.
if (JString::strpos($row->text, 'class="system-pagebreak') === false)
{
return true;
}
$view = $input->getString('view');
$full = $input->getBool('fullview');
if (!$page)
{
$page = 0;
}
if ($params->get('intro_only') || $params->get('popup') || $full || $view != 'article')
{
$row->text = preg_replace($regex, '', $row->text);
return;
}
// Find all instances of plugin and put in $matches.
$matches = array();
preg_match_all($regex, $row->text, $matches, PREG_SET_ORDER);
if (($showall && $this->params->get('showall', 1)))
{
$hasToc = $this->params->get('multipage_toc', 1);
if ($hasToc)
{
// Display TOC.
$page = 1;
$this->_createToc($row, $matches, $page);
}
else
{
$row->toc = '';
}
$row->text = preg_replace($regex, '<br />', $row->text);
return true;
}
// Split the text around the plugin.
$text = preg_split($regex, $row->text);
// Count the number of pages.
$n = count($text);
// We have found at least one plugin, therefore at least 2 pages.
if ($n > 1)
{
$title = $this->params->get('title', 1);
$hasToc = $this->params->get('multipage_toc', 1);
// Adds heading or title to <site> Title.
if ($title)
{
if ($page)
{
if ($page && @$matches[$page - 1][2])
{
$attrs = JUtility::parseAttributes($matches[$page - 1][1]);
if (@$attrs['title'])
{
$row->page_title = $attrs['title'];
}
}
}
}
// Reset the text, we already hold it in the $text array.
$row->text = '';
if ($style == 'pages')
{
// Display TOC.
if ($hasToc)
{
$this->_createToc($row, $matches, $page);
}
else
{
$row->toc = '';
}
// Traditional mos page navigation
$pageNav = new JPagination($n, $page, 1);
// Page counter.
$row->text .= '<div class="pagenavcounter">';
$row->text .= $pageNav->getPagesCounter();
$row->text .= '</div>';
// Page text.
$text[$page] = str_replace('<hr id="system-readmore" />', '', $text[$page]);
$row->text .= $text[$page];
// $row->text .= '<br />';
$row->text .= '<div class="pager">';
// Adds navigation between pages to bottom of text.
if ($hasToc)
{
$this->_createNavigation($row, $page, $n);
}
// Page links shown at bottom of page if TOC disabled.
if (!$hasToc)
{
$row->text .= $pageNav->getPagesLinks();
}
$row->text .= '</div>';
}
else
{
$t[] = $text[0];
$t[] = (string) JHtml::_($style . '.start', 'article' . $row->id . '-' . $style);
foreach ($text as $key => $subtext)
{
if ($key >= 1)
{
$match = $matches[$key - 1];
$match = (array) JUtility::parseAttributes($match[0]);
if (isset($match['alt']))
{
$title = stripslashes($match['alt']);
}
elseif (isset($match['title']))
{
$title = stripslashes($match['title']);
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $key + 1);
}
$t[] = (string) JHtml::_($style . '.panel', $title, 'article' . $row->id . '-' . $style . $key);
}
$t[] = (string) $subtext;
}
$t[] = (string) JHtml::_($style . '.end');
$row->text = implode(' ', $t);
}
}
return true;
}
/**
* Creates a Table of Contents for the pagebreak
*
* @param object &$row The article object. Note $article->text is also available
* @param array &$matches Array of matches of a regex in onContentPrepare
* @param integer &$page The 'page' number
*
* @return void
*
* @since 1.6
*/
protected function _createTOC(&$row, &$matches, &$page)
{
$heading = isset($row->title) ? $row->title : JText::_('PLG_CONTENT_PAGEBREAK_NO_TITLE');
$input = JFactory::getApplication()->input;
$limitstart = $input->getUInt('limitstart', 0);
$showall = $input->getInt('showall', 0);
// TOC header.
$row->toc .= '<div class="pull-right article-index">';
if ($this->params->get('article_index') == 1)
{
$headingtext = JText::_('PLG_CONTENT_PAGEBREAK_ARTICLE_INDEX');
if ($this->params->get('article_index_text'))
{
htmlspecialchars($headingtext = $this->params->get('article_index_text'));
}
$row->toc .= '<h3>' . $headingtext . '</h3>';
}
// TOC first Page link.
$class = ($limitstart === 0 && $showall === 0) ? 'toclink active' : 'toclink';
$row->toc .= '<ul class="nav nav-tabs nav-stacked">
<li class="' . $class . '">
<a href="' . JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=') . '" class="' . $class . '">'
. $heading .
'</a>
</li>
';
$i = 2;
foreach ($matches as $bot)
{
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($i - 1));
if (@$bot[0])
{
$attrs2 = JUtility::parseAttributes($bot[0]);
if (@$attrs2['alt'])
{
$title = stripslashes($attrs2['alt']);
}
elseif (@$attrs2['title'])
{
$title = stripslashes($attrs2['title']);
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}
}
else
{
$title = JText::sprintf('PLG_CONTENT_PAGEBREAK_PAGE_NUM', $i);
}
$class = ($limitstart == $i - 1) ? 'toclink active' : 'toclink';
$row->toc .= '
<li>
<a href="' . $link . '" class="' . $class . '">'
. $title .
'</a>
</li>
';
$i++;
}
if ($this->params->get('showall'))
{
$link = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=1&limitstart=');
$class = ($showall == 1) ? 'toclink active' : 'toclink';
$row->toc .= '
<li>
<a href="' . $link . '" class="' . $class . '">'
. JText::_('PLG_CONTENT_PAGEBREAK_ALL_PAGES') .
'</a>
</li>
';
}
$row->toc .= '</ul></div>';
}
/**
* Creates the navigation for the item
*
* @param object &$row The article object. Note $article->text is also available
* @param int $page The total number of pages
* @param int $n The page number
*
* @return void
*
* @since 1.6
*/
protected function _createNavigation(&$row, $page, $n)
{
$pnSpace = '';
if (JText::_('JGLOBAL_LT') || JText::_('JGLOBAL_LT'))
{
$pnSpace = ' ';
}
if ($page < $n - 1)
{
$page_next = $page + 1;
$link_next = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($page_next));
// Next >>
$next = '<a href="' . $link_next . '">' . JText::_('JNEXT') . $pnSpace . JText::_('JGLOBAL_GT') . JText::_('JGLOBAL_GT') . '</a>';
}
else
{
$next = JText::_('JNEXT');
}
if ($page > 0)
{
$page_prev = $page - 1 == 0 ? '' : $page - 1;
$link_prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->slug, $row->catid) . '&showall=&limitstart=' . ($page_prev));
// << Prev
$prev = '<a href="' . $link_prev . '">' . JText::_('JGLOBAL_LT') . JText::_('JGLOBAL_LT') . $pnSpace . JText::_('JPREV') . '</a>';
}
else
{
$prev = JText::_('JPREV');
}
$row->text .= '<ul><li>' . $prev . ' </li><li>' . $next . '</li></ul>';
}
}

View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_pagebreak</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_CONTENT_PAGEBREAK_XML_DESCRIPTION</description>
<files>
<filename plugin="pagebreak">pagebreak.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_pagebreak.ini</language>
<language tag="en-GB">en-GB.plg_content_pagebreak.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="title" type="radio"
class="btn-group"
default="1"
description="PLG_CONTENT_PAGEBREAK_SITE_TITLE_DESC"
label="PLG_CONTENT_PAGEBREAK_SITE_TITLE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="article_index" type="radio"
class="btn-group"
default="1"
description="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEX_DESC"
label="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEX_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="article_index_text" type="text" default=""
label="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEXTEXT"
description="PLG_CONTENT_PAGEBREAK_SITE_ARTICLEINDEXTEXT_DESC" />
<field name="multipage_toc" type="radio"
class="btn-group"
default="1"
description="PLG_CONTENT_PAGEBREAK_TOC_DESC"
label="PLG_CONTENT_PAGEBREAK_TOC_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="showall" type="radio"
class="btn-group"
default="1"
description="PLG_CONTENT_PAGEBREAK_SHOW_ALL_DESC"
label="PLG_CONTENT_PAGEBREAK_SHOW_ALL_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="style" type="list"
default="pages"
description="PLG_CONTENT_PAGEBREAK_STYLE_DESC"
label="PLG_CONTENT_PAGEBREAK_STYLE_LABEL"
>
<option value="pages">PLG_CONTENT_PAGEBREAK_PAGES</option>
<option value="sliders">PLG_CONTENT_PAGEBREAK_SLIDERS</option>
<option value="tabs">PLG_CONTENT_PAGEBREAK_TABS</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,232 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.pagenavigation
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Pagenavigation plugin class.
*
* @package Joomla.Plugin
* @subpackage Content.pagenavigation
* @since 1.5
*/
class PlgContentPagenavigation extends JPlugin
{
/**
* If in the article view and the parameter is enabled shows the page navigation
*
* @param string $context The context of the content being passed to the plugin
* @param object &$row The article object
* @param mixed &$params The article params
* @param integer $page The 'page' number
*
* @return mixed void or true
*
* @since 1.6
*/
public function onContentBeforeDisplay($context, &$row, &$params, $page = 0)
{
$app = JFactory::getApplication();
$view = $app->input->get('view');
$print = $app->input->getBool('print');
if ($print)
{
return false;
}
if (($context == 'com_content.article') && ($view == 'article') && $params->get('show_item_navigation'))
{
$db = JFactory::getDbo();
$user = JFactory::getUser();
$lang = JFactory::getLanguage();
$nullDate = $db->getNullDate();
$date = JFactory::getDate();
$now = $date->toSql();
$uid = $row->id;
$option = 'com_content';
$canPublish = $user->authorise('core.edit.state', $option . '.article.' . $row->id);
/**
* The following is needed as different menu items types utilise a different param to control ordering.
* For Blogs the `orderby_sec` param is the order controlling param.
* For Table and List views it is the `orderby` param.
**/
$params_list = $params->toArray();
if (array_key_exists('orderby_sec', $params_list))
{
$order_method = $params->get('orderby_sec', '');
}
else
{
$order_method = $params->get('orderby', '');
}
// Additional check for invalid sort ordering.
if ($order_method == 'front')
{
$order_method = '';
}
// Determine sort order.
switch ($order_method)
{
case 'date' :
$orderby = 'a.created';
break;
case 'rdate' :
$orderby = 'a.created DESC';
break;
case 'alpha' :
$orderby = 'a.title';
break;
case 'ralpha' :
$orderby = 'a.title DESC';
break;
case 'hits' :
$orderby = 'a.hits';
break;
case 'rhits' :
$orderby = 'a.hits DESC';
break;
case 'order' :
$orderby = 'a.ordering';
break;
case 'author' :
$orderby = 'a.created_by_alias, u.name';
break;
case 'rauthor' :
$orderby = 'a.created_by_alias DESC, u.name DESC';
break;
case 'front' :
$orderby = 'f.ordering';
break;
default :
$orderby = 'a.ordering';
break;
}
$xwhere = ' AND (a.state = 1 OR a.state = -1)' .
' AND (publish_up = ' . $db->quote($nullDate) . ' OR publish_up <= ' . $db->quote($now) . ')' .
' AND (publish_down = ' . $db->quote($nullDate) . ' OR publish_down >= ' . $db->quote($now) . ')';
// Array of articles in same category correctly ordered.
$query = $db->getQuery(true);
// Sqlsrv changes
$case_when = ' CASE WHEN ';
$case_when .= $query->charLength('a.alias', '!=', '0');
$case_when .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when .= ' ELSE ';
$case_when .= $a_id . ' END as slug';
$case_when1 = ' CASE WHEN ';
$case_when1 .= $query->charLength('cc.alias', '!=', '0');
$case_when1 .= ' THEN ';
$c_id = $query->castAsChar('cc.id');
$case_when1 .= $query->concatenate(array($c_id, 'cc.alias'), ':');
$case_when1 .= ' ELSE ';
$case_when1 .= $c_id . ' END as catslug';
$query->select('a.id,' . $case_when . ',' . $case_when1)
->from('#__content AS a')
->join('LEFT', '#__categories AS cc ON cc.id = a.catid')
->where(
'a.catid = ' . (int) $row->catid . ' AND a.state = ' . (int) $row->state
. ($canPublish ? '' : ' AND a.access = ' . (int) $row->access) . $xwhere
);
$query->order($orderby);
if ($app->isSite() && $app->getLanguageFilter())
{
$query->where('a.language in (' . $db->quote($lang->getTag()) . ',' . $db->quote('*') . ')');
}
$db->setQuery($query);
$list = $db->loadObjectList('id');
// This check needed if incorrect Itemid is given resulting in an incorrect result.
if (!is_array($list))
{
$list = array();
}
reset($list);
// Location of current content item in array list.
$location = array_search($uid, array_keys($list));
$rows = array_values($list);
$row->prev = null;
$row->next = null;
if ($location - 1 >= 0)
{
// The previous content item cannot be in the array position -1.
$row->prev = $rows[$location - 1];
}
if (($location + 1) < count($rows))
{
// The next content item cannot be in an array position greater than the number of array postions.
$row->next = $rows[$location + 1];
}
// $pnSpace is/can be used in the include file
$pnSpace = "";
if (JText::_('JGLOBAL_LT') || JText::_('JGLOBAL_GT'))
{
$pnSpace = " ";
}
if ($row->prev)
{
$row->prev = JRoute::_(ContentHelperRoute::getArticleRoute($row->prev->slug, $row->prev->catslug));
}
else
{
$row->prev = '';
}
if ($row->next)
{
$row->next = JRoute::_(ContentHelperRoute::getArticleRoute($row->next->slug, $row->next->catslug));
}
else
{
$row->next = '';
}
// Output.
if ($row->prev || $row->next)
{
// Get the path for the layout file
$path = JPluginHelper::getLayoutPath('content', 'pagenavigation');
// Render the pagenav
ob_start();
include $path;
$row->pagination = ob_get_clean();
$row->paginationposition = $this->params->get('position', 1);
// This will default to the 1.5 and 1.6-1.7 behavior.
$row->paginationrelative = $this->params->get('relative', 0);
}
}
return;
}
}

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_pagenavigation</name>
<author>Joomla! Project</author>
<creationDate>January 2006</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_PAGENAVIGATION_XML_DESCRIPTION</description>
<files>
<filename plugin="pagenavigation">pagenavigation.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_pagenavigation.ini</language>
<language tag="en-GB">en-GB.plg_content_pagenavigation.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="position" type="list"
default="1"
description="PLG_PAGENAVIGATION_FIELD_POSITION_DESC"
label="PLG_PAGENAVIGATION_FIELD_POSITION_LABEL"
>
<option value="1">PLG_PAGENAVIGATION_FIELD_VALUE_BELOW</option>
<option value="0">PLG_PAGENAVIGATION_FIELD_VALUE_ABOVE</option>
</field>
<field name="relative" type="list"
default="1"
description="PLG_PAGENAVIGATION_FIELD_RELATIVE_DESC"
label="PLG_PAGENAVIGATION_FIELD_RELATIVE_LABEL"
>
<option value="1">PLG_PAGENAVIGATION_FIELD_VALUE_ARTICLE</option>
<option value="0">PLG_PAGENAVIGATION_FIELD_VALUE_TEXT</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1,23 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.pagenavigation
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
?>
<ul class="pager pagenav">
<?php if ($row->prev) : ?>
<li class="previous">
<a href="<?php echo $row->prev; ?>" rel="prev"><?php echo JText::_('JGLOBAL_LT') . $pnSpace . JText::_('JPREV'); ?></a>
</li>
<?php endif; ?>
<?php if ($row->next) : ?>
<li class="next">
<a href="<?php echo $row->next; ?>" rel="next"><?php echo JText::_('JNEXT') . $pnSpace . JText::_('JGLOBAL_GT'); ?></a>
</li>
<?php endif; ?>
</ul>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,101 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Content.vote
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Vote plugin.
*
* @package Joomla.Plugin
* @subpackage Content.vote
* @since 1.5
*/
class PlgContentVote extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Displays the voting area if in an article
*
* @param string $context The context of the content being passed to the plugin
* @param object &$row The article object
* @param object &$params The article params
* @param integer $page The 'page' number
*
* @return string html string containing code for the votes
*
* @since 1.6
*/
public function onContentBeforeDisplay($context, &$row, &$params, $page=0)
{
$html = '';
if (!empty($params) && $params->get('show_vote', null))
{
$rating = (int) @$row->rating;
$view = JFactory::getApplication()->input->getString('view', '');
$img = '';
// Look for images in template if available
$starImageOn = JHtml::_('image', 'system/rating_star.png', JText::_('PLG_VOTE_STAR_ACTIVE'), null, true);
$starImageOff = JHtml::_('image', 'system/rating_star_blank.png', JText::_('PLG_VOTE_STAR_INACTIVE'), null, true);
for ($i = 0; $i < $rating; $i++)
{
$img .= $starImageOn;
}
for ($i = $rating; $i < 5; $i++)
{
$img .= $starImageOff;
}
$html .= '<div class="content_rating">';
$html .= '<p class="unseen element-invisible">' . JText::sprintf('PLG_VOTE_USER_RATING', $rating, '5') . '</p>';
$html .= $img;
$html .= '</div>';
if ($view == 'article' && $row->state == 1)
{
$uri = JUri::getInstance();
$uri->setQuery($uri->getQuery() . '&hitcount=0');
// Create option list for voting select box
$options = array();
for ($i = 1; $i < 6; $i++)
{
$options[] = JHTML::_('select.option', $i, JText::sprintf('PLG_VOTE_VOTE', $i));
}
// Generate voting form
$html .= '<form method="post" action="' . htmlspecialchars($uri->toString()) . '" class="form-inline">';
$html .= '<span class="content_vote">';
$html .= '<label class="unseen element-invisible" for="content_vote_' . $row->id . '">' . JText::_('PLG_VOTE_LABEL') . '</label>';
$html .= JHTML::_('select.genericlist', $options, 'user_rating', null, 'value', 'text', '5', 'content_vote_' . $row->id);
$html .= '&#160;<input class="btn btn-mini" type="submit" name="submit_vote" value="' . JText::_('PLG_VOTE_RATE') . '" />';
$html .= '<input type="hidden" name="task" value="article.vote" />';
$html .= '<input type="hidden" name="hitcount" value="0" />';
$html .= '<input type="hidden" name="url" value="' . htmlspecialchars($uri->toString()) . '" />';
$html .= JHtml::_('form.token');
$html .= '</span>';
$html .= '</form>';
}
}
return $html;
}
}

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="content">
<name>plg_content_vote</name>
<author>Joomla! Project</author>
<creationDate>November 2005</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_VOTE_XML_DESCRIPTION</description>
<files>
<filename plugin="vote">vote.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_content_vote.ini</language>
<language tag="en-GB">en-GB.plg_content_vote.sys.ini</language>
</languages>
<config>
<fields name="params">
</fields>
</config>
</extension>

View File

@ -0,0 +1,78 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.article
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Editor Article buton
*
* @package Joomla.Plugin
* @subpackage Editors-xtd.article
* @since 1.5
*/
class PlgButtonArticle extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Display the button
*
* @param string $name The name of the button to add
*
* @return array A four element array of (article_id, article_title, category_id, object)
*/
public function onDisplay($name)
{
/*
* Javascript to insert the link
* View element calls jSelectArticle when an article is clicked
* jSelectArticle creates the link tag, sends it to the editor,
* and closes the select frame.
*/
$js = "
function jSelectArticle(id, title, catid, object, link, lang)
{
var hreflang = '';
if (lang !== '')
{
var hreflang = ' hreflang = \"' + lang + '\"';
}
var tag = '<a' + hreflang + ' href=\"' + link + '\">' + title + '</a>';
jInsertEditorText(tag, '" . $name . "');
SqueezeBox.close();
}";
$doc = JFactory::getDocument();
$doc->addScriptDeclaration($js);
JHtml::_('behavior.modal');
/*
* Use the built-in element view to select the article.
* Currently uses blank class.
*/
$link = 'index.php?option=com_content&amp;view=articles&amp;layout=modal&amp;tmpl=component&amp;' . JSession::getFormToken() . '=1';
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_ARTICLE_BUTTON_ARTICLE');
$button->name = 'file-add';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
return $button;
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors-xtd">
<name>plg_editors-xtd_article</name>
<author>Joomla! Project</author>
<creationDate>October 2009</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_ARTICLE_XML_DESCRIPTION</description>
<files>
<filename plugin="article">article.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_editors-xtd_article.ini</language>
<language tag="en-GB">en-GB.plg_editors-xtd_article.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,73 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.image
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Editor Image buton
*
* @package Joomla.Plugin
* @subpackage Editors-xtd.image
* @since 1.5
*/
class PlgButtonImage extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Display the button
*
* @param string $name The name of the button to display
* @param string $asset
* @param string $author
*
* @return array A two element array of (imageName, textToInsert)
*/
public function onDisplay($name, $asset, $author)
{
$app = JFactory::getApplication();
$user = JFactory::getUser();
$extension = $app->input->get('option');
if ($asset == '')
{
$asset = $extension;
}
if ( $user->authorise('core.edit', $asset)
|| $user->authorise('core.create', $asset)
|| (count($user->getAuthorisedCategories($asset, 'core.create')) > 0)
|| ($user->authorise('core.edit.own', $asset) && $author == $user->id)
|| (count($user->getAuthorisedCategories($extension, 'core.edit')) > 0)
|| (count($user->getAuthorisedCategories($extension, 'core.edit.own')) > 0 && $author == $user->id))
{
$link = 'index.php?option=com_media&amp;view=images&amp;tmpl=component&amp;e_name=' . $name . '&amp;asset=' . $asset . '&amp;author=' . $author;
JHtml::_('behavior.modal');
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_IMAGE_BUTTON_IMAGE');
$button->name = 'picture';
$button->options = "{handler: 'iframe', size: {x: 800, y: 500}}";
return $button;
}
else
{
return false;
}
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors-xtd">
<name>plg_editors-xtd_image</name>
<author>Joomla! Project</author>
<creationDate>August 2004</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_IMAGE_XML_DESCRIPTION</description>
<files>
<filename plugin="image">image.php</filename>
<filename>index.html</filename> </files>
<languages>
<language tag="en-GB">en-GB.plg_editors-xtd_image.ini</language>
<language tag="en-GB">en-GB.plg_editors-xtd_image.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,52 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.pagebreak
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Editor Pagebreak buton
*
* @package Joomla.Plugin
* @subpackage Editors-xtd.pagebreak
* @since 1.5
*/
class PlgButtonPagebreak extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Display the button
*
* @param string $name The name of the button to add
*
* @return array A two element array of (imageName, textToInsert)
*/
public function onDisplay($name)
{
JHtml::_('behavior.modal');
$link = 'index.php?option=com_content&amp;view=article&amp;layout=pagebreak&amp;tmpl=component&amp;e_name=' . $name;
$button = new JObject;
$button->modal = true;
$button->class = 'btn';
$button->link = $link;
$button->text = JText::_('PLG_EDITORSXTD_PAGEBREAK_BUTTON_PAGEBREAK');
$button->name = 'copy';
$button->options = "{handler: 'iframe', size: {x: 500, y: 300}}";
return $button;
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors-xtd">
<name>plg_editors-xtd_pagebreak</name>
<author>Joomla! Project</author>
<creationDate>August 2004</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_EDITORSXTD_PAGEBREAK_XML_DESCRIPTION</description>
<files>
<filename plugin="pagebreak">pagebreak.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_editors-xtd_pagebreak.ini</language>
<language tag="en-GB">en-GB.plg_editors-xtd_pagebreak.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,73 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors-xtd.readmore
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Editor Readmore buton
*
* @package Joomla.Plugin
* @subpackage Editors-xtd.readmore
* @since 1.5
*/
class PlgButtonReadmore extends JPlugin
{
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Readmore button
*
* @param string $name The name of the button to add
*
* @return array A two element array of (imageName, textToInsert)
*/
public function onDisplay($name)
{
$doc = JFactory::getDocument();
// Button is not active in specific content components
$getContent = $this->_subject->getContent($name);
$present = JText::_('PLG_READMORE_ALREADY_EXISTS', true);
$js = "
function insertReadmore(editor)
{
var content = $getContent
if (content.match(/<hr\s+id=(\"|')system-readmore(\"|')\s*\/*>/i))
{
alert('$present');
return false;
} else {
jInsertEditorText('<hr id=\"system-readmore\" />', editor);
}
}
";
$doc->addScriptDeclaration($js);
$button = new JObject;
$button->modal = false;
$button->class = 'btn';
$button->onclick = 'insertReadmore(\'' . $name . '\');return false;';
$button->text = JText::_('PLG_READMORE_BUTTON_READMORE');
$button->name = 'arrow-down';
// @TODO: The button writer needs to take into account the javascript directive
// $button->link', 'javascript:void(0)');
$button->link = '#';
return $button;
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors-xtd">
<name>plg_editors-xtd_readmore</name>
<author>Joomla! Project</author>
<creationDate>March 2006</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_READMORE_XML_DESCRIPTION</description>
<files>
<filename plugin="readmore">readmore.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_editors-xtd_readmore.ini</language>
<language tag="en-GB">en-GB.plg_editors-xtd_readmore.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,275 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.codemirror
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* CodeMirror Editor Plugin.
*
* @package Joomla.Plugin
* @subpackage Editors.codemirror
* @since 1.6
*/
class PlgEditorCodemirror extends JPlugin
{
/**
* Base path for editor files
*/
protected $_basePath = 'media/editors/codemirror/';
/**
* Initialises the Editor.
*
* @return string JavaScript Initialization string.
*/
public function onInit()
{
JHtml::_('behavior.framework');
$uncompressed = JFactory::getApplication()->getCfg('debug') ? '-uncompressed' : '';
JHtml::_('script', $this->_basePath . 'js/codemirror' . $uncompressed . '.js', false, false, false, false);
JHtml::_('stylesheet', $this->_basePath . 'css/codemirror.css');
return '';
}
/**
* Copy editor content to form field.
*
* @param string $id The id of the editor field.
*
* @return string Javascript
*/
public function onSave($id)
{
return "document.getElementById('$id').value = Joomla.editors.instances['$id'].getCode();\n";
}
/**
* Get the editor content.
*
* @param string $id The id of the editor field.
*
* @return string Javascript
*/
public function onGetContent($id)
{
return "Joomla.editors.instances['$id'].getCode();\n";
}
/**
* Set the editor content.
*
* @param string $id The id of the editor field.
* @param string $content The content to set.
*
* @return string Javascript
*/
public function onSetContent($id, $content)
{
return "Joomla.editors.instances['$id'].setCode($content);\n";
}
/**
* Adds the editor specific insert method.
*
* @return boolean
*/
public function onGetInsertMethod()
{
static $done = false;
// Do this only once.
if (!$done)
{
$done = true;
$doc = JFactory::getDocument();
$js = "\tfunction jInsertEditorText(text, editor)
{
Joomla.editors.instances[editor].replaceSelection(text);\n
}";
$doc->addScriptDeclaration($js);
}
return true;
}
/**
* Display the editor area.
*
* @param string $name The control name.
* @param string $content The contents of the text area.
* @param string $width The width of the text area (px or %).
* @param string $height The height of the text area (px or %).
* @param integer $col The number of columns for the textarea.
* @param integer $row The number of rows for the textarea.
* @param boolean $buttons True and the editor buttons will be displayed.
* @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
* @param array $params Associative array of editor parameters.
*
* @return string HTML
*/
public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
{
if (empty($id))
{
$id = $name;
}
// Only add "px" to width and height if they are not given as a percentage
if (is_numeric($width))
{
$width .= 'px';
}
if (is_numeric($height))
{
$height .= 'px';
}
// Must pass the field id to the buttons in this editor.
$buttons = $this->_displayButtons($id, $buttons, $asset, $author);
$compressed = JFactory::getApplication()->getCfg('debug') ? '-uncompressed' : '';
// Default syntax
$parserFile = 'parsexml.js';
$styleSheet = array('xmlcolors.css');
// Look if we need special syntax coloring.
$syntax = JFactory::getApplication()->getUserState('editor.source.syntax');
if ($syntax)
{
switch ($syntax)
{
case 'css':
$parserFile = 'parsecss.js';
$styleSheet = array('csscolors.css');
break;
case 'js':
$parserFile = array('tokenizejavascript.js', 'parsejavascript.js');
$styleSheet = array('jscolors.css');
break;
case 'html':
$parserFile = array('parsexml.js', 'parsecss.js', 'tokenizejavascript.js', 'parsejavascript.js', 'parsehtmlmixed.js');
$styleSheet = array('xmlcolors.css', 'jscolors.css', 'csscolors.css');
break;
case 'php':
$parserFile = array('parsexml.js', 'parsecss.js', 'tokenizejavascript.js', 'parsejavascript.js', 'tokenizephp.js', 'parsephp.js', 'parsephphtmlmixed.js');
$styleSheet = array('xmlcolors.css', 'jscolors.css', 'csscolors.css', 'phpcolors.css');
break;
default:
break;
}
}
foreach ($styleSheet as &$style)
{
$style = JUri::root(true) . '/' . $this->_basePath . 'css/' . $style;
}
$options = new stdClass;
$options->basefiles = array('basefiles' . $compressed . '.js');
$options->path = JUri::root(true) . '/' . $this->_basePath . 'js/';
$options->parserfile = $parserFile;
$options->stylesheet = $styleSheet;
$options->height = $height;
$options->width = $width;
$options->continuousScanning = 500;
if ($this->params->get('linenumbers', 0))
{
$options->lineNumbers = true;
$options->textWrapping = false;
}
if ($this->params->get('tabmode', '') == 'shift')
{
$options->tabMode = 'shift';
}
$html = array();
$html[] = "<textarea name=\"$name\" id=\"$id\" cols=\"$col\" rows=\"$row\">$content</textarea>";
$html[] = $buttons;
$html[] = '<script type="text/javascript">';
$html[] = '(function() {';
$html[] = 'var editor = CodeMirror.fromTextArea("' . $id . '", ' . json_encode($options) . ');';
$html[] = 'Joomla.editors.instances[\'' . $id . '\'] = editor;';
$html[] = '})()';
$html[] = '</script>';
return implode("\n", $html);
}
/**
* Displays the editor buttons.
*
* @param string $name Name of the button
* @param mixed $buttons [array with button objects | boolean true to display buttons]
* @param string $asset The object asset
* @param object $author The author.
*
* @return string HTML
*/
protected function _displayButtons($name, $buttons, $asset, $author)
{
// Load modal popup behavior
JHtml::_('behavior.modal', 'a.modal-button');
$args['name'] = $name;
$args['event'] = 'onGetInsertMethod';
$html = array();
$results[] = $this->update($args);
foreach ($results as $result)
{
if (is_string($result) && trim($result))
{
$html[] = $result;
}
}
if (is_array($buttons) || (is_bool($buttons) && $buttons))
{
$results = $this->_subject->getButtons($name, $buttons, $asset, $author);
// This will allow plugins to attach buttons or change the behavior on the fly using AJAX
$html[] = '<div id="editor-xtd-buttons">';
$html[] = '<div class="btn-toolbar">';
foreach ($results as $button)
{
// Results should be an object
if ($button->get('name'))
{
$modal = ($button->get('modal')) ? 'class="modal-button btn"' : null;
$href = ($button->get('link')) ? ' class="btn" href="' . JUri::base() . $button->get('link') . '"' : null;
$onclick = ($button->get('onclick')) ? 'onclick="' . $button->get('onclick') . '"' : null;
$title = ($button->get('title')) ? $button->get('title') : $button->get('text');
$html[] = '<a ' . $modal . ' title="' . $title . '" ' . $href . ' ' . $onclick . ' rel="' . $button->get('options') . '">';
$html[] = '<i class="icon-' . $button->get('name') . '"></i> ';
$html[] = $button->get('text') . '</a>';
}
}
$html[] = '</div>';
$html[] = '</div>';
}
return implode("\n", $html);
}
}

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors">
<name>plg_editors_codemirror</name>
<version>1.0</version>
<creationDate>28 March 2011</creationDate>
<author>Marijn Haverbeke</author>
<authorEmail>N/A</authorEmail>
<authorUrl></authorUrl>
<copyright></copyright>
<license></license>
<description>PLG_CODEMIRROR_XML_DESCRIPTION</description>
<files>
<filename plugin="codemirror">codemirror.php</filename>
<filename>index.html</filename> </files>
<languages>
<language tag="en-GB">en-GB.plg_editors_codemirror.ini</language>
<language tag="en-GB">en-GB.plg_editors_codemirror.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="linenumbers" type="radio"
class="btn-group"
default="0"
description="PLG_CODEMIRROR_FIELD_LINENUMBERS_DESC"
label="PLG_CODEMIRROR_FIELD_LINENUMBERS_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="tabmode" type="list"
default="indent"
description="PLG_CODEMIRROR_FIELD_TABMODE_DESC"
label="PLG_CODEMIRROR_FIELD_TABMODE_LABEL"
>
<option value="indent">PLG_CODEMIRROR_FIELD_VALUE_TABMODE_INDENT</option>
<option value="shift">PLG_CODEMIRROR_FIELD_VALUE_TABMODE_SHIFT</option>
</field>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,215 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.none
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Plain Textarea Editor Plugin
*
* @package Joomla.Plugin
* @subpackage Editors.none
* @since 1.5
*/
class PlgEditorNone extends JPlugin
{
/**
* Method to handle the onInitEditor event.
* - Initialises the Editor
*
* @return string JavaScript Initialization string
*
* @since 1.5
*/
public function onInit()
{
$txt = "<script type=\"text/javascript\">
function insertAtCursor(myField, myValue)
{
if (document.selection)
{
// IE support
myField.focus();
sel = document.selection.createRange();
sel.text = myValue;
} else if (myField.selectionStart || myField.selectionStart == '0')
{
// MOZILLA/NETSCAPE support
var startPos = myField.selectionStart;
var endPos = myField.selectionEnd;
myField.value = myField.value.substring(0, startPos)
+ myValue
+ myField.value.substring(endPos, myField.value.length);
} else {
myField.value += myValue;
}
}
</script>";
return $txt;
}
/**
* Copy editor content to form field.
*
* Not applicable in this editor.
*
* @return void
*/
public function onSave()
{
return;
}
/**
* Get the editor content.
*
* @param string $id The id of the editor field.
*
* @return string
*/
public function onGetContent($id)
{
return "document.getElementById('$id').value;\n";
}
/**
* Set the editor content.
*
* @param string $id The id of the editor field.
* @param string $html The content to set.
*
* @return string
*/
public function onSetContent($id, $html)
{
return "document.getElementById('$id').value = $html;\n";
}
/**
* @param string $id The id of the editor field
*
* @return boolean returns true when complete
*/
public function onGetInsertMethod($id)
{
static $done = false;
// Do this only once.
if (!$done)
{
$doc = JFactory::getDocument();
$js = "\tfunction jInsertEditorText(text, editor)
{
insertAtCursor(document.getElementById(editor), text);
}";
$doc->addScriptDeclaration($js);
}
return true;
}
/**
* Display the editor area.
*
* @param string $name The control name.
* @param string $content The contents of the text area.
* @param string $width The width of the text area (px or %).
* @param string $height The height of the text area (px or %).
* @param integer $col The number of columns for the textarea.
* @param integer $row The number of rows for the textarea.
* @param boolean $buttons True and the editor buttons will be displayed.
* @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
* @param array $params Associative array of editor parameters.
*
* @return string
*/
public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null, $params = array())
{
if (empty($id))
{
$id = $name;
}
// Only add "px" to width and height if they are not given as a percentage
if (is_numeric($width))
{
$width .= 'px';
}
if (is_numeric($height))
{
$height .= 'px';
}
$buttons = $this->_displayButtons($id, $buttons, $asset, $author);
$editor = "<textarea name=\"$name\" id=\"$id\" cols=\"$col\" rows=\"$row\" style=\"width: $width; height: $height;\">$content</textarea>" . $buttons;
return $editor;
}
/**
* Displays the editor buttons.
*
* @param string $name The control name.
* @param mixed $buttons [array with button objects | boolean true to display buttons]
* @param string $asset The object asset
* @param object $author The author.
*
* @return string HTML
*/
public function _displayButtons($name, $buttons, $asset, $author)
{
// Load modal popup behavior
JHtml::_('behavior.modal', 'a.modal-button');
$args['name'] = $name;
$args['event'] = 'onGetInsertMethod';
$return = '';
$results[] = $this->update($args);
foreach ($results as $result)
{
if (is_string($result) && trim($result))
{
$return .= $result;
}
}
if (is_array($buttons) || (is_bool($buttons) && $buttons))
{
$results = $this->_subject->getButtons($name, $buttons, $asset, $author);
// This will allow plugins to attach buttons or change the behavior on the fly using AJAX
$return .= "\n<div id=\"editor-xtd-buttons\" class=\"btn-toolbar pull-left\">\n";
$return .= "\n<div class=\"btn-toolbar\">\n";
foreach ($results as $button)
{
// Results should be an object
if ($button->get('name'))
{
$modal = ($button->get('modal')) ? 'class="modal-button btn"' : null;
$href = ($button->get('link')) ? 'class="btn" href="' . JUri::base() . $button->get('link') . '"' : null;
$onclick = ($button->get('onclick')) ? 'onclick="' . $button->get('onclick') . '"' : null;
$title = ($button->get('title')) ? $button->get('title') : $button->get('text');
$return .= "<a " . $modal . " title=\"" . $title . "\" " . $href . " " . $onclick . " rel=\"" . $button->get('options') . "\"><i class=\"icon-" . $button->get('name') . "\"></i> " . $button->get('text') . "</a>\n";
}
}
$return .= "</div>\n";
$return .= "</div>\n";
$return .= "<div class=\"clearfix\"></div>\n";
}
return $return;
}
}

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors">
<name>plg_editors_none</name>
<version>3.0.0</version>
<creationDate>August 2004</creationDate>
<author></author>
<authorEmail>N/A</authorEmail>
<authorUrl></authorUrl>
<copyright></copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<description>PLG_NONE_XML_DESCRIPTION</description>
<files>
<filename plugin="none">none.php</filename>
<filename>index.html</filename> </files>
<languages>
<language tag="en-GB">en-GB.plg_editors_none.ini</language>
<language tag="en-GB">en-GB.plg_editors_none.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,823 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Editors.tinymce
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* TinyMCE Editor Plugin
*
* @package Joomla.Plugin
* @subpackage Editors.tinymce
* @since 1.5
*/
class PlgEditorTinymce extends JPlugin
{
/**
* Base path for editor files
*/
protected $_basePath = 'media/editors/tinymce/jscripts/tiny_mce';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Initialises the Editor.
*
* @return string JavaScript Initialization string
*
* @since 1.5
*/
public function onInit()
{
$language = JFactory::getLanguage();
$mode = (int) $this->params->get('mode', 1);
$theme = array('simple', 'advanced', 'advanced');
$skin = $this->params->get('skin', '0');
switch ($skin)
{
case '3':
$skin = 'skin : "o2k7", skin_variant : "black",';
break;
case '2':
$skin = 'skin : "o2k7", skin_variant : "silver",';
break;
case '1':
$skin = 'skin : "o2k7",';
break;
case '0':
default:
$skin = 'skin : "default",';
}
$entity_encoding = $this->params->def('entity_encoding', 'raw');
$langMode = $this->params->def('lang_mode', 0);
$langPrefix = $this->params->def('lang_code', 'en');
if ($langMode)
{
$langPrefix = substr($language->getTag(), 0, strpos($language->getTag(), '-'));
}
$text_direction = 'ltr';
if ($language->isRTL())
{
$text_direction = 'rtl';
}
$use_content_css = $this->params->def('content_css', 1);
$content_css_custom = $this->params->def('content_css_custom', '');
/*
* Lets get the default template for the site application
*/
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('template')
->from('#__template_styles')
->where('client_id=0 AND home=' . $db->quote('1'));
$db->setQuery($query);
$template = $db->loadResult();
$content_css = '';
$templates_path = JPATH_SITE . '/templates';
// Loading of css file for 'styles' dropdown
if ( $content_css_custom )
{
// If URL, just pass it to $content_css
if (strpos($content_css_custom, 'http') !== false)
{
$content_css = 'content_css : "' . $content_css_custom . '",';
}
// If it is not a URL, assume it is a file name in the current template folder
else
{
$content_css = 'content_css : "' . JUri::root() . 'templates/' . $template . '/css/' . $content_css_custom . '",';
// Issue warning notice if the file is not found (but pass name to $content_css anyway to avoid TinyMCE error
if (!file_exists($templates_path . '/' . $template . '/css/' . $content_css_custom))
{
$msg = sprintf(JText::_('PLG_TINY_ERR_CUSTOMCSSFILENOTPRESENT'), $content_css_custom);
JError::raiseNotice('SOME_ERROR_CODE', $msg);
}
}
}
else
{
// Process when use_content_css is Yes and no custom file given
if ($use_content_css)
{
// First check templates folder for default template
// if no editor.css file in templates folder, check system template folder
if (!file_exists($templates_path . '/' . $template . '/css/editor.css'))
{
// If no editor.css file in system folder, show alert
if (!file_exists($templates_path . '/system/css/editor.css'))
{
JError::raiseNotice('SOME_ERROR_CODE', JText::_('PLG_TINY_ERR_EDITORCSSFILENOTPRESENT'));
}
else
{
$content_css = 'content_css : "' . JUri::root() . 'templates/system/css/editor.css",';
}
}
else
{
$content_css = 'content_css : "' . JUri::root() . 'templates/' . $template . '/css/editor.css",';
}
}
}
$relative_urls = $this->params->def('relative_urls', '1');
if ($relative_urls)
{
// Relative
$relative_urls = "true";
}
else
{
// Absolute
$relative_urls = "false";
}
$newlines = $this->params->def('newlines', 0);
if ($newlines)
{
// br
$forcenewline = "force_br_newlines : true, force_p_newlines : false, forced_root_block : '',";
}
else
{
// p
$forcenewline = "force_br_newlines : false, force_p_newlines : true, forced_root_block : 'p',";
}
$invalid_elements = $this->params->def('invalid_elements', 'script,applet,iframe');
$extended_elements = $this->params->def('extended_elements', '');
// theme_advanced_* settings
$toolbar = $this->params->def('toolbar', 'top');
$toolbar_align = $this->params->def('toolbar_align', 'left');
$html_height = $this->params->def('html_height', '550');
$html_width = $this->params->def('html_width', '750');
$resizing = $this->params->def('resizing', 'true');
$resize_horizontal = $this->params->def('resize_horizontal', 'false');
if ($this->params->get('element_path', 1))
{
$element_path = 'theme_advanced_statusbar_location : "bottom", theme_advanced_path : true';
}
else
{
$element_path = 'theme_advanced_statusbar_location : "none", theme_advanced_path : false';
}
$buttons1_add_before = $buttons1_add = array();
$buttons2_add_before = $buttons2_add = array();
$buttons3_add_before = $buttons3_add = array();
$buttons4 = array();
$plugins = array();
if ($extended_elements != "")
{
$elements = explode(',', $extended_elements);
}
// Initial values for buttons
array_push($buttons4, 'cut', 'copy', 'paste');
// array_push($buttons4,'|');
// Plugins
// Fonts
$fonts = $this->params->def('fonts', 1);
if ($fonts)
{
$buttons1_add[] = 'fontselect,fontsizeselect';
}
// Paste
$paste = $this->params->def('paste', 1);
if ($paste)
{
$plugins[] = 'paste';
$buttons4[] = 'pastetext';
$buttons4[] = 'pasteword';
$buttons4[] = 'selectall,|';
}
// Search & replace
$searchreplace = $this->params->def('searchreplace', 1);
if ($searchreplace)
{
$plugins[] = 'searchreplace';
$buttons2_add_before[] = 'search,replace,|';
}
// Insert date and/or time plugin
$insertdate = $this->params->def('insertdate', 1);
$format_date = $this->params->def('format_date', '%Y-%m-%d');
$inserttime = $this->params->def('inserttime', 1);
$format_time = $this->params->def('format_time', '%H:%M:%S');
if ($insertdate or $inserttime)
{
$plugins[] = 'insertdatetime';
if ($insertdate)
{
$buttons2_add[] = 'insertdate';
}
if ($inserttime)
{
$buttons2_add[] = 'inserttime';
}
}
// Colors
$colors = $this->params->def('colors', 1);
if ($colors)
{
$buttons2_add[] = 'forecolor,backcolor';
}
// Table
$table = $this->params->def('table', 1);
if ($table)
{
$plugins[] = 'table';
$buttons3_add_before[] = 'tablecontrols';
}
// Emotions
$smilies = $this->params->def('smilies', 1);
if ($smilies)
{
$plugins[] = 'emotions';
$buttons3_add[] = 'emotions';
}
// Media plugin
$media = $this->params->def('media', 1);
if ($media)
{
$plugins[] = 'media';
$buttons3_add[] = 'media';
}
// Horizontal line
$hr = $this->params->def('hr', 1);
if ($hr)
{
$plugins[] = 'advhr';
$elements[] = 'hr[id|title|alt|class|width|size|noshade|style]';
$buttons3_add[] = 'advhr';
}
else
{
$elements[] = 'hr[id|class|title|alt]';
}
// RTL/LTR buttons
$directionality = $this->params->def('directionality', 1);
if ($directionality)
{
$plugins[] = 'directionality';
$buttons3_add[] = 'ltr,rtl';
}
// Fullscreen
$fullscreen = $this->params->def('fullscreen', 1);
if ($fullscreen)
{
$plugins[] = 'fullscreen';
$buttons2_add[] = 'fullscreen';
}
// Layer
$layer = $this->params->def('layer', 1);
if ($layer)
{
$plugins[] = 'layer';
$buttons4[] = 'insertlayer';
$buttons4[] = 'moveforward';
$buttons4[] = 'movebackward';
$buttons4[] = 'absolute';
}
// Style
$style = $this->params->def('style', 1);
if ($style)
{
$plugins[] = 'style';
$buttons4[] = 'styleprops';
}
// XHTMLxtras
$xhtmlxtras = $this->params->def('xhtmlxtras', 1);
if ($xhtmlxtras)
{
$plugins[] = 'xhtmlxtras';
$buttons4[] = 'cite,abbr,acronym,ins,del,attribs';
}
// Visualchars
$visualchars = $this->params->def('visualchars', 1);
if ($visualchars)
{
$plugins[] = 'visualchars';
$buttons4[] = 'visualchars';
}
// Visualblocks
$visualblocks = $this->params->def('visualblocks', 1);
if ($visualblocks)
{
$plugins[] = 'visualblocks';
$buttons4[] = 'visualblocks';
}
// Non-breaking
$nonbreaking = $this->params->def('nonbreaking', 1);
if ($nonbreaking)
{
$plugins[] = 'nonbreaking';
$buttons4[] = 'nonbreaking';
}
// Blockquote
$blockquote = $this->params->def('blockquote', 1);
if ($blockquote)
{
$buttons4[] = 'blockquote';
}
// Wordcount
$wordcount = $this->params->def('wordcount', 1);
if ($wordcount)
{
$plugins[] = 'wordcount';
}
// Template
$template = $this->params->def('template', 1);
if ($template)
{
$plugins[] = 'template';
$buttons4[] = 'template';
}
// Advimage
$advimage = $this->params->def('advimage', 1);
if ($advimage)
{
$plugins[] = 'advimage';
$elements[] = 'img[class|src|alt|title|hspace|vspace|width|height|align|onmouseover|onmouseout|name|style]';
}
// Advlink
$advlink = $this->params->def('advlink', 1);
if ($advlink)
{
$plugins[] = 'advlink';
$elements[] = 'a[id|class|name|href|hreflang|target|title|onclick|rel|style]';
}
// Advlist
$advlist = $this->params->def('advlist', 1);
if ($advlist)
{
$plugins[] = 'advlist';
}
// Autosave
$autosave = $this->params->def('autosave', 1);
if ($autosave)
{
$plugins[] = 'autosave';
}
// Context menu
$contextmenu = $this->params->def('contextmenu', 1);
if ($contextmenu)
{
$plugins[] = 'contextmenu';
}
// Inline popups
$inlinepopups = $this->params->def('inlinepopups', 1);
if ($inlinepopups)
{
$plugins[] = 'inlinepopups';
$dialog_type = 'dialog_type : "modal",';
}
else
{
$dialog_type = "";
}
$custom_plugin = $this->params->def('custom_plugin', '');
if ($custom_plugin != "")
{
$plugins[] = $custom_plugin;
}
$custom_button = $this->params->def('custom_button', '');
if ($custom_button != "")
{
$buttons4[] = $custom_button;
}
// Prepare config variables
$buttons1_add_before = implode(',', $buttons1_add_before);
$buttons2_add_before = implode(',', $buttons2_add_before);
$buttons3_add_before = implode(',', $buttons3_add_before);
$buttons1_add = implode(',', $buttons1_add);
$buttons2_add = implode(',', $buttons2_add);
$buttons3_add = implode(',', $buttons3_add);
$buttons4 = implode(',', $buttons4);
$plugins = implode(',', $plugins);
$elements = implode(',', $elements);
switch ($mode)
{
case 0: /* Simple mode*/
$load = "\t<script type=\"text/javascript\" src=\"" .
JUri::root() . $this->_basePath .
"/tiny_mce.js\"></script>\n";
$return = $load .
"\t<script type=\"text/javascript\">
tinyMCE.init({
// General
directionality: \"$text_direction\",
editor_selector : \"mce_editable\",
language : \"" . $langPrefix . "\",
mode : \"specific_textareas\",
$skin
theme : \"$theme[$mode]\",
// Cleanup/Output
inline_styles : true,
gecko_spellcheck : true,
entity_encoding : \"$entity_encoding\",
$forcenewline
// URL
relative_urls : $relative_urls,
remove_script_host : false,
// Layout
$content_css
document_base_url : \"" . JUri::root() . "\"
});
</script>";
break;
case 1: /* Advanced mode*/
$load = "\t<script type=\"text/javascript\" src=\"" .
JUri::root() . $this->_basePath .
"/tiny_mce.js\"></script>\n";
$return = $load .
"\t<script type=\"text/javascript\">
tinyMCE.init({
// General
directionality: \"$text_direction\",
editor_selector : \"mce_editable\",
language : \"" . $langPrefix . "\",
mode : \"specific_textareas\",
$skin
theme : \"$theme[$mode]\",
// Cleanup/Output
inline_styles : true,
gecko_spellcheck : true,
entity_encoding : \"$entity_encoding\",
extended_valid_elements : \"$elements\",
$forcenewline
invalid_elements : \"$invalid_elements\",
// URL
relative_urls : $relative_urls,
remove_script_host : false,
document_base_url : \"" . JUri::root() . "\",
// Layout
$content_css
// Advanced theme
theme_advanced_toolbar_location : \"$toolbar\",
theme_advanced_toolbar_align : \"$toolbar_align\",
theme_advanced_source_editor_height : \"$html_height\",
theme_advanced_source_editor_width : \"$html_width\",
theme_advanced_resizing : $resizing,
theme_advanced_resize_horizontal : $resize_horizontal,
$element_path
});
</script>";
break;
case 2: /* Extended mode*/
$load = "\t<script type=\"text/javascript\" src=\"" .
JUri::root() . $this->_basePath .
"/tiny_mce.js\"></script>\n";
$return = $load .
"\t<script type=\"text/javascript\">
tinyMCE.init({
// General
$dialog_type
directionality: \"$text_direction\",
editor_selector : \"mce_editable\",
language : \"" . $langPrefix . "\",
mode : \"specific_textareas\",
plugins : \"$plugins\",
$skin
theme : \"$theme[$mode]\",
// Cleanup/Output
inline_styles : true,
gecko_spellcheck : true,
entity_encoding : \"$entity_encoding\",
extended_valid_elements : \"$elements\",
$forcenewline
invalid_elements : \"$invalid_elements\",
// URL
relative_urls : $relative_urls,
remove_script_host : false,
document_base_url : \"" . JUri::root() . "\",
//Templates
template_external_list_url : \"" . JUri::root() . "media/editors/tinymce/templates/template_list.js\",
// Layout
$content_css
// Advanced theme
theme_advanced_toolbar_location : \"$toolbar\",
theme_advanced_toolbar_align : \"$toolbar_align\",
theme_advanced_source_editor_height : \"$html_height\",
theme_advanced_source_editor_width : \"$html_width\",
theme_advanced_resizing : $resizing,
theme_advanced_resize_horizontal : $resize_horizontal,
$element_path,
theme_advanced_buttons1_add_before : \"$buttons1_add_before\",
theme_advanced_buttons2_add_before : \"$buttons2_add_before\",
theme_advanced_buttons3_add_before : \"$buttons3_add_before\",
theme_advanced_buttons1_add : \"$buttons1_add\",
theme_advanced_buttons2_add : \"$buttons2_add\",
theme_advanced_buttons3_add : \"$buttons3_add\",
theme_advanced_buttons4 : \"$buttons4\",
plugin_insertdate_dateFormat : \"$format_date\",
plugin_insertdate_timeFormat : \"$format_time\",
fullscreen_settings : {
theme_advanced_path_location : \"top\"
}
});
</script>";
break;
}
return $return;
}
/**
* TinyMCE WYSIWYG Editor - get the editor content
*
* @param string $editor The name of the editor
*
* @return string
*/
public function onGetContent($editor)
{
return 'tinyMCE.get(\'' . $editor . '\').getContent();';
}
/**
* TinyMCE WYSIWYG Editor - set the editor content
*
* @param string $editor The name of the editor
* @param string $html HTML code to set as the content for the editor
*
* @return string
*/
public function onSetContent($editor, $html)
{
return 'tinyMCE.get(\'' . $editor . '\').setContent(' . $html . ');';
}
/**
* TinyMCE WYSIWYG Editor - copy editor content to form field
*
* @param string $editor The name of the editor
*
* @return string
*/
public function onSave($editor)
{
return 'if (tinyMCE.get("' . $editor . '").isHidden()) {tinyMCE.get("' . $editor . '").show()}; tinyMCE.get("' . $editor . '").save();';
}
/**
* @param string $name
*
* @return boolean
*/
public function onGetInsertMethod($name)
{
$doc = JFactory::getDocument();
$js = "
function isBrowserIE()
{
return navigator.appName==\"Microsoft Internet Explorer\";
}
function jInsertEditorText( text, editor )
{
if (isBrowserIE())
{
if (window.parent.tinyMCE)
{
window.parent.tinyMCE.selectedInstance.selection.moveToBookmark(window.parent.global_ie_bookmark);
}
}
tinyMCE.execInstanceCommand(editor, 'mceInsertContent',false,text);
}
var global_ie_bookmark = false;
function IeCursorFix()
{
if (isBrowserIE())
{
tinyMCE.execCommand('mceInsertContent', false, '');
global_ie_bookmark = tinyMCE.activeEditor.selection.getBookmark(false);
}
return true;
}";
$doc->addScriptDeclaration($js);
return true;
}
/**
* Display the editor area.
*
* @param string $name The control name.
* @param string $content The contents of the text area.
* @param string $width The width of the text area (px or %).
* @param string $height The height of the text area (px or %).
* @param integer $col The number of columns for the textarea.
* @param integer $row The number of rows for the textarea.
* @param boolean $buttons True and the editor buttons will be displayed.
* @param string $id An optional ID for the textarea (note: since 1.6). If not supplied the name is used.
* @param string $asset The object asset
* @param object $author The author.
*
* @return string
*/
public function onDisplay($name, $content, $width, $height, $col, $row, $buttons = true, $id = null, $asset = null, $author = null)
{
if (empty($id))
{
$id = $name;
}
// Only add "px" to width and height if they are not given as a percentage
if (is_numeric($width))
{
$width .= 'px';
}
if (is_numeric($height))
{
$height .= 'px';
}
$editor = '<textarea name="' . $name . '" id="' . $id .'" cols="' . $col .'" rows="' . $row . '" style="width: ' . $width . '; height:' . $height . ';" class="mce_editable">' . $content . "</textarea>\n" .
$this->_displayButtons($id, $buttons, $asset, $author) .
$this->_toogleButton($id);
return $editor;
}
/**
* Displays the editor buttons.
*
* @param string $name
* @param mixed $buttons [array with button objects | boolean true to display buttons]
* @param string $asset
* @param string $author
*
* @return string HTML
*/
private function _displayButtons($name, $buttons, $asset, $author)
{
// Load modal popup behavior
JHtml::_('behavior.modal', 'a.modal-button');
$args['name'] = $name;
$args['event'] = 'onGetInsertMethod';
$return = '';
$results[] = $this->update($args);
foreach ($results as $result)
{
if (is_string($result) && trim($result))
{
$return .= $result;
}
}
if (is_array($buttons) || (is_bool($buttons) && $buttons))
{
$results = $this->_subject->getButtons($name, $buttons, $asset, $author);
/*
* This will allow plugins to attach buttons or change the behavior on the fly using AJAX
*/
$return .= "\n<div id=\"editor-xtd-buttons\" class=\"btn-toolbar pull-left\">\n";
$return .= "\n<div class=\"btn-toolbar\">\n";
foreach ($results as $button)
{
/*
* Results should be an object
*/
if ( $button->get('name') )
{
$class = ($button->get('class')) ? $button->get('class') : null;
$class .= ($button->get('modal')) ? ' modal-button' : null;
$href = ($button->get('link')) ? ' href="'.JUri::base().$button->get('link').'"' : null;
$onclick = ($button->get('onclick')) ? ' onclick="'.$button->get('onclick').'"' : ' onclick="IeCursorFix(); return false;"';
$title = ($button->get('title')) ? $button->get('title') : $button->get('text');
$return .= '<a class="' . $class . '" title="' . $title . '"' . $href . $onclick . ' rel="' . $button->get('options')
. '"><i class="icon-' . $button->get('name'). '"></i> ' . $button->get('text') . "</a>\n";
}
}
$return .= "</div>\n";
$return .= "</div>\n";
}
return $return;
}
/**
*
* @return string
*/
private function _toogleButton($name)
{
$return = '';
$return .= "\n<div class=\"toggle-editor btn-toolbar pull-right\">\n";
$return .= "<div class=\"btn-group\"><a class=\"btn\" href=\"#\" onclick=\"tinyMCE.execCommand('mceToggleEditor', false, '" . $name . "');return false;\" title=\"" . JText::_('PLG_TINY_BUTTON_TOGGLE_EDITOR') . '"><i class="icon-eye"></i> ' . JText::_('PLG_TINY_BUTTON_TOGGLE_EDITOR') . "</a></div>";
$return .= "</div>\n";
$return .= "<div class=\"clearfix\"></div>\n";
return $return;
}
}

View File

@ -0,0 +1,517 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="editors" method="upgrade">
<name>plg_editors_tinymce</name>
<version>3.5.6</version>
<creationDate>2005-2012</creationDate>
<author>Moxiecode Systems AB</author>
<authorEmail>N/A</authorEmail>
<authorUrl>tinymce.moxiecode.com/</authorUrl>
<copyright>Moxiecode Systems AB</copyright>
<license>LGPL</license>
<description>PLG_TINY_XML_DESCRIPTION</description>
<files>
<filename plugin="tinymce">tinymce.php</filename>
<filename>index.html</filename> </files>
<languages>
<language tag="en-GB">en-GB.plg_editors_tinymce.ini</language>
<language tag="en-GB">en-GB.plg_editors_tinymce.sys.ini</language>
</languages>
<config>
<fields name="params">
<fieldset name="basic">
<field name="mode" type="list"
default="2"
description="PLG_TINY_FIELD_FUNCTIONALITY_DESC"
label="PLG_TINY_FIELD_FUNCTIONALITY_LABEL"
>
<option value="0">PLG_TINY_FIELD_VALUE_SIMPLE</option>
<option value="1">PLG_TINY_FIELD_VALUE_ADVANCED</option>
<option value="2">PLG_TINY_FIELD_VALUE_EXTENDED</option>
</field>
<field name="skin" type="list"
default="0"
description="PLG_TINY_FIELD_SKIN_DESC"
label="PLG_TINY_FIELD_SKIN_LABEL"
>
<option value="0">PLG_TINY_FIELD_VALUE_DEFAULT</option>
<option value="1">PLG_TINY_FIELD_VALUE_BLUE</option>
<option value="2">PLG_TINY_FIELD_VALUE_SILVER</option>
<option value="3">PLG_TINY_FIELD_VALUE_BLACK</option>
</field>
<field name="spacer1" type="spacer"
hr="true"
/>
<field name="entity_encoding" type="list"
default="raw"
description="PLG_TINY_FIELD_ENCODING_DESC"
label="PLG_TINY_FIELD_ENCODING_LABEL"
>
<option value="named">PLG_TINY_FIELD_VALUE_NAMED</option>
<option value="numeric">PLG_TINY_FIELD_VALUE_NUMERIC</option>
<option value="raw">PLG_TINY_FIELD_VALUE_RAW</option>
</field>
<field name="spacer2" type="spacer"
hr="true"
/>
<field name="lang_mode" type="radio"
class="btn-group"
default="0"
description="PLG_TINY_FIELD_LANGSELECT_DESC"
label="PLG_TINY_FIELD_LANGSELECT_LABEL"
>
<option value="0">JNo</option>
<option value="1">JYes</option>
</field>
<field name="lang_code" type="text"
default="en"
description="PLG_TINY_FIELD_LANGCODE_DESC"
label="PLG_TINY_FIELD_LANGCODE_LABEL"
size="2"
/>
<field name="text_direction" type="list"
default="ltr"
description="PLG_TINY_FIELD_DIRECTION_DESC"
label="PLG_TINY_FIELD_DIRECTION_LABEL"
>
<option value="ltr">PLG_TINY_FIELD_VALUE_LTR</option>
<option value="rtl">PLG_TINY_FIELD_VALUE_RTL</option>
</field>
<field name="spacer3" type="spacer"
hr="true"
/>
<field name="content_css" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_CSS_DESC"
label="PLG_TINY_FIELD_CSS_LABEL"
>
<option value="0">JNo</option>
<option value="1">JYes</option>
</field>
<field name="content_css_custom" type="text"
size="30"
description="PLG_TINY_FIELD_CUSTOM_CSS_DESC"
label="PLG_TINY_FIELD_CUSTOM_CSS_LABEL"
/>
<field name="spacer4" type="spacer"
hr="true"
/>
<field name="relative_urls" type="list"
default="1"
description="PLG_TINY_FIELD_URLS_DESC"
label="PLG_TINY_FIELD_URLS_LABEL"
>
<option value="0">PLG_TINY_FIELD_VALUE_ABSOLUTE</option>
<option value="1">PLG_TINY_FIELD_VALUE_RELATIVE</option>
</field>
<field name="newlines" type="list"
default="0"
description="PLG_TINY_FIELD_NEWLINES_DESC"
label="PLG_TINY_FIELD_NEWLINES_LABEL"
>
<option value="1">PLG_TINY_FIELD_VALUE_BR</option>
<option value="0">PLG_TINY_FIELD_VALUE_P</option>
</field>
<field name="invalid_elements" type="textarea"
cols="30"
default="script,applet,iframe"
description="PLG_TINY_FIELD_PROHIBITED_DESC"
label="PLG_TINY_FIELD_PROHIBITED_LABEL"
rows="2"
/>
<field name="extended_elements" type="textarea"
cols="30"
description="PLG_TINY_FIELD_ELEMENTS_DESC"
label="PLG_TINY_FIELD_ELEMENTS_LABEL"
rows="2"
/>
</fieldset>
<fieldset name="advanced"
label="PLG_TINY_FIELD_LABEL_ADVANCEDPARAMS"
>
<field name="toolbar" type="radio"
class="btn-group"
default="top"
description="PLG_TINY_FIELD_TOOLBAR_DESC"
label="PLG_TINY_FIELD_TOOLBAR_LABEL"
>
<option value="top">PLG_TINY_FIELD_VALUE_TOP</option>
<option value="bottom">PLG_TINY_FIELD_VALUE_BOTTOM</option>
</field>
<field name="toolbar_align" type="list"
default="left"
description="PLG_TINY_FIELD_TOOLBAR_ALIGN_DESC"
label="PLG_TINY_FIELD_TOOLBAR_ALIGN_LABEL"
>
<option value="left">PLG_TINY_FIELD_VALUE_LEFT</option>
<option value="center">PLG_TINY_FIELD_VALUE_CENTER</option>
<option value="right">PLG_TINY_FIELD_VALUE_RIGHT</option>
</field>
<field name="html_height" type="text"
default="550"
description="PLG_TINY_FIELD_HTMLHEIGHT_DESC"
label="PLG_TINY_FIELD_HTMLHEIGHT_LABEL"
/>
<field name="html_width" type="text"
default="750"
description="PLG_TINY_FIELD_HTMLWIDTH_DESC"
label="PLG_TINY_FIELD_HTMLWIDTH_LABEL"
/>
<field name="resizing" type="radio"
class="btn-group"
default="true"
description="PLG_TINY_FIELD_RESIZING_DESC"
label="PLG_TINY_FIELD_RESIZING_LABEL"
>
<option value="false">JOFF</option>
<option value="true">JON</option>
</field>
<field name="resize_horizontal" type="radio"
class="btn-group"
default="false"
description="PLG_TINY_FIELD_RESIZE_HORIZONTAL_DESC"
label="PLG_TINY_FIELD_RESIZE_HORIZONTAL_LABEL"
>
<option value="false">JOFF</option>
<option value="true">JON</option>
</field>
<field name="element_path" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_PATH_DESC"
label="PLG_TINY_FIELD_PATH_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="spacer" type="spacer" class="text"
label="PLG_TINY_FIELD_NAME_EXTENDED_LABEL"
/>
<field name="fonts" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_FONTS_DESC"
label="PLG_TINY_FIELD_FONTS_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="paste" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_PASTE_DESC"
label="PLG_TINY_FIELD_PASTE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="searchreplace" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_SEARCH-REPLACE_DESC"
label="PLG_TINY_FIELD_SEARCH-REPLACE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="insertdate" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_DATE_DESC"
label="PLG_TINY_FIELD_DATE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="format_date" type="text"
default="%Y-%m-%d"
description="PLG_TINY_FIELD_DATEFORMAT_DESC"
label="PLG_TINY_FIELD_DATEFORMAT_LABEL"
/>
<field name="inserttime" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_TIME_DESC"
label="PLG_TINY_FIELD_TIME_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="format_time" type="text"
default="%H:%M:%S"
description="PLG_TINY_FIELD_TIMEFORMAT_DESC"
label="PLG_TINY_FIELD_TIMEFORMAT_LABEL"
/>
<field name="colors" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_COLORS_DESC"
label="PLG_TINY_FIELD_COLORS_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="table" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_TABLE_DESC"
label="PLG_TINY_FIELD_TABLE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="smilies" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_SMILIES_DESC"
label="PLG_TINY_FIELD_SMILIES_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="media" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_MEDIA_DESC"
label="PLG_TINY_FIELD_MEDIA_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="hr" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_HR_DESC"
label="PLG_TINY_FIELD_HR_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="directionality" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_RTL_DESC"
label="PLG_TINY_FIELD_RTL_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="fullscreen" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_FULLSCREEN_DESC"
label="PLG_TINY_FIELD_FULLSCREEN_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="style" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_STYLE_DESC"
label="PLG_TINY_FIELD_STYLE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="layer" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_LAYER_DESC"
label="PLG_TINY_FIELD_LAYER_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="xhtmlxtras" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_XHTMLXTRAS_DESC"
label="PLG_TINY_FIELD_XHTMLXTRAS_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="visualchars" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_VISUALCHARS_DESC"
label="PLG_TINY_FIELD_VISUALCHARS_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="visualblocks" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_VISUALBLOCKS_DESC"
label="PLG_TINY_FIELD_VISUALBLOCKS_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="nonbreaking" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_NONBREAKING_DESC"
label="PLG_TINY_FIELD_NONBREAKING_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="template" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_TEMPLATE_DESC"
label="PLG_TINY_FIELD_TEMPLATE_LABEL"
>
<option value="0">JHIDE</option>
<option value="1">JSHOW</option>
</field>
<field name="blockquote" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_BLOCKQUOTE_DESC"
label="PLG_TINY_FIELD_BLOCKQUOTE_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="wordcount" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_WORDCOUNT_DESC"
label="PLG_TINY_FIELD_WORDCOUNT_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="spacer5" type="spacer"
hr="true"
/>
<field name="advimage" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_ADVIMAGE_DESC"
label="PLG_TINY_FIELD_ADVIMAGE_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="advlink" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_ADVLINK_DESC"
label="PLG_TINY_FIELD_ADVLINK_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="advlist" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_ADVLIST_DESC"
label="PLG_TINY_FIELD_ADVLIST_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="autosave" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_SAVEWARNING_DESC"
label="PLG_TINY_FIELD_SAVEWARNING_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="contextmenu" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_CONTEXTMENU_DESC"
label="PLG_TINY_FIELD_CONTEXTMENU_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="inlinepopups" type="radio"
class="btn-group"
default="1"
description="PLG_TINY_FIELD_INLINEPOPUPS_DESC"
label="PLG_TINY_FIELD_INLINEPOPUPS_LABEL"
>
<option value="0">JOFF</option>
<option value="1">JON</option>
</field>
<field name="spacer6" type="spacer"
hr="true"
/>
<field name="custom_plugin" type="text"
description="PLG_TINY_FIELD_CUSTOMPLUGIN_DESC"
label="PLG_TINY_FIELD_CUSTOMPLUGIN_LABEL"
/>
<field name="custom_button" type="text"
description="PLG_TINY_FIELD_CUSTOMBUTTON_DESC"
label="PLG_TINY_FIELD_CUSTOMBUTTON_LABEL"
/>
</fieldset>
</fields>
</config>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,264 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Extension.Joomla
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
/**
* Joomla! master extension plugin.
*
* @package Joomla.Plugin
* @subpackage Extension.Joomla
* @since 1.6
*/
class PlgExtensionJoomla extends JPlugin
{
/**
* @var integer Extension Identifier
* @since 1.6
*/
private $eid = 0;
/**
* @var JInstaller Installer object
* @since 1.6
*/
private $installer = null;
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Adds an update site to the table if it doesn't exist.
*
* @param string $name The friendly name of the site
* @param string $type The type of site (e.g. collection or extension)
* @param string $location The URI for the site
* @param boolean $enabled If this site is enabled
*
* @return void
*
* @since 1.6
*/
private function addUpdateSite($name, $type, $location, $enabled)
{
$db = JFactory::getDbo();
// Look if the location is used already; doesn't matter what type you can't have two types at the same address, doesn't make sense
$query = $db->getQuery(true)
->select('update_site_id')
->from('#__update_sites')
->where('location = ' . $db->quote($location));
$db->setQuery($query);
$update_site_id = (int) $db->loadResult();
// If it doesn't exist, add it!
if (!$update_site_id)
{
$query->clear()
->insert('#__update_sites')
->columns(array($db->quoteName('name'), $db->quoteName('type'), $db->quoteName('location'), $db->quoteName('enabled')))
->values($db->quote($name) . ', ' . $db->quote($type) . ', ' . $db->quote($location) . ', ' . (int) $enabled);
$db->setQuery($query);
if ($db->execute())
{
// Link up this extension to the update site
$update_site_id = $db->insertid();
}
}
// Check if it has an update site id (creation might have faileD)
if ($update_site_id)
{
// Look for an update site entry that exists
$query->clear()
->select('update_site_id')
->from('#__update_sites_extensions')
->where('update_site_id = ' . $update_site_id)
->where('extension_id = ' . $this->eid);
$db->setQuery($query);
$tmpid = (int) $db->loadResult();
if (!$tmpid)
{
// Link this extension to the relevant update site
$query->clear()
->insert('#__update_sites_extensions')
->columns(array($db->quoteName('update_site_id'), $db->quoteName('extension_id')))
->values($update_site_id . ', ' . $this->eid);
$db->setQuery($query);
$db->execute();
}
}
}
/**
* Handle post extension install update sites
*
* @param JInstaller $installer Installer object
* @param integer $eid Extension Identifier
*
* @return void
*
* @since 1.6
*/
public function onExtensionAfterInstall($installer, $eid )
{
if ($eid)
{
$this->installer = $installer;
$this->eid = $eid;
// After an install we only need to do update sites
$this->processUpdateSites();
}
}
/**
* Handle extension uninstall
*
* @param JInstaller $installer Installer instance
* @param integer $eid Extension id
* @param integer $result Installation result
*
* @return void
*
* @since 1.6
*/
public function onExtensionAfterUninstall($installer, $eid, $result)
{
if ($eid)
{
// Wipe out any update_sites_extensions links
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->delete('#__update_sites_extensions')
->where('extension_id = ' . $eid);
$db->setQuery($query);
$db->execute();
// Delete any unused update sites
$query->clear()
->select('update_site_id')
->from('#__update_sites_extensions');
$db->setQuery($query);
$results = $db->loadColumn();
if (is_array($results))
{
// So we need to delete the update sites and their associated updates
$updatesite_delete = $db->getQuery(true);
$updatesite_delete->delete('#__update_sites');
$updatesite_query = $db->getQuery(true);
$updatesite_query->select('update_site_id')
->from('#__update_sites');
// If we get results back then we can exclude them
if (count($results))
{
$updatesite_query->where('update_site_id NOT IN (' . implode(',', $results) . ')');
$updatesite_delete->where('update_site_id NOT IN (' . implode(',', $results) . ')');
}
// So let's find what update sites we're about to nuke and remove their associated extensions
$db->setQuery($updatesite_query);
$update_sites_pending_delete = $db->loadColumn();
if (is_array($update_sites_pending_delete) && count($update_sites_pending_delete))
{
// Nuke any pending updates with this site before we delete it
// TODO: investigate alternative of using a query after the delete below with a query and not in like above
$query->clear()
->delete('#__updates')
->where('update_site_id IN (' . implode(',', $update_sites_pending_delete) . ')');
$db->setQuery($query);
$db->execute();
}
// Note: this might wipe out the entire table if there are no extensions linked
$db->setQuery($updatesite_delete);
$db->execute();
}
// Last but not least we wipe out any pending updates for the extension
$query->clear()
->delete('#__updates')
->where('extension_id = '. $eid);
$db->setQuery($query);
$db->execute();
}
}
/**
* After update of an extension
*
* @param JInstaller $installer Installer object
* @param integer $eid Extension identifier
*
* @return void
*
* @since 1.6
*/
public function onExtensionAfterUpdate($installer, $eid)
{
if ($eid)
{
$this->installer = $installer;
$this->eid = $eid;
// handle any update sites
$this->processUpdateSites();
}
}
/**
* Processes the list of update sites for an extension.
*
* @return void
*
* @since 1.6
*/
private function processUpdateSites()
{
$manifest = $this->installer->getManifest();
$updateservers = $manifest->updateservers;
if ($updateservers)
{
$children = $updateservers->children();
}
else
{
$children = array();
}
if (count($children))
{
foreach ($children as $child)
{
$attrs = $child->attributes();
$this->addUpdateSite($attrs['name'], $attrs['type'], $child, true);
}
}
else
{
$data = (string) $updateservers;
if (strlen($data))
{
// We have a single entry in the update server line, let us presume this is an extension line
$this->addUpdateSite(JText::_('PLG_EXTENSION_JOOMLA_UNKNOWN_SITE'), 'extension', $data, true);
}
}
}
}

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="extension">
<name>plg_extension_joomla</name>
<author>Joomla! Project</author>
<creationDate>May 2010</creationDate>
<copyright>Copyright (C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_EXTENSION_JOOMLA_XML_DESCRIPTION</description>
<files>
<filename plugin="joomla">joomla.php</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">en-GB.plg_extension_joomla.ini</language>
<language tag="en-GB">en-GB.plg_extension_joomla.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1,395 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Categories
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Finder adapter for Joomla Categories.
*
* @package Joomla.Plugin
* @subpackage Finder.Categories
* @since 2.5
*/
class PlgFinderCategories extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Categories';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_categories';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'category';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Category';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__categories';
/**
* The field the published state is stored in.
*
* @var string
* @since 2.5
*/
protected $state_field = 'published';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderDelete($context, $table)
{
if ($context == 'com_categories.category')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
/**
* Method to determine if the access level of an item changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content has just been created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle categories here
if ($context == 'com_categories.category')
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
// Reindex the item
$this->reindex($row->id);
}
// Check if the parent access level is different
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Method to reindex the link information for an item that has been saved.
* This event is fired before the data is actually saved so we are going
* to queue the item to be indexed later.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle categories here
if ($context == 'com_categories.category')
{
// Query the database for the old access level and the parent if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle categories here
if ($context == 'com_categories.category')
{
// The category published state is tied to the parent category
// published state so we need to look up all published states
// before we change anything.
foreach ($pks as $pk)
{
/* TODO: The $item variable does not seem to be used at all
$query = clone($this->getStateQuery());
$query->where('a.id = ' . (int) $pk);
// Get the published states.
$this->db->setQuery($query);
$item = $this->db->loadObject();
*/
// Translate the state.
$state = null;
if ($item->parent_id != 1)
{
$state = $item->cat_state;
}
$temp = $this->translateState($value, $state);
// Update the item.
$this->change($pk, 'state', $temp);
// Reindex the item
$this->reindex($pk);
}
}
// Handle when the plugin is disabled
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
$item->setLanguage();
// Need to import component route helpers dynamically, hence the reason it's handled here
$path = JPATH_SITE . '/components/' . $item->extension . '/helpers/route.php';
if (is_file($path))
{
include_once $path;
}
$extension = ucfirst(substr($item->extension, 4));
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = $registry;
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
/* Add the meta-data processing instructions based on the categories
* configuration parameters.
*/
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
//$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Trigger the onContentPrepare event.
$item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $item->extension, $this->layout);
$class = $extension . 'HelperRoute';
if (class_exists($class) && method_exists($class, 'getCategoryRoute'))
{
$item->route = $class::getCategoryRoute($item->id);
}
else
{
$item->route = ContentHelperRoute::getCategoryRoute($item->slug, $item->catid);
}
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true))
{
$item->title = $title;
}
// Translate the state. Categories should only be published if the parent category is published.
$item->state = $this->translateState($item->state);
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Category');
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load com_content route helper as it is the fallback for routing in the indexer in this instance.
include_once JPATH_SITE . '/components/com_content/helpers/route.php';
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.title, a.alias, a.description AS summary, a.extension')
->select('a.created_user_id AS created_by, a.modified_time AS modified, a.modified_user_id AS modified_by')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.lft, a.parent_id, a.level')
->select('a.created_time AS start_date, a.published AS state, a.access, a.params');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias)
->from('#__categories AS a')
->where($db->quoteName('a.id') . ' > 1');
return $query;
}
/**
* Method to get a SQL query to load the published and access states for
* an article and category.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getStateQuery()
{
$query = $this->db->getQuery(true)
->select($this->db->quoteName('a.id'))
->select('a.' . $this->state_field . ' AS state, c.published AS cat_state')
->select('a.access, c.access AS cat_access')
->from($this->db->quoteName('#__categories') . ' AS a')
->join('LEFT', '#__categories AS c ON c.id = a.parent_id');
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_categories</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_CATEGORIES_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="categories">categories.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_categories.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_categories.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,449 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Contacts
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Finder adapter for Joomla Contacts.
*
* @package Joomla.Plugin
* @subpackage Finder.Contacts
* @since 2.5
*/
class PlgFinderContacts extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Contacts';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_contact';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'contact';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Contact';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__contact_details';
/**
* The field the published state is stored in.
*
* @var string
* @since 2.5
*/
protected $state_field = 'published';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to update the item link information when the item category is
* changed. This is fired when the item category is published or unpublished
* from the list view.
*
* @param string $extension The extension whose category has been updated.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderCategoryChangeState($extension, $pks, $value)
{
// Make sure we're handling com_contact categories
if ($extension == 'com_contact')
{
$this->categoryStateChange($pks, $value);
}
}
/**
* Method to remove the link information for items that have been deleted.
*
* This event will fire when contacts are deleted and when an indexed item is deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_contact.contact')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
/**
* Method to determine if the access level of an item changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content has just been created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle contacts here
if ($context == 'com_contact.contact')
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item
$this->reindex($row->id);
}
// Check for access changes in the category
if ($context == 'com_categories.category')
{
// Check if the access levels are different
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Method to reindex the link information for an item that has been saved.
* This event is fired before the data is actually saved so we are going
* to queue the item to be indexed later.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle contacts here
if ($context == 'com_contact.contact')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category
if ($context == 'com_categories.category')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle contacts here
if ($context == 'com_contact.contact')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
$item->setLanguage();
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = ContactHelperRoute::getContactRoute($item->slug, $item->catslug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true))
{
$item->title = $title;
}
/*
* Add the meta-data processing instructions based on the contact
* configuration parameters.
*/
// Handle the contact position.
if ($item->params->get('show_position', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'position');
}
// Handle the contact street address.
if ($item->params->get('show_street_address', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'address');
}
// Handle the contact city.
if ($item->params->get('show_suburb', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'city');
}
// Handle the contact region.
if ($item->params->get('show_state', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'region');
}
// Handle the contact country.
if ($item->params->get('show_country', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'country');
}
// Handle the contact zip code.
if ($item->params->get('show_postcode', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'zip');
}
// Handle the contact telephone number.
if ($item->params->get('show_telephone', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'telephone');
}
// Handle the contact fax number.
if ($item->params->get('show_fax', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'fax');
}
// Handle the contact e-mail address.
if ($item->params->get('show_email', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'email');
}
// Handle the contact mobile number.
if ($item->params->get('show_mobile', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'mobile');
}
// Handle the contact webpage.
if ($item->params->get('show_webpage', true))
{
$item->addInstruction(FinderIndexer::META_CONTEXT, 'webpage');
}
// Handle the contact user name.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'user');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Contact');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Add the region taxonomy data.
if (!empty($item->region) && $this->params->get('tax_add_region', true))
{
$item->addTaxonomy('Region', $item->region);
}
// Add the country taxonomy data.
if (!empty($item->country) && $this->params->get('tax_add_country', true))
{
$item->addTaxonomy('Country', $item->country);
}
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
require_once JPATH_SITE . '/components/com_contact/helpers/route.php';
// This is a hack to get around the lack of a route helper.
FinderIndexerHelper::getContentPath('index.php?option=com_contact');
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.name AS title, a.alias, a.con_position AS position, a.address, a.created AS start_date')
->select('a.created_by_alias, a.modified, a.modified_by')
->select('a.metakey, a.metadesc, a.metadata, a.language')
->select('a.sortname1, a.sortname2, a.sortname3')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('a.suburb AS city, a.state AS region, a.country, a.postcode AS zip')
->select('a.telephone, a.fax, a.misc AS summary, a.email_to AS email, a.mobile')
->select('a.webpage, a.access, a.published AS state, a.ordering, a.params, a.catid')
->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$query->select($case_when_category_alias)
->select('u.name')
->from('#__contact_details AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->join('LEFT', '#__users AS u ON u.id = a.user_id');
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_contacts</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_CONTACTS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="contacts">contacts.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_contacts.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_contacts.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,375 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Content
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Finder adapter for com_content.
*
* @package Joomla.Plugin
* @subpackage Finder.Content
* @since 2.5
*/
class PlgFinderContent extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Content';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_content';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'article';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Article';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__content';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to update the item link information when the item category is
* changed. This is fired when the item category is published or unpublished
* from the list view.
*
* @param string $extension The extension whose category has been updated.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderCategoryChangeState($extension, $pks, $value)
{
// Make sure we're handling com_content categories
if ($extension == 'com_content')
{
$this->categoryStateChange($pks, $value);
}
}
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_content.article')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
/**
* Method to determine if the access level of an item changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content has just been created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle articles here
if ($context == 'com_content.article' || $context == 'com_content.form')
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item
$this->reindex($row->id);
}
// Check for access changes in the category
if ($context == 'com_categories.category')
{
// Check if the access levels are different
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Method to reindex the link information for an item that has been saved.
* This event is fired before the data is actually saved so we are going
* to queue the item to be indexed later.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle articles here
if ($context == 'com_content.article' || $context == 'com_content.form')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category
if ($context == 'com_categories.category')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle articles here
if ($context == 'com_content.article' || $context == 'com_content.form')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
$item->setLanguage();
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = JComponentHelper::getParams('com_content', true);
$item->params->merge($registry);
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Trigger the onContentPrepare event.
$item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
$item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = ContentHelperRoute::getArticleRoute($item->slug, $item->catslug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true))
{
$item->title = $title;
}
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Add the meta-data processing instructions.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Translate the state. Articles should only be published if the category is published.
$item->state = $this->translateState($item->state, $item->cat_state);
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Article');
// Add the author taxonomy data.
if (!empty($item->author) || !empty($item->created_by_alias))
{
$item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
}
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
include_once JPATH_SITE . '/components/com_content/helpers/route.php';
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body')
->select('a.state, a.catid, a.created AS start_date, a.created_by')
->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$query->select($case_when_category_alias)
->select('u.name AS author')
->from('#__content AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid')
->join('LEFT', '#__users AS u ON u.id = a.created_by');
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_content</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_CONTENT_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="content">content.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_content.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_content.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

295
plugins/finder/k2/k2.php Normal file
View File

@ -0,0 +1,295 @@
<?php
/**
* @version $Id: k2.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
*/
defined('JPATH_BASE') or die ;
jimport('joomla.application.component.helper');
// Load the base adapter.
require_once JPATH_ADMINISTRATOR.'/components/com_finder/helpers/indexer/adapter.php';
class plgFinderK2 extends FinderIndexerAdapter
{
protected $context = 'K2';
protected $extension = 'com_k2';
protected $layout = 'item';
protected $type_title = 'K2 Item';
protected $table = '#__k2_items';
protected $state_field = 'published';
public function __construct(&$subject, $config)
{
parent::__construct($subject, $config);
$this->loadLanguage();
}
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_k2.item')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle articles here
if ($context == 'com_k2.item')
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item
$this->reindex($row->id);
}
// Check for access changes in the category
if ($context == 'com_k2.category')
{
// Update the state
$this->categoryStateChange(array($row->id), $row->published);
// Check if the access levels are different
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle articles here
if ($context == 'com_k2.item')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category
if ($context == 'com_k2.category')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
public function onFinderChangeState($context, $pks, $value)
{
// Items
if ($context == 'com_k2.item')
{
$this->itemStateChange($pks, $value);
}
// Categories
if ($context == 'com_k2.category')
{
$this->categoryStateChange($pks, $value);
}
}
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = JComponentHelper::getParams('com_k2', true);
$item->params->merge($registry);
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Trigger the onContentPrepare event.
$item->summary = FinderIndexerHelper::prepareContent($item->summary, $item->params);
$item->body = FinderIndexerHelper::prepareContent($item->body, $item->params);
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = K2HelperRoute::getItemRoute($item->slug, $item->catslug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true))
{
$item->title = $title;
}
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Add the meta-data processing instructions.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Translate the state. Articles should only be published if the category is published.
$item->state = $this->translateState($item->state, $item->cat_state);
// Translate the trash state. Articles should only be accesible if the category is accessible.
if ($item->trash || $item->cat_trash)
{
$item->state = 0;
}
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'K2 Item');
// Add the author taxonomy data.
if (!empty($item->author) || !empty($item->created_by_alias))
{
$item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
}
// Add the category taxonomy data.
$item->addTaxonomy('K2 Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
if (method_exists('FinderIndexer', 'getInstance'))
{
FinderIndexer::getInstance()->index($item);
}
else
{
FinderIndexer::index($item);
}
}
protected function setup()
{
// Load dependent classes.
include_once JPATH_SITE.'/components/com_k2/helpers/route.php';
return true;
}
protected function getListQuery($sql = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$sql = is_a($sql, 'JDatabaseQuery') ? $sql : $db->getQuery(true);
$sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body');
$sql->select('a.published as state, a.catid, a.created AS start_date, a.created_by');
$sql->select('a.created_by_alias, a.modified, a.modified_by, a.params');
$sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.ordering');
$sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date');
$sql->select('a.trash, c.trash AS cat_trash');
$sql->select('c.name AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $sql->charLength('a.alias');
$case_when_item_alias .= ' THEN ';
$a_id = $sql->castAsChar('a.id');
$case_when_item_alias .= $sql->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$sql->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $sql->charLength('c.alias');
$case_when_category_alias .= ' THEN ';
$c_id = $sql->castAsChar('c.id');
$case_when_category_alias .= $sql->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$sql->select($case_when_category_alias);
$sql->select('u.name AS author');
$sql->from('#__k2_items AS a');
$sql->join('LEFT', '#__k2_categories AS c ON c.id = a.catid');
$sql->join('LEFT', '#__users AS u ON u.id = a.created_by');
return $sql;
}
protected function checkCategoryAccess($row)
{
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName('access'));
$query->from($this->db->quoteName('#__k2_categories'));
$query->where($this->db->quoteName('id').' = '.(int)$row->id);
$this->db->setQuery($query);
// Store the access level to determine if it changes
$this->old_cataccess = $this->db->loadResult();
}
protected function categoryAccessChange($row)
{
$sql = clone($this->getStateQuery());
$sql->where('c.id = '.(int)$row->id);
// Get the access level.
$this->db->setQuery($sql);
$items = $this->db->loadObjectList();
// Adjust the access level for each item within the category.
foreach ($items as $item)
{
// Set the access level.
$temp = max($item->access, $row->access);
// Update the item.
$this->change((int)$item->id, 'access', $temp);
// Reindex the item
$this->reindex($item->id);
}
}
}

15
plugins/finder/k2/k2.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="finder" method="upgrade">
<name>plg_finder_k2</name>
<author>JoomlaWorks</author>
<creationDate>July 8th, 2013</creationDate>
<copyright>Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
<authorUrl>www.joomlaworks.net</authorUrl>
<version>2.6.7</version>
<description>PLG_FINDER_K2_DESCRIPTION</description>
<files>
<file plugin="k2">k2.php</file>
</files>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,365 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Newsfeeds
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Finder adapter for Joomla Newsfeeds.
*
* @package Joomla.Plugin
* @subpackage Finder.Newsfeeds
* @since 2.5
*/
class PlgFinderNewsfeeds extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Newsfeeds';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_newsfeeds';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'newsfeed';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'News Feed';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__newsfeeds';
/**
* The field the published state is stored in.
*
* @var string
* @since 2.5
*/
protected $state_field = 'published';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to update the item link information when the item category is
* changed. This is fired when the item category is published or unpublished
* from the list view.
*
* @param string $extension The extension whose category has been updated.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderCategoryChangeState($extension, $pks, $value)
{
// Make sure we're handling com_newsfeeds categories
if ($extension == 'com_newsfeeds')
{
$this->categoryStateChange($pks, $value);
}
}
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_newsfeeds.newsfeed')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
/**
* Method to determine if the access level of an item changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content has just been created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle news feeds here
if ($context == 'com_newsfeeds.newsfeed')
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item
$this->reindex($row->id);
}
// Check for access changes in the category
if ($context == 'com_categories.category')
{
// Check if the access levels are different
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Method to reindex the link information for an item that has been saved.
* This event is fired before the data is actually saved so we are going
* to queue the item to be indexed later.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle news feeds here
if ($context == 'com_newsfeeds.newsfeed')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category
if ($context == 'com_categories.category')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle news feeds here
if ($context == 'com_newsfeeds.newsfeed')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
$item->setLanguage();
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = $registry;
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = NewsfeedsHelperRoute::getNewsfeedRoute($item->slug, $item->catslug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
/*
* Add the meta-data processing instructions based on the newsfeeds
* configuration parameters.
*/
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'News Feed');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
require_once JPATH_SITE . '/components/com_newsfeeds/helpers/route.php';
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.catid, a.name AS title, a.alias, a.link AS link')
->select('a.published AS state, a.ordering, a.created AS start_date, a.params, a.access')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('a.metakey, a.metadesc, a.metadata, a.language')
->select('a.created_by, a.created_by_alias, a.modified, a.modified_by')
->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$query->select($case_when_category_alias)
->from('#__newsfeeds AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_newsfeeds</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_NEWSFEEDS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="newsfeeds">newsfeeds.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_newsfeeds.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_newsfeeds.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,361 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Tags
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
// Load the base adapter.
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Finder adapter for Joomla Tag.
*
* @package Joomla.Plugin
* @subpackage Finder.Tags
* @since 3.1
*/
class PlgFinderTags extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 3.1
*/
protected $context = 'Tags';
/**
* The extension name.
*
* @var string
* @since 3.1
*/
protected $extension = 'com_tags';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 3.1
*/
protected $layout = 'tag';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 3.1
*/
protected $type_title = 'Tag';
/**
* The table name.
*
* @var string
* @since 3.1
*/
protected $table = '#__tags';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* The field the published state is stored in.
*
* @var string
* @since 3.1
*/
protected $state_field = 'published';
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 3.1
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_tags.tag')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
/**
* Method to determine if the access level of an item changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content has just been created
*
* @return boolean True on success.
*
* @since 3.1
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle tags here.
if ($context == 'com_tags.tag')
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item
$this->reindex($row->id);
}
return true;
}
/**
* Method to reindex the link information for an item that has been saved.
* This event is fired before the data is actually saved so we are going
* to queue the item to be indexed later.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean True on success.
*
* @since 3.1
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle news feeds here
if ($context == 'com_tags.tag')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 3.1
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle tags here
if ($context == 'com_tags.tag')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 3.1
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
$item->setLanguage();
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = JComponentHelper::getParams('com_tags', true);
$item->params->merge($registry);
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = TagsHelperRoute::getTagRoute($item->slug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
// Get the menu title if it exists.
$title = $this->getItemMenuTitle($item->url);
// Adjust the title if necessary.
if (!empty($title) && $this->params->get('use_menu_title', true))
{
$item->title = $title;
}
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Tag');
// Add the author taxonomy data.
if (!empty($item->author) || !empty($item->created_by_alias))
{
$item->addTaxonomy('Author', !empty($item->created_by_alias) ? $item->created_by_alias : $item->author);
}
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 3.1
*/
protected function setup()
{
// Load dependent classes.
require_once JPATH_SITE . '/components/com_tags/helpers/route.php';
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 3.1
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.title, a.alias, a.description AS summary')
->select('a.created_time AS start_date, a.created_user_id AS created_by')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.access')
->select('a.modified_time AS modified, a.modified_user_id AS modified_by')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('a.published AS state, a.access, a.created_time AS start_date, a.params');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias)
->from('#__tags AS a');
// Join the #__users table
$query->select('u.name AS author')
->join('LEFT', '#__users AS u ON u.id = b.created_user_id')
->from('#__tags AS b');
// Exclude the ROOT item
$query->where($db->quoteName('a.id') . ' > 1');
return $query;
}
/**
* Method to get a SQL query to load the published and access states for the given tag.
*
* @return JDatabaseQuery A database object.
*
* @since 3.1
*/
protected function getStateQuery()
{
$query = $this->db->getQuery(true);
$query->select($this->db->quoteName('a.id'))
->select($this->db->quoteName('a.' . $this->state_field, 'state') . ', ' . $this->db->quoteName('a.access'))
->select('NULL AS cat_state, NULL AS cat_access')
->from($this->db->quoteName($this->table, 'a'));
return $query;
}
/**
* Method to get the query clause for getting items to update by time.
*
* @param string $time The modified timestamp.
*
* @return JDatabaseQuery A database object.
*
* @since 3.1
*/
protected function getUpdateQueryByTime($time)
{
// Build an SQL query based on the modified time.
$query = $this->db->getQuery(true)
->where('a.date >= ' . $this->db->quote($time));
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_tags</name>
<author>Joomla! Project</author>
<creationDate>February 2013</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_TAGS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="tags">tags.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_tags.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_tags.sys.ini</language>
</languages>
</extension>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,374 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Finder.Weblinks
*
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_BASE') or die;
// Load the base adapter.
require_once JPATH_ADMINISTRATOR . '/components/com_finder/helpers/indexer/adapter.php';
/**
* Finder adapter for Joomla Web Links.
*
* @package Joomla.Plugin
* @subpackage Finder.Weblinks
* @since 2.5
*/
class PlgFinderWeblinks extends FinderIndexerAdapter
{
/**
* The plugin identifier.
*
* @var string
* @since 2.5
*/
protected $context = 'Weblinks';
/**
* The extension name.
*
* @var string
* @since 2.5
*/
protected $extension = 'com_weblinks';
/**
* The sublayout to use when rendering the results.
*
* @var string
* @since 2.5
*/
protected $layout = 'weblink';
/**
* The type of content that the adapter indexes.
*
* @var string
* @since 2.5
*/
protected $type_title = 'Web Link';
/**
* The table name.
*
* @var string
* @since 2.5
*/
protected $table = '#__weblinks';
/**
* Load the language file on instantiation.
*
* @var boolean
* @since 3.1
*/
protected $autoloadLanguage = true;
/**
* Method to update the item link information when the item category is
* changed. This is fired when the item category is published or unpublished
* from the list view.
*
* @param string $extension The extension whose category has been updated.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderCategoryChangeState($extension, $pks, $value)
{
// Make sure we're handling com_weblinks categories
if ($extension == 'com_weblinks')
{
$this->categoryStateChange($pks, $value);
}
}
/**
* Method to remove the link information for items that have been deleted.
*
* @param string $context The context of the action being performed.
* @param JTable $table A JTable object containing the record to be deleted
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterDelete($context, $table)
{
if ($context == 'com_weblinks.weblink')
{
$id = $table->id;
}
elseif ($context == 'com_finder.index')
{
$id = $table->link_id;
}
else
{
return true;
}
// Remove the items.
return $this->remove($id);
}
/**
* Method to determine if the access level of an item changed.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content has just been created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderAfterSave($context, $row, $isNew)
{
// We only want to handle web links here. We need to handle front end and back end editing.
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form' )
{
// Check if the access levels are different
if (!$isNew && $this->old_access != $row->access)
{
// Process the change.
$this->itemAccessChange($row);
}
// Reindex the item
$this->reindex($row->id);
}
// Check for access changes in the category
if ($context == 'com_categories.category')
{
// Check if the access levels are different
if (!$isNew && $this->old_cataccess != $row->access)
{
$this->categoryAccessChange($row);
}
}
return true;
}
/**
* Method to reindex the link information for an item that has been saved.
* This event is fired before the data is actually saved so we are going
* to queue the item to be indexed later.
*
* @param string $context The context of the content passed to the plugin.
* @param JTable $row A JTable object
* @param boolean $isNew If the content is just about to be created
*
* @return boolean True on success.
*
* @since 2.5
* @throws Exception on database error.
*/
public function onFinderBeforeSave($context, $row, $isNew)
{
// We only want to handle web links here
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkItemAccess($row);
}
}
// Check for access levels from the category
if ($context == 'com_categories.category')
{
// Query the database for the old access level if the item isn't new
if (!$isNew)
{
$this->checkCategoryAccess($row);
}
}
return true;
}
/**
* Method to update the link information for items that have been changed
* from outside the edit screen. This is fired when the item is published,
* unpublished, archived, or unarchived from the list view.
*
* @param string $context The context for the content passed to the plugin.
* @param array $pks A list of primary key ids of the content that has changed state.
* @param integer $value The value of the state that the content has been changed to.
*
* @return void
*
* @since 2.5
*/
public function onFinderChangeState($context, $pks, $value)
{
// We only want to handle web links here
if ($context == 'com_weblinks.weblink' || $context == 'com_weblinks.form')
{
$this->itemStateChange($pks, $value);
}
// Handle when the plugin is disabled
if ($context == 'com_plugins.plugin' && $value === 0)
{
$this->pluginDisable($pks);
}
}
/**
* Method to index an item. The item must be a FinderIndexerResult object.
*
* @param FinderIndexerResult $item The item to index as an FinderIndexerResult object.
* @param string $format The item format
*
* @return void
*
* @since 2.5
* @throws Exception on database error.
*/
protected function index(FinderIndexerResult $item, $format = 'html')
{
// Check if the extension is enabled
if (JComponentHelper::isEnabled($this->extension) == false)
{
return;
}
$item->setLanguage();
// Initialize the item parameters.
$registry = new JRegistry;
$registry->loadString($item->params);
$item->params = $registry;
$registry = new JRegistry;
$registry->loadString($item->metadata);
$item->metadata = $registry;
// Build the necessary route and path information.
$item->url = $this->getURL($item->id, $this->extension, $this->layout);
$item->route = WeblinksHelperRoute::getWeblinkRoute($item->slug, $item->catslug);
$item->path = FinderIndexerHelper::getContentPath($item->route);
/*
* Add the meta-data processing instructions based on the newsfeeds
* configuration parameters.
*/
// Add the meta-author.
$item->metaauthor = $item->metadata->get('author');
// Handle the link to the meta-data.
$item->addInstruction(FinderIndexer::META_CONTEXT, 'link');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
$item->addInstruction(FinderIndexer::META_CONTEXT, 'created_by_alias');
// Add the type taxonomy data.
$item->addTaxonomy('Type', 'Web Link');
// Add the category taxonomy data.
$item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
// Add the language taxonomy data.
$item->addTaxonomy('Language', $item->language);
// Get content extras.
FinderIndexerHelper::getContentExtras($item);
// Index the item.
$this->indexer->index($item);
}
/**
* Method to setup the indexer to be run.
*
* @return boolean True on success.
*
* @since 2.5
*/
protected function setup()
{
// Load dependent classes.
require_once JPATH_SITE . '/components/com_weblinks/helpers/route.php';
return true;
}
/**
* Method to get the SQL query used to retrieve the list of content items.
*
* @param mixed $query A JDatabaseQuery object or null.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getListQuery($query = null)
{
$db = JFactory::getDbo();
// Check if we can use the supplied SQL query.
$query = $query instanceof JDatabaseQuery ? $query : $db->getQuery(true)
->select('a.id, a.catid, a.title, a.alias, a.url AS link, a.description AS summary')
->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.ordering')
->select('a.created_by_alias, a.modified, a.modified_by')
->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date')
->select('a.state AS state, a.created AS start_date, a.params')
->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
// Handle the alias CASE WHEN portion of the query
$case_when_item_alias = ' CASE WHEN ';
$case_when_item_alias .= $query->charLength('a.alias', '!=', '0');
$case_when_item_alias .= ' THEN ';
$a_id = $query->castAsChar('a.id');
$case_when_item_alias .= $query->concatenate(array($a_id, 'a.alias'), ':');
$case_when_item_alias .= ' ELSE ';
$case_when_item_alias .= $a_id.' END as slug';
$query->select($case_when_item_alias);
$case_when_category_alias = ' CASE WHEN ';
$case_when_category_alias .= $query->charLength('c.alias', '!=', '0');
$case_when_category_alias .= ' THEN ';
$c_id = $query->castAsChar('c.id');
$case_when_category_alias .= $query->concatenate(array($c_id, 'c.alias'), ':');
$case_when_category_alias .= ' ELSE ';
$case_when_category_alias .= $c_id.' END as catslug';
$query->select($case_when_category_alias)
->from('#__weblinks AS a')
->join('LEFT', '#__categories AS c ON c.id = a.catid');
return $query;
}
/**
* Method to get the query clause for getting items to update by time.
*
* @param string $time The modified timestamp.
*
* @return JDatabaseQuery A database object.
*
* @since 2.5
*/
protected function getUpdateQueryByTime($time)
{
// Build an SQL query based on the modified time.
$query = $this->db->getQuery(true)
->where('a.date >= ' . $this->db->quote($time));
return $query;
}
}

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="3.1" type="plugin" group="finder" method="upgrade">
<name>plg_finder_weblinks</name>
<author>Joomla! Project</author>
<creationDate>August 2011</creationDate>
<copyright>(C) 2005 - 2013 Open Source Matters. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<authorEmail>admin@joomla.org</authorEmail>
<authorUrl>www.joomla.org</authorUrl>
<version>3.0.0</version>
<description>PLG_FINDER_WEBLINKS_XML_DESCRIPTION</description>
<scriptfile>script.php</scriptfile>
<files>
<file plugin="weblinks">weblinks.php</file>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_weblinks.ini</language>
<language tag="en-GB">language/en-GB/en-GB.plg_finder_weblinks.sys.ini</language>
</languages>
</extension>

1
plugins/index.html Normal file
View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<josetta>
<context>com_k2_category</context>
<name>K2 Category</name>
<table>#__k2_categories</table>
<reference>
<id>
<column>id</column>
<type>int</type>
<size>11</size>
</id>
<title>
<column>name</column>
<type>josettatext</type>
<size>255</size>
</title>
<published>
<column>published</column>
<type>int</type>
<size>6</size>
</published>
<parent>
<column>parent</column>
<type>int</type>
<size>11</size>
</parent>
</reference>
<reference_filters>
<reference_filter>
<table>#__k2_categories</table>
<column>trash</column>
<value>0</value>
</reference_filter>
</reference_filters>
</josetta>

View File

@ -0,0 +1,131 @@
<?xml version="1.0" encoding="UTF-8"?>
<josetta>
<fields>
<field>
<id>name</id>
<name>K2_TITLE</name>
<description></description>
<column>name</column>
<type>josettatext</type>
<size>60</size>
<length>255</length>
<translate>yes</translate>
<display>yes</display>
<require>yes</require>
</field>
<field>
<id>alias</id>
<name>K2_TITLE_ALIAS</name>
<description></description>
<column>alias</column>
<type>josettatext</type>
<size>60</size>
<length>255</length>
<translate>yes</translate>
<display>yes</display>
<require>no</require>
</field>
<field>
<id>parent</id>
<name>K2_PARENT_CATEGORY</name>
<column>parent</column>
<type>k2languagecategory</type>
<addfieldpath>/plugins/josetta_ext/k2item/fields</addfieldpath>
<translate>yes</translate>
<display>yes</display>
<require>yes</require>
<show_root>yes</show_root>
</field>
<field>
<id>description</id>
<name>K2_DESCRIPTION</name>
<description></description>
<column>description</column>
<type>editor</type>
<filter>JComponentHelper::filterText</filter>
<size>0</size>
<length>0</length>
<translate>yes</translate>
<display>yes</display>
<require>no</require>
</field>
<field>
<id>image</id>
<name>image</name>
<description></description>
<column>image</column>
<translate>no</translate>
<display>no</display>
<require>no</require>
</field>
<field>
<id>metadesc</id>
<name>K2_DESCRIPTION</name>
<description></description>
<column>metadesc</column>
<type>textarea</type>
<size>0</size>
<length>0</length>
<translate>yes</translate>
<display>yes</display>
<require>no</require>
</field>
<field>
<id>metakey</id>
<name>K2_KEYWORDS</name>
<description></description>
<column>metakey</column>
<type>textarea</type>
<size>0</size>
<length>0</length>
<translate>yes</translate>
<display>yes</display>
<require>no</require>
</field>
<field>
<id>language</id>
<name>K2_LANGUAGE</name>
<column>language</column>
<type>language</type>
<size>0</size>
<length>0</length>
<translate>no</translate>
<display>no</display>
<require>no</require>
<grid>yes</grid>
</field>
<field>
<id>access</id>
<name>access</name>
<column>access</column>
<translate>no</translate>
<display>no</display>
<require>no</require>
</field>
<field>
<id>extraFieldsGroup</id>
<name>extraFieldsGroup</name>
<column>extraFieldsGroup</column>
<translate>no</translate>
<display>no</display>
<require>no</require>
</field>
<field>
<id>attribs</id>
<name>attribs</name>
<column>params</column>
<translate>no</translate>
<display>no</display>
<require>no</require>
</field>
<field>
<id>xreference</id>
<name>xreference</name>
<column>xreference</column>
<translate>no</translate>
<display>no</display>
<require>no</require>
<grid>no</grid>
</field>
</fields>
</josetta>

View File

@ -0,0 +1,308 @@
<?php
/**
* @version $Id: k2category.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
*/
defined('_JEXEC') or die;
// include K2Base Josetta plugin, which shares many methods and thus is used as a base class
require_once JPATH_PLUGINS . '/josetta_ext/k2item/classes/basek2plugin.php';
class plgJosetta_extK2Category extends plgJosetta_extBaseK2Plugin
{
protected $_context = 'com_k2_category';
protected $_defaultTable = 'K2Category';
/**
* Method to build the dropdown of josetta translator screen
*
* @return array
*
*/
public function onJosettaGetTypes()
{
$this->loadLanguages();
$item = array(self::$this->_context => 'K2 ' . JText::_('K2_CATEGORIES'));
$items[] = $item;
return $items;
}
/**
* Overriden method, to add indentation to the list of categories
*
*/
public function onJosettaLoadItems($context, $state)
{
if ((!empty($context) && ($context != $this->_context)))
{
return null;
}
// read data. Can't use parent, as this would slice the results
// using limitstart and limit. K2 needs to slice later on,
// after indenting has been done
$items = array();
$db = JFactory::getDbo();
$this->_buildItemsListQuery($state);
$db->setQuery($this->_query);
$rawItems = $db->loadObjectList();
// Check for a database error.
if ($db->getErrorNum())
{
ShlSystem_Log::logError(__METHOD__ . ': ' . $db->getErrorMsg());
$rawItems = array();
}
// now indent
if (!empty($rawItems))
{
// Joomla! framework menu utility used to indent
// requires fields as parent_id instead of parent
foreach ($rawItems as &$item)
{
$item->title = $item->name;
$item->parent_id = $item->parent;
}
// indent cat list, for easier reading
$items = self::indentCategories($rawItems);
foreach ($items as &$item)
{
$item->name = JString::str_ireplace('<sup>|_</sup>', '', $item->treename);
}
// finally slice up to get the set we need
$items = array_slice($items, $state->get('list.start'), $state->get('list.limit'));
}
return $items;
}
/**
*
* @see JosettaClassesExtensionplugin::onJosettaLoadItem()
*/
public function onJosettaLoadItem($context, $id = '')
{
if ((!empty($context) && ($context != $this->_context)) || (empty($id)))
{
return null;
}
//call the parent base class method to load the context information
$category = parent::onJosettaLoadItem($context, $id);
// Display the parent category name instead of the ID
$db = JFactory::getDBO();
$db->setQuery('SELECT name FROM #__k2_categories WHERE id = ' . (int) $category->parent);
$category->parent = $db->loadResult();
// Convert the meta description and meta keywords params to fields so user can translate them
$categoryParams = new JRegistry($category->params);
$category->metadesc = $categoryParams->get('catMetaDesc');
$category->metakey = $categoryParams->get('catMetaKey');
return $category;
}
/**
* Save an item after it has been translated
* This will be called by Josetta when a user clicks
* the Save button. The context is passed so
* that each plugin knows if it must process the data or not
*
* if $item->reference_id is empty, this is
* a new item, otherwise we are updating the item
*
* $item->data contains the fields entered by the user
* that needs to be saved
*
*@param context type
*@param data in form of array
*
*return table id if data is inserted
*
*return false if error occurs
*
*/
public function onJosettaSaveItem($context, $item, &$errors)
{
if (($context != $this->_context))
{
return;
}
// load languages for form and error messages
$this->loadLanguages();
// Save
jimport('joomla.filesystem.file');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_k2/tables');
require_once(JPATH_ADMINISTRATOR . '/components/com_k2/lib/class.upload.php');
$row = JTable::getInstance('K2Category', 'Table');
$params = JComponentHelper::getParams('com_k2');
if (!$row->bind($item))
{
JosettaHelper::enqueueMessages($row->getError());
return false;
}
$row->parent = (int) $row->parent;
//$input = JRequest::get('post');
$filter = JFilterInput::getInstance();
$categoryParams = new JRegistry($row->params);
$categoryParams->set('catMetaDesc', $filter->clean($item['metadesc']));
$categoryParams->set('catMetaKey', $filter->clean($item['metakey']));
$row->params = $categoryParams->toString();
$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));
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 = ' . $row->parent . ' AND trash=0');
}
$savepath = JPATH_ROOT . '/media/k2/categories/';
if ($row->image && JFile::exists($savepath . $image))
{
$uniqueName = uniqid() . '.jpg';
JFile::copy($savepath . $row->image, $savepath . $uniqueName);
$row->image = $uniqueName;
}
if (!$row->check())
{
JosettaHelper::enqueueMessages($row->getError());
return false;
}
if (!$row->store())
{
JosettaHelper::enqueueMessages($row->getError());
return false;
}
if (!$params->get('disableCompactOrdering'))
$row->reorder('parent = ' . $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/';
// TODO: this will be renamed when used through Josetta
//$existingImage = JRequest::getVar('existingImage');
if (!empty($item['files']) && !empty($item['files']['image']))
{
if (($item['files']['image']['error'] === 0 || !empty($item['existingImage'])) && empty($item['del_image']))
{
if ($item['files']['image']['error'] === 0)
{
$image = $item['files']['image'];
}
else
{
$image = JPATH_SITE . '/' . JPath::clean($item['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
{
JosettaHelper::enqueueMessages($handle->error);
return false;
}
$row->image = $handle->file_dst_name;
}
}
// TODO: this will be renamed when used through Josetta
if (!empty($item['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())
{
JosettaHelper::enqueueMessages($row->getError());
return false;
}
//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();
return $row->id;
}
public static function indentCategories(&$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;
}
}

View File

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<extension version="2.5" type="plugin" group="josetta_ext" method="upgrade">
<name>Josetta - K2 Categories</name>
<author>JoomlaWorks</author>
<creationDate>July 8th, 2013</creationDate>
<copyright>Copyright (c) 2006 - 2013 JoomlaWorks Ltd. All rights reserved.</copyright>
<authorEmail>please-use-the-contact-form@joomlaworks.net</authorEmail>
<authorUrl>www.joomlaworks.net</authorUrl>
<version>2.6.7</version>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description></description>
<files>
<filename plugin="k2category">k2category.php</filename>
<filename>definitions.xml</filename>
<filename>fields_common.xml</filename>
</files>
</extension>

View File

@ -0,0 +1,219 @@
<?php
/**
* @version $Id: basek2plugin.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
*/
defined('_JEXEC') or die ;
// include base class of josetta plugins
require_once JPATH_ADMINISTRATOR.DS.'components/com_josetta/classes/extensionplugin.php';
class plgJosetta_extBaseK2Plugin extends JosettaadminClass_Extensionplugin
{
protected $_context = 'com_k2';
public function loadLanguages()
{
// load Joomla global language files
parent::loadLanguages();
$language = JFactory::getLanguage();
// load the administrator english language of the component
$language->load('com_k2', JPATH_ADMINISTRATOR, 'en-GB', true);
// load the administrator default language of the component
$language->load('com_k2', JPATH_ADMINISTRATOR, null, true);
}
protected function _setPath()
{
$this->_path = JPATH_PLUGINS.'/josetta_ext/'.$this->_name;
}
/**
* Hook for 3rd party extensions to add a path to search for
* additional subtypes fields definitions
* To be used by extensions, for instance to handle specific menu items
* subtypes, or module subtypes
*
* @param string context
*/
public function onJosettaAddSubTypePath($context, $subType)
{
if (!empty($context) && ($context != $this->_context))
{
return;
}
// a 3rd party extension will use this hook to store a full path to
// a directory where fields_*.xml files can be found
// to be appended to the translation form,
// for instance:
$this->_subTypePath[] = JPATH_PLUGINS.'/josetta_ext/'.$this->_name;
}
/**
* Method to build a list filter for the main translator view
* Used when such filter is not one of the Josetta built in filters type
*
* @return array
*
*/
public function onJosettaGet3rdPartyFilter($context, $filterType, $filterName, $current)
{
if (!empty($context) && ($context != $this->_context))
{
return;
}
$filterHtml = '';
switch( $filterType)
{
case 'k2languagecategory' :
// this is a category, so use Joomla html helper to build the drop down
$filterHtml = '';
$filterHtml .= JText::_('COM_JOSETTA_CONTENT_CATEGORY');
$filterHtml .= '<select name="'.$filterName.'" id="'.$filterName.'" class="inputbox" onchange="this.form.submit()">'."\n";
$filterHtml .= '<option value="0">'.JText::_('JOPTION_SELECT_CATEGORY').'</option>'."\n";
$categoriesSelectConfig = array('filter.published' => array(0, 1), 'filter.languages' => array('*', JosettaHelper::getSiteDefaultLanguage()));
require_once JPATH_PLUGINS.'/josetta_ext/k2item/helpers/helper.php';
$categoriesOptionsHtml = JosettaK2ItemHelper::getCategoryOptionsPerLanguage($categoriesSelectConfig);
$filterHtml .= JHtml::_('select.options', $categoriesOptionsHtml, 'value', 'text', (int)($current))."\n";
$filterHtml .= "</select>\n";
break;
default :
break;
}
return empty($filterHtml) ? null : $filterHtml;
}
/**
*
* Compute the subtitle of a provided item
* Subtitle is used for display to the user of an item
* to provide more context
* By default, we use an item category
*
* @param string $context
* @param mixed $item
*/
public function onJosettaGetSubtitle($context, $item)
{
if (!empty($context) && ($context != $this->_context))
{
return;
}
$subTitle = '';
if (empty($item))
{
return $subTitle;
}
return $subTitle;
}
/**
* Hook for module to add their own fields processing
* to the form xml
*
* @return string
*/
protected function _output3rdPartyFieldsXml($xmlData, $field, $itemType, $item, $originalItem, $targetLanguage)
{
switch( $xmlData->fieldType)
{
case 'k2languagecategory' :
//add extension tag if type category is present
//add option tag in list if present in jform
foreach ($field->option as $option)
{
$xmlData->subfield .= '<option value="'.$option->value->data().'">'.$option->title->data().'</option>';
}
//Important for developer if using category type extension must be defined in xml
$xmlData->other .= ' languages="'.$targetLanguage.'"';
$multiple = !empty($field->multiple) && $field->multiple->data() == 'yes';
$xmlData->other .= $multiple ? ' multiple="true"' : '';
break;
default :
break;
}
return $xmlData;
}
/**
* Format a the original field value for display on the translate view
*
* @param object $originalItem the actual data of the original item
* @param string $originalFieldTitle the field title
* @param object $field the Joomla! field object
* @param string the formatted, ready to display, string
*/
public function onJosettaGet3rdPartyFormatOriginalField($originalItem, $originalFieldTitle, $field)
{
$html = null;
switch( strtolower( $field->type))
{
case 'k2languagecategory' :
// element id can be stored in 2 different locations, depending on plugin
$elementId = empty($originalItem->request) || !isset($originalItem->request['id']) ? null : $originalItem->request['id'];
$elementId = is_null($elementId) ? $originalItem->$originalFieldTitle : $elementId;
if (is_array($elementId))
{
// mmultiple categories selected
$size = $field->element->getAttribute('size');
$size = empty($size) ? 10 : $size;
$html = '<select name="josetta_dummy" id="josetta_dummy" class="inputbox" size="'.$size.'" multiple="multiple" disabled="disabled">'."\n";
$categoriesSelectConfig = array('filter.published' => array(0, 1), 'filter.languages' => array('*', JosettaHelper::getSiteDefaultLanguage()));
require_once JPATH_PLUGINS.'/josetta_ext/k2item/helpers/helper.php';
$categoriesOptionsHtml = JosettaK2ItemHelper::getCategoryOptionsPerLanguage($categoriesSelectConfig);
$html .= JHtml::_('select.options', $categoriesOptionsHtml, 'value', 'text', $elementId)."\n";
$html .= "</select>\n";
}
else
{
// just one category
if (empty($elementId))
{
$html = JText::_('ROOT');
}
else
{
require_once JPATH_PLUGINS.'/josetta_ext/k2item/helpers/helper.php';
$categories = JosettaK2ItemHelper::getCategoriesPerLanguage(null, 'id');
$categoryDetails = empty($categories[$elementId]) ? null : $categories[$elementId];
$html = empty($categoryDetails) ? $elementId : $categoryDetails->title;
if ($html == 'ROOT')
{
$html = JText::_('ROOT');
}
}
}
break;
}
return $html;
}
}

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,46 @@
<?xml version="1.0" encoding="UTF-8"?>
<josetta>
<context>com_k2_item</context>
<name>K2 Item</name>
<table>#__k2_items</table>
<reference>
<id>
<column>id</column>
<type>int</type>
<size>11</size>
</id>
<title>
<column>title</column>
<type>josettatext</type>
<size>255</size>
</title>
<last_modified_by>
<column>modified_by</column>
</last_modified_by>
<last_modified>
<column>modified</column>
</last_modified>
<published>
<column>published</column>
<type>int</type>
<size>6</size>
</published>
</reference>
<filters>
<filter>
<type>k2languagecategory</type>
<id>filter_category</id>
<table>#__k2_categories</table>
<column>catid</column>
<default>0</default>
<addfieldpath>/plugins/josetta_ext/k2item/fields</addfieldpath>
</filter>
</filters>
<reference_filters>
<reference_filter>
<table>#__k2_items</table>
<column>trash</column>
<value>0</value>
</reference_filter>
</reference_filters>
</josetta>

View File

@ -0,0 +1 @@
<!DOCTYPE html><title></title>

View File

@ -0,0 +1,80 @@
/**
* @version $Id: k2extrafields.js 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
*/
$K2(document).ready(function() {
extraFields();
setTimeout(function() {
initExtraFieldsEditor();
}, 1000);
$K2('[id$=josetta_form_catid]').change(function() {
if ($K2(this).find('option:selected').attr('disabled')) {
alert(K2Language[4]);
$K2(this).val('0');
return;
}
extraFields();
});
});
function extraFields() {
var selectedValue = $K2('[id$=josetta_form_catid]').val();
var url = K2BasePath + '/index.php?option=com_k2&view=item&task=extraFields&cid=' + selectedValue + '&id=' + Josetta.josettaItemid;
$K2('#extraFieldsContainer').fadeOut('slow', function() {
$K2.ajax({
url : url,
type : 'get',
success : function(response) {
$K2('#extraFieldsContainer').html(response);
initExtraFieldsEditor();
$K2('img.calendar').each(function() {
inputFieldID = $K2(this).prev().attr('id');
imgFieldID = $K2(this).attr('id');
Calendar.setup({
inputField : inputFieldID,
ifFormat : "%Y-%m-%d",
button : imgFieldID,
align : "Tl",
singleClick : true
});
});
$K2('#extraFieldsContainer').fadeIn('slow');
}
});
});
}
function initExtraFieldsEditor() {
$K2('.k2ExtraFieldEditor').each(function() {
var id = $K2(this).attr('id');
if ( typeof tinymce != 'undefined') {
if (tinyMCE.get(id)) {
tinymce.EditorManager.remove(tinyMCE.get(id));
}
tinyMCE.execCommand('mceAddControl', false, id);
} else {
new nicEditor({
fullPanel : true,
maxHeight : 180,
iconsPath : K2BasePath + '/media/k2/assets/images/system/nicEditorIcons.gif'
}).panelInstance($K2(this).attr('id'));
}
});
}
function syncExtraFieldsEditor() {
$K2('.k2ExtraFieldEditor').each(function() {
editor = nicEditors.findEditor($K2(this).attr('id'));
if ( typeof editor != 'undefined') {
if (editor.content == '<br>' || editor.content == '<br />') {
editor.setContent('');
}
editor.saveContent();
}
});
}

View File

@ -0,0 +1,49 @@
<?php
/**
* @version $Id: k2extrafields.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
*/
defined('JPATH_PLATFORM') or die ;
class JFormFieldK2ExtraFields extends JFormField
{
protected $type = 'K2ExtraFields';
protected function getInput()
{
$document = JFactory::getDocument();
$document->addScriptDeclaration('var K2BasePath = "'.JURI::root(true).'";');
$document->addScript(JURI::root(true).'/plugins/josetta_ext/k2item/fields/k2extrafields.js');
K2Model::addIncludePath(JPATH_SITE.'/components/com_k2/models');
JLoader::register('K2HelperUtilities', JPATH_SITE.DS.'components'.DS.'com_k2'.DS.'helpers'.DS.'utilities.php');
$model = K2Model::getInstance('Item', 'K2Model');
$extraFields = $model->getItemExtraFields($this->value);
$html = '<div id="extraFieldsContainer">';
if (count($extraFields))
{
$html .= '<table class="admintable" id="extraFields">';
foreach ($extraFields as $extraField)
{
$html .= '<tr>
<td align="right" class="key">'.$extraField->name.'</td>
<td>'.$extraField->element.'</td>
</tr>';
}
$html .= '</table>';
}
else
{
$html .= '<span class="k2Note"> '.JText::_('K2_PLEASE_SELECT_A_CATEGORY_FIRST_TO_RETRIEVE_ITS_RELATED_EXTRA_FIELDS').' </span>';
}
$html .= '</div>';
return $html;
}
}

View File

@ -0,0 +1,75 @@
<?php
/**
* @version $Id: k2languagecategory.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
*/
defined('_JEXEC') or die ;
JFormHelper::loadFieldClass('list');
JFormHelper::loadFieldClass('category');
class JFormFieldK2LanguageCategory extends JFormFieldCategory
{
public $type = 'K2LanguageCategory';
public function __get($name)
{
switch ($name)
{
case 'element' :
return $this->$name;
break;
}
$value = parent::__get($name);
return $value;
}
protected function getOptions()
{
// Initialise variables.
$options = array();
$published = (string)$this->element['published'];
$languages = (string)$this->element['languages'];
$name = (string)$this->element['name'];
// insert custom options passed in xml file
$options = array();
if (!is_null($this->element->option))
{
foreach ($this->element->option as $option)
{
$options[] = JHtml::_('select.option', $option->getAttribute('value'), JText::_($option->data()));
}
}
// Filter over published state or not depending upon if it is present.
// include k2item helper, which has the method we want
require_once JPATH_PLUGINS.'/josetta_ext/k2item/helpers/helper.php';
if ($published)
{
$categoriesoptions = JosettaK2ItemHelper::getCategoryOptionsPerLanguage(array('filter.published' => explode(',', $published), 'filter.languages' => explode(',', $languages)));
}
else
{
$categoriesoptions = JosettaK2ItemHelper::getCategoryOptionsPerLanguage(array('filter.languages' => explode(',', $languages)));
}
$options = array_merge($options, $categoriesoptions);
if (!empty($this->element['show_root']) && strtolower($this->element['show_root']) == 'yes')
{
array_unshift($options, JHtml::_('select.option', '0', JText::_('JGLOBAL_ROOT')));
}
return $options;
}
}

View File

@ -0,0 +1,124 @@
/**
* @version $Id: k2tags.css 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
*/
.ui-autocomplete {
position: absolute;
margin: 0;
padding: 0;
list-style: none;
border: 1px solid #eee;
background-color: white;
border-right-color: #ddd;
border-bottom-color: #ddd;
text-align: left;sans-serif;
z-index: 50;
}
* html .ui-autocomplete {
width: 1px;
}/* without this, the menu expands to 100% in IE6 */
.ui-menu {
list-style: none;
padding: 2px;
margin: 0;
margin-top: -3px;
display: block;
float: left;
}
.ui-menu .ui-menu-item {
margin: 0;
padding: 0;
zoom: 0;
float: left;
clear: left;
width: 99%;
}
.ui-menu .ui-menu-item a {
text-decoration: none;
display: block;
padding: .2em .4em;
line-height: 1.5;
zoom: 1;
font-weight: bold;
}
.ui-menu .ui-menu-item a.ui-state-hover, .ui-menu .ui-menu-item a.ui-state-active {
margin: -1px;
background-color: #444;
color: #fff;
}
ul.tags {
background: #fff;
border: 1px solid #c0c0c0;
padding: 0;
cursor: default;
margin: 0;
padding: 0;
width: 99%;
}
ul.tags li {
-moz-border-radius: 4px;
-webkit-border-radius: 4px;
border-radius: 4px;
background: #cfe4fa;
color: #222;
border: 1px solid #b0d2f9;
padding: 2px 4px 4px;
list-style: none;
float: left;
clear: none;
height: 18px;
margin: 2px 1px 1px;
}
ul.tags li span.tagRemove {
color: #5279a1;
padding-left: 4px;
cursor: pointer;
}
ul.tags li span.tagRemove:hover {
color: #505050;
cursor: pointer;
}
ul.tags li input {
border: none;
padding-top: 2px;
background: none;
float: left;
clear: none;
margin:0;
padding:0;
height:18px;
}
ul.tags li input:focus {
background: none;
}
ul.tags li input.tagsLoading {
background: url(../../../../media/k2/assets/images/system/loader.gif) no-repeat 50% 50%;
}
ul.tags li.clr {
clear: both;
height: 0;
line-height: 0;
border: none;
float: none;
background: none;
padding: 0;
margin: 0;
}
ul.tags li.tagAdd {
border-color: #fff;
background: none;
}
ul.tags li.tagAdd input {
border: none;
}
span.k2Note {
display: block;
padding: 4px 0 0 0;
font-style: italic;
color: #777;
}

View File

@ -0,0 +1,80 @@
/**
* @version $Id: k2tags.js 1919 2013-02-11 19:02:02Z 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
*/
$K2(document).ready(function() {
// Generic function to get URL params passed in .js script include
function getUrlParams(targetScript, varName) {
var scripts = document.getElementsByTagName('script');
var scriptCount = scripts.length;
for (var a = 0; a < scriptCount; a++) {
var scriptSrc = scripts[a].src;
if (scriptSrc.indexOf(targetScript) >= 0) {
varName = varName.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var re = new RegExp("[\\?&]" + varName + "=([^&#]*)");
var parsedVariables = re.exec(scriptSrc);
if (parsedVariables !== null) {
return parsedVariables[1];
}
}
}
}
// Set the site root path
var K2SitePath = getUrlParams('k2.js', 'sitepath');
$K2('.tagRemove').click(function(event) {
event.preventDefault();
$K2(this).parent().remove();
});
/*
$K2('ul.tags').click(function() {
//$K2('#search-field').focus();
});
*/
$K2('.k2-search-field').keypress(function(event) {
if (event.which == '13') {
if ($K2(this).val() != '') {
$K2('<li id="' + this.attributes['rel'].value + '_tagAdd" class="addedTag">' + $K2(this).val() + '<span class="tagRemove" onclick="Josetta.itemChanged('+this.id+');$K2(this).parent().remove();">x</span><input type="hidden" value="' + $K2(this).val() + '" name="'+this.attributes['rel'].value + '[tags][]"></li>').insertBefore('.tags #' + this.attributes['rel'].value + '_tagAdd.tagAdd');
Josetta.itemChanged(this);
$K2(this).val('');
}
}
});
$K2('.k2-search-field').autocomplete({
source : function(request, response) {
var target = this.element[0];
$K2.ajax({
type : 'post',
url : K2SitePath + 'index.php?option=com_k2&view=item&task=tags',
data : 'q=' + request.term,
dataType : 'json',
success : function(data) {
target.removeClass('tagsLoading');
response($K2.map(data, function(item) {
return item;
}));
}
});
},
minLength : 3,
select : function(event, ui) {
$K2('<li id="' + this.attributes['rel'].value + '_tagAdd" class="addedTag">' + ui.item.label + '<span class="tagRemove" onclick="Josetta.itemChanged('+this.id+');$K2(this).parent().remove();">x</span><input type="hidden" value="' + ui.item.value + '" name="'+this.attributes['rel'].value + '[tags][]"></li>').insertBefore('.tags #' + this.attributes['rel'].value + '_tagAdd.tagAdd');
Josetta.itemChanged(this);
this.value = '';
return false;
},
search : function(event, ui) {
event.target.addClass('tagsLoading');
}
});
});

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