home/wuectly/www/administrator/components/com_plugins/plugins.php 0000604 00000001126 15245630344 0021574 0 ustar 00
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
defined('_JEXEC') or die;
JHtml::_('behavior.tabstate');
if (!JFactory::getUser()->authorise('core.manage', 'com_plugins'))
{
throw new JAccessExceptionNotallowed(JText::_('JERROR_ALERTNOAUTHOR'), 403);
}
$controller = JControllerLegacy::getInstance('Plugins');
$controller->execute(JFactory::getApplication()->input->get('task'));
$controller->redirect();
home/wuectly/www/libraries/f0f/form/field/plugins.php 0000604 00000004663 15245657454 0016711 0 ustar 00 static))
{
$this->static = $this->getStatic();
}
return $this->static;
break;
case 'repeatable':
if (empty($this->repeatable))
{
$this->repeatable = $this->getRepeatable();
}
return $this->repeatable;
break;
default:
return parent::__get($name);
}
}
/**
* Get the rendering of this field type for static display, e.g. in a single
* item view (typically a "read" task).
*
* @since 2.0
*
* @return string The field HTML
*/
public function getStatic()
{
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
return '' .
htmlspecialchars(F0FFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
'';
}
/**
* Get the rendering of this field type for a repeatable (grid) display,
* e.g. in a view listing many item (typically a "browse" task)
*
* @since 2.0
*
* @return string The field HTML
*/
public function getRepeatable()
{
$class = $this->element['class'] ? (string) $this->element['class'] : '';
return '' .
htmlspecialchars(F0FFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
'';
}
}
home/wuectly/www/libraries/joomla/form/fields/plugins.php 0000604 00000010327 15245657607 0017674 0 ustar 00
* @license GNU General Public License version 2 or later; see LICENSE
*/
defined('JPATH_PLATFORM') or die;
JFormHelper::loadFieldClass('list');
/**
* Form Field class for the Joomla Framework.
*
* @since 2.5.0
*/
class JFormFieldPlugins extends JFormFieldList
{
/**
* The field type.
*
* @var string
* @since 2.5.0
*/
protected $type = 'Plugins';
/**
* The path to folder for plugins.
*
* @var string
* @since 3.2
*/
protected $folder;
/**
* Method to get certain otherwise inaccessible properties from the form field object.
*
* @param string $name The property name for which to get the value.
*
* @return mixed The property value or null.
*
* @since 3.2
*/
public function __get($name)
{
switch ($name)
{
case 'folder':
return $this->folder;
}
return parent::__get($name);
}
/**
* Method to set certain otherwise inaccessible properties of the form field object.
*
* @param string $name The property name for which to set the value.
* @param mixed $value The value of the property.
*
* @return void
*
* @since 3.2
*/
public function __set($name, $value)
{
switch ($name)
{
case 'folder':
$this->folder = (string) $value;
break;
default:
parent::__set($name, $value);
}
}
/**
* Method to attach a JForm object to the field.
*
* @param SimpleXMLElement $element The SimpleXMLElement object representing the `` tag for the form field object.
* @param mixed $value The form field value to validate.
* @param string $group The field name group control value. This acts as an array container for the field.
* For example if the field has name="foo" and the group value is set to "bar" then the
* full field name would end up being "bar[foo]".
*
* @return boolean True on success.
*
* @see JFormField::setup()
* @since 3.2
*/
public function setup(SimpleXMLElement $element, $value, $group = null)
{
$return = parent::setup($element, $value, $group);
if ($return)
{
$this->folder = (string) $this->element['folder'];
}
return $return;
}
/**
* Method to get a list of options for a list input.
*
* @return array An array of JHtml options.
*
* @since 2.5.0
*/
protected function getOptions()
{
$folder = $this->folder;
$parentOptions = parent::getOptions();
if (!empty($folder))
{
// Get list of plugins
$db = JFactory::getDbo();
$query = $db->getQuery(true)
->select('element AS value, name AS text')
->from('#__extensions')
->where('folder = ' . $db->quote($folder))
->where('enabled = 1')
->order('ordering, name');
if ((string) $this->element['useaccess'] === 'true')
{
$groups = implode(',', JFactory::getUser()->getAuthorisedViewLevels());
$query->where($db->quoteName('access') . ' IN (' . $groups . ')');
}
$options = $db->setQuery($query)->loadObjectList();
$lang = JFactory::getLanguage();
$useGlobal = $this->element['useglobal'];
if ($useGlobal)
{
$globalValue = JFactory::getConfig()->get($this->fieldname);
}
foreach ($options as $i => $item)
{
$source = JPATH_PLUGINS . '/' . $folder . '/' . $item->value;
$extension = 'plg_' . $folder . '_' . $item->value;
$lang->load($extension . '.sys', JPATH_ADMINISTRATOR, null, false, true) || $lang->load($extension . '.sys', $source, null, false, true);
$options[$i]->text = JText::_($item->text);
// If we are using useglobal update the use global value text with the plugin text.
if ($useGlobal && isset($parentOptions[0]) && $item->value === $globalValue)
{
$text = JText::_($extension);
$parentOptions[0]->text = JText::sprintf('JGLOBAL_USE_GLOBAL_VALUE', ($text === '' || $text === $extension ? $item->value : $text));
}
}
}
else
{
JLog::add(JText::_('JFRAMEWORK_FORM_FIELDS_PLUGINS_ERROR_FOLDER_EMPTY'), JLog::WARNING, 'jerror');
}
return array_merge($parentOptions, $options);
}
}
home/wuectly/www/administrator/components/com_jce/helpers/plugins.php 0000604 00000034200 15245700674 0022321 0 ustar 00 $attribs) {
$attribs->type = 'command';
$commands[$name] = $attribs;
}
}
return $commands;
}
public static function isValidPlugin($name)
{
$plugins = self::getPlugins();
return isset($plugins[$name]);
}
/**
* Get a list of all code, pro and installed plugins.
*
* @return array $plugins
*/
public static function getPlugins()
{
$app = Factory::getApplication();
$language = Factory::getLanguage();
static $plugins;
if (!isset($plugins)) {
$plugins = array();
// get core json
$core = file_get_contents(__DIR__ . '/plugins.json');
// decode to object
$data = json_decode($core);
if ($data) {
foreach ($data as $name => $attribs) {
// skip if the plugin file is missing
if (!is_file(WF_EDITOR_MEDIA . '/tinymce/plugins/' . $name . '/plugin.js')) {
continue;
}
// update attributes
$attribs->type = 'plugin';
$attribs->path = WF_EDITOR_PLUGINS . '/' . $name;
$attribs->manifest = WF_EDITOR_PLUGINS . '/' . $name . '/' . $name . '.xml';
$attribs->image = '';
if (!isset($attribs->class)) {
$attribs->class = '';
}
// compatability
$attribs->name = $name;
// pass to array
$plugins[$name] = $attribs;
}
}
// get plugins external sources via event, eg: JCE Pro System Plugin
$app->triggerEvent('onWfPluginsHelperGetPlugins', array(&$plugins));
// get all installed plugins
$installed = PluginHelper::getPlugin('jce');
foreach ($installed as $item) {
// check for delimiter, only load editor plugins
if (!preg_match('/^editor[-_]/', $item->name)) {
continue;
}
// create path
$path = JPATH_PLUGINS . '/jce/' . $item->name;
// load language
$language->load('plg_jce_' . $item->name, JPATH_ADMINISTRATOR);
$language->load('plg_jce_' . $item->name, $path);
// get xml file
$file = $path . '/' . $item->name . '.xml';
if (is_file($file)) {
// load xml data
$xml = simplexml_load_file($file);
if ($xml) {
// check xml file is valid
if ((string) $xml->getName() != 'extension') {
continue;
}
// remove "editor-" or "editor_"
$name = substr($item->name, 7);
$attribs = new StdClass();
$attribs->name = $name;
$attribs->manifest = $file;
$params = $xml->fields;
$attribs->title = (string) $xml->name;
$attribs->icon = (string) $xml->icon;
$attribs->editable = 0;
// set default values
$attribs->image = '';
$attribs->class = '';
if ($xml->icon->attributes()) {
foreach ($xml->icon->attributes() as $key => $value) {
$attribs->$key = $value;
}
}
if ($attribs->image) {
$attribs->image = Uri::root(true) . '/' . $attribs->image;
}
// can't be editable without parameters
if ($params && count($params->children())) {
$attribs->editable = 1;
}
$row = (int) $xml->attributes()->row;
// set row from passed in value or 0
$attribs->row = $row;
// if an icon is set and no row, default to 4
if (!empty($attribs->icon) && !$row) {
$attribs->row = 4;
}
$attribs->description = (string) $xml->description;
$attribs->core = 0;
// relative path
$attribs->path = $path;
$attribs->url = 'plugins/jce/' . $item->name;
// get snake-case name to check for media folder
$snake_case_name = str_replace('-', '_', $item->name);
// url in Joomla media folder
if (is_dir(JPATH_SITE . '/media/plg_jce_' . $snake_case_name)) {
$attribs->url = 'media/plg_jce_' . $snake_case_name;
}
$attribs->type = 'plugin';
$plugins[$name] = $attribs;
}
}
}
}
return $plugins;
}
/**
* Get installed extensions.
*
* @return array $extensions
*/
public static function getExtensions($type = '')
{
$language = Factory::getLanguage();
static $extensions;
if (empty($extensions)) {
$extensions = array();
// recursively get all extension files
$files = Folder::files(WF_EDITOR_EXTENSIONS, '\.xml$', true, true);
foreach ($files as $file) {
$name = basename($file, '.xml');
$object = new StdClass();
$object->folder = basename(dirname($file));
$object->manifest = $file;
$object->plugins = array();
$object->name = $name;
$object->title = 'WF_' . strtoupper($object->folder) . '_' . strtoupper($name) . '_TITLE';
$object->description = '';
$object->id = $object->folder . '.' . $object->name;
$object->extension = $object->name;
// set as non-core by default
$object->core = 0;
// set as not editable by default
$object->editable = 0;
// set type
$object->type = $object->folder;
$extensions[$object->type][] = $object;
}
// get all installed plugins
$installed = PluginHelper::getPlugin('jce');
if (!empty($installed)) {
foreach ($installed as $p) {
// check for delimiter to remove legacy extensions
if (!preg_match('/[-_]/', $p->name)) {
continue;
}
// only load "extensions", not editor plugins
if (preg_match('/^editor[-_]/', $p->name)) {
continue;
}
// set path
$p->path = JPATH_PLUGINS . '/jce/' . $p->name;
$parts = preg_split('/[-_]/', $p->name, 2);
// get type and name
$p->folder = $parts[0];
$p->extension = $parts[1];
// plugin manifest, eg: filesystem-joomla.xml
$p->manifest = $p->path . '/' . $p->name . '.xml';
$p->plugins = array();
$p->description = '';
// load language
$language->load('plg_jce_' . $p->name, JPATH_ADMINISTRATOR);
$language->load('plg_jce_' . $p->name, $p->path);
list($p->type, $p->name) = preg_split('/[-_]/', $p->name, 2);
// create title from name parts, eg: plg_jce_filesystem_joomla
$p->title = 'plg_jce_' . $p->type . '_' . $p->name;
// create plugin id, eg: filesystem.joomla
$p->id = $p->type . '.' . $p->name;
// not core
$p->core = 0;
// set as not editable by default
$p->editable = 0;
$extensions[$p->type][] = $p;
}
}
}
if ($type && isset($extensions[$type])) {
return $extensions[$type];
}
return $extensions;
}
public static function addToProfile($id, $plugin)
{
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jce/tables');
// Add to Default Group
$profile = Table::getInstance('Profiles', 'JceTable');
if ($profile->load($id)) {
// Add to plugins list
$plugins = explode(',', $profile->plugins);
if (!in_array($plugin->name, $plugins)) {
$plugins[] = $plugin->name;
}
$profile->plugins = implode(',', $plugins);
if ($plugin->icon) {
if (in_array($plugin->name, preg_split('/[;,]+/', $profile->rows)) === false) {
// get rows as array
$rows = explode(';', $profile->rows);
if (count($rows)) {
// get key (row number)
$key = count($rows) - 1;
// get row contents as array
$row = explode(',', $rows[$key]);
// add plugin name to end of row
$row[] = $plugin->name;
// add row data back to rows array
$rows[$key] = implode(',', $row);
$profile->rows = implode(';', $rows);
}
}
}
if (!$profile->store()) {
throw new Exception(Text::_('WF_INSTALLER_PLUGIN_PROFILE_ERROR'));
}
}
return true;
}
public static function removeFromProfile($id, $plugin)
{
Table::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_jce/tables');
// Add to Default Group
$profile = Table::getInstance('Profiles', 'JceTable');
if ($profile->load($id)) {
// remove from plugins list
$plugins = explode(',', $profile->plugins);
$key = array_search($plugin->name, $plugins);
if ($key) {
unset($plugins[$key]);
$profile->plugins = implode(',', array_values($plugins));
}
if ($plugin->icon) {
// check if its in the profile
if (in_array($plugin->name, preg_split('/[;,]+/', $profile->rows))) {
$lists = array();
foreach (explode(';', $profile->rows) as $list) {
$icons = explode(',', $list);
foreach ($icons as $k => $v) {
if ($plugin->name == $v) {
unset($icons[$k]);
}
}
$lists[] = implode(',', $icons);
}
$profile->rows = implode(';', $lists);
}
if (!$profile->store()) {
throw new Exception(Text::sprintf('WF_INSTALLER_REMOVE_FROM_GROUP_ERROR', $plugin->name));
}
}
}
return true;
}
/**
* Add index.html files to each folder.
*/
private static function addIndexfiles($path)
{
// get the base file
$file = JPATH_ADMINISTRATOR . '/components/com_jce/index.html';
if (is_file($file) && is_dir($path)) {
File::copy($file, $path . '/' . basename($file));
// admin component
$folders = Folder::folders($path, '.', true, true);
foreach ($folders as $folder) {
File::copy($file, $folder . '/' . basename($file));
}
}
}
public static function postInstall($route, $plugin, $installer)
{
$db = Factory::getDBO();
// load the plugin and enable
if (isset($plugin->row) && $plugin->row > 0) {
$query = $db->getQuery(true);
$query->select('id')->from('#__wf_profiles')->where('name = ' . $db->Quote('Default') . ' OR id = 1');
$db->setQuery($query);
$id = $db->loadResult();
if ($id) {
if ($route == 'install') {
// add to profile
self::addToProfile($id, $plugin);
} else {
// remove from profile
self::removeFromProfile($id, $plugin);
}
}
}
if ($route == 'install') {
if ($plugin->type == 'extension') {
$plugin->path = $plugin->path . '/' . $plugin->name;
}
// add index.html files
self::addIndexfiles($plugin->path);
}
return true;
}
}
home/wuectly/www/libraries/fof/form/field/plugins.php 0000604 00000004663 15245723312 0016773 0 ustar 00 static))
{
$this->static = $this->getStatic();
}
return $this->static;
break;
case 'repeatable':
if (empty($this->repeatable))
{
$this->repeatable = $this->getRepeatable();
}
return $this->repeatable;
break;
default:
return parent::__get($name);
}
}
/**
* Get the rendering of this field type for static display, e.g. in a single
* item view (typically a "read" task).
*
* @since 2.0
*
* @return string The field HTML
*/
public function getStatic()
{
$class = $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
return '' .
htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
'';
}
/**
* Get the rendering of this field type for a repeatable (grid) display,
* e.g. in a view listing many item (typically a "browse" task)
*
* @since 2.0
*
* @return string The field HTML
*/
public function getRepeatable()
{
$class = $this->element['class'] ? (string) $this->element['class'] : '';
return '' .
htmlspecialchars(FOFFormFieldList::getOptionName($this->getOptions(), $this->value), ENT_COMPAT, 'UTF-8') .
'';
}
}