Файловый менеджер - Редактировать - /home/wuectly/www/03cbe/joomla.php.tar
Назад
home/wuectly/www/plugins/user/joomla/joomla.php 0000604 00000024417 15245530301 0015730 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage User.joomla * * @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\Language\Text; use Joomla\CMS\Uri\Uri; use Joomla\CMS\User\User; use Joomla\CMS\User\UserHelper; use Joomla\Registry\Registry; /** * Joomla User plugin * * @since 1.5 */ class PlgUserJoomla extends JPlugin { /** * Application object * * @var JApplicationCms * @since 3.2 */ protected $app; /** * Database object * * @var JDatabaseDriver * @since 3.2 */ protected $db; /** * Set as required the passwords fields when mail to user is set to No * * @param JForm $form The form to be altered. * @param mixed $data The associated data for the form. * * @return boolean * * @since 3.9.2 */ public function onContentPrepareForm($form, $data) { // Check we are manipulating a valid user form before modifying it. $name = $form->getName(); if ($name === 'com_users.user') { // In case there is a validation error (like duplicated user), $data is an empty array on save. // After returning from error, $data is an array but populated if (!$data) { $data = JFactory::getApplication()->input->get('jform', array(), 'array'); } if (is_array($data)) { $data = (object) $data; } // Passwords fields are required when mail to user is set to No if (empty($data->id) && !$this->params->get('mail_to_user', 1)) { $form->setFieldAttribute('password', 'required', 'true'); $form->setFieldAttribute('password2', 'required', 'true'); } } return true; } /** * Remove all sessions for the user name * * Method is called after user data is deleted from the database * * @param array $user Holds the user data * @param boolean $success True if user was successfully stored in the database * @param string $msg Message * * @return boolean * * @since 1.6 */ public function onUserAfterDelete($user, $success, $msg) { if (!$success) { return false; } $query = $this->db->getQuery(true) ->delete($this->db->quoteName('#__session')) ->where($this->db->quoteName('userid') . ' = ' . (int) $user['id']); try { $this->db->setQuery($query)->execute(); } catch (JDatabaseExceptionExecuting $e) { return false; } $query = $this->db->getQuery(true) ->delete($this->db->quoteName('#__messages')) ->where($this->db->quoteName('user_id_from') . ' = ' . (int) $user['id']); try { $this->db->setQuery($query)->execute(); } catch (JDatabaseExceptionExecuting $e) { return false; } return true; } /** * Utility method to act on a user after it has been saved. * * This method sends a registration email to new users created in the backend. * * @param array $user Holds the new user data. * @param boolean $isnew True if a new user is stored. * @param boolean $success True if user was successfully stored in the database. * @param string $msg Message. * * @return void * * @since 1.6 */ public function onUserAfterSave($user, $isnew, $success, $msg) { $mail_to_user = $this->params->get('mail_to_user', 1); if (!$isnew || !$mail_to_user) { return; } // TODO: Suck in the frontend registration emails here as well. Job for a rainy day. // The method check here ensures that if running as a CLI Application we don't get any errors if (method_exists($this->app, 'isClient') && !$this->app->isClient('administrator')) { return; } // Check if we have a sensible from email address, if not bail out as mail would not be sent anyway if (strpos($this->app->get('mailfrom'), '@') === false) { $this->app->enqueueMessage(Text::_('JERROR_SENDING_EMAIL'), 'warning'); return; } $lang = Factory::getLanguage(); $defaultLocale = $lang->getTag(); /** * Look for user language. Priority: * 1. User frontend language * 2. User backend language */ $userParams = new Registry($user['params']); $userLocale = $userParams->get('language', $userParams->get('admin_language', $defaultLocale)); if ($userLocale !== $defaultLocale) { $lang->setLanguage($userLocale); } $lang->load('plg_user_joomla', JPATH_ADMINISTRATOR); // Compute the mail subject. $emailSubject = Text::sprintf( 'PLG_USER_JOOMLA_NEW_USER_EMAIL_SUBJECT', $user['name'], $this->app->get('sitename') ); // Compute the mail body. $emailBody = Text::sprintf( 'PLG_USER_JOOMLA_NEW_USER_EMAIL_BODY', $user['name'], $this->app->get('sitename'), Uri::root(), $user['username'], $user['password_clear'] ); $res = Factory::getMailer()->sendMail( $this->app->get('mailfrom'), $this->app->get('fromname'), $user['email'], $emailSubject, $emailBody ); if ($res === false) { $this->app->enqueueMessage(Text::_('JERROR_SENDING_EMAIL'), 'warning'); } // Set application language back to default if we changed it if ($userLocale !== $defaultLocale) { $lang->setLanguage($defaultLocale); } } /** * This method should handle any login logic and report back to the subject * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return boolean True on success * * @since 1.5 */ public function onUserLogin($user, $options = array()) { $instance = $this->_getUser($user, $options); // If _getUser returned an error, then pass it back. if ($instance instanceof Exception) { return false; } // If the user is blocked, redirect with an error if ($instance->block == 1) { $this->app->enqueueMessage(Text::_('JERROR_NOLOGIN_BLOCKED'), 'warning'); return false; } // Authorise the user based on the group information if (!isset($options['group'])) { $options['group'] = 'USERS'; } // Check the user can login. $result = $instance->authorise($options['action']); if (!$result) { $this->app->enqueueMessage(Text::_('JERROR_LOGIN_DENIED'), 'warning'); return false; } // Mark the user as logged in $instance->guest = 0; $session = Factory::getSession(); // Grab the current session ID $oldSessionId = $session->getId(); // Fork the session $session->fork(); $session->set('user', $instance); // Ensure the new session's metadata is written to the database $this->app->checkSession(); // Purge the old session $query = $this->db->getQuery(true) ->delete('#__session') ->where($this->db->quoteName('session_id') . ' = ' . $this->db->quoteBinary($oldSessionId)); try { $this->db->setQuery($query)->execute(); } catch (RuntimeException $e) { // The old session is already invalidated, don't let this block logging in } // Hit the user last visit field $instance->setLastVisit(); // Add "user state" cookie used for reverse caching proxies like Varnish, Nginx etc. if ($this->app->isClient('site')) { $this->app->input->cookie->set( 'joomla_user_state', 'logged_in', 0, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain', ''), $this->app->isHttpsForced(), true ); } return true; } /** * This method should handle any logout logic and report back to the subject * * @param array $user Holds the user data. * @param array $options Array holding options (client, ...). * * @return boolean True on success * * @since 1.5 */ public function onUserLogout($user, $options = array()) { $my = Factory::getUser(); $session = Factory::getSession(); // Make sure we're a valid user first if ($user['id'] == 0 && !$my->get('tmp_user')) { return true; } $sharedSessions = $this->app->get('shared_session', '0'); // Check to see if we're deleting the current session if ($my->id == $user['id'] && ($sharedSessions || (!$sharedSessions && $options['clientid'] == $this->app->getClientId()))) { // Hit the user last visit field $my->setLastVisit(); // Destroy the php session for this user $session->destroy(); } // Enable / Disable Forcing logout all users with same userid $forceLogout = $this->params->get('forceLogout', 1); if ($forceLogout) { $clientId = (!$sharedSessions) ? (int) $options['clientid'] : null; UserHelper::destroyUserSessions($user['id'], false, $clientId); } // Delete "user state" cookie used for reverse caching proxies like Varnish, Nginx etc. if ($this->app->isClient('site')) { $this->app->input->cookie->set('joomla_user_state', '', 1, $this->app->get('cookie_path', '/'), $this->app->get('cookie_domain', '')); } return true; } /** * This method will return a user object * * If options['autoregister'] is true, if the user doesn't exist yet they will be created * * @param array $user Holds the user data. * @param array $options Array holding options (remember, autoregister, group). * * @return User * * @since 1.5 */ protected function _getUser($user, $options = array()) { $instance = User::getInstance(); $id = (int) UserHelper::getUserId($user['username']); if ($id) { $instance->load($id); return $instance; } // TODO : move this out of the plugin $params = ComponentHelper::getParams('com_users'); // Read the default user group option from com_users $defaultUserGroup = $params->get('new_usertype', $params->get('guest_usergroup', 1)); $instance->id = 0; $instance->name = $user['fullname']; $instance->username = $user['username']; $instance->password_clear = $user['password_clear']; // Result should contain an email (check). $instance->email = $user['email']; $instance->groups = array($defaultUserGroup); // If autoregister is set let's register the user $autoregister = isset($options['autoregister']) ? $options['autoregister'] : $this->params->get('autoregister', 1); if ($autoregister) { if (!$instance->save()) { JLog::add('Error in autoregistration for user ' . $user['username'] . '.', JLog::WARNING, 'error'); } } else { // No existing user and autoregister off, this is a temporary user. $instance->set('tmp_user', true); } return $instance; } } home/wuectly/www/plugins/actionlog/joomla/joomla.php 0000604 00000071772 15245551650 0016751 0 ustar 00 <?php /** * @package Joomla.Plugins * @subpackage System.actionlogs * * @copyright (C) 2018 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; use Joomla\CMS\Component\ComponentHelper; use Joomla\CMS\Factory; use Joomla\CMS\User\User; use Joomla\CMS\Version; use Joomla\Utilities\ArrayHelper; JLoader::register('ActionLogPlugin', JPATH_ADMINISTRATOR . '/components/com_actionlogs/libraries/actionlogplugin.php'); JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php'); /** * Joomla! Users Actions Logging Plugin. * * @since 3.9.0 */ class PlgActionlogJoomla extends ActionLogPlugin { /** * Array of loggable extensions. * * @var array * @since 3.9.0 */ protected $loggableExtensions = array(); /** * Context aliases * * @var array * @since 3.9.0 */ protected $contextAliases = array('com_content.form' => 'com_content.article'); /** * Constructor. * * @param object &$subject The object to observe. * @param array $config An optional associative array of configuration settings. * * @since 3.9.0 */ public function __construct(&$subject, $config) { parent::__construct($subject, $config); $params = ComponentHelper::getComponent('com_actionlogs')->getParams(); $this->loggableExtensions = $params->get('loggable_extensions', array()); } /** * After save content logging method * This method adds a record to #__action_logs contains (message, date, context, user) * Method is called right after the content is saved * * @param string $context The context of the content passed to the plugin * @param object $article A JTableContent object * @param boolean $isNew If the content is just about to be created * * @return void * * @since 3.9.0 */ public function onContentAfterSave($context, $article, $isNew) { if (isset($this->contextAliases[$context])) { $context = $this->contextAliases[$context]; } $option = $this->app->input->getCmd('option'); if (!$this->checkLoggable($option)) { return; } $params = ActionlogsHelper::getLogContentTypeParams($context); // Not found a valid content type, don't process further if ($params === null) { return; } list(, $contentType) = explode('.', $params->type_alias); if ($isNew) { $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_ADDED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'; } else { $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_UPDATED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'; } // If the content type doesn't has it own language key, use default language key if (!$this->app->getLanguage()->hasKey($messageLanguageKey)) { $messageLanguageKey = $defaultLanguageKey; } $id = empty($params->id_holder) ? 0 : $article->get($params->id_holder); $message = array( 'action' => $isNew ? 'add' : 'update', 'type' => $params->text_prefix . '_TYPE_' . $params->type_title, 'id' => $id, 'title' => $article->get($params->title_holder), 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $id, $params->id_holder, $article), ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * After delete content logging method * This method adds a record to #__action_logs contains (message, date, context, user) * Method is called right after the content is deleted * * @param string $context The context of the content passed to the plugin * @param object $article A JTableContent object * * @return void * * @since 3.9.0 */ public function onContentAfterDelete($context, $article) { $option = $this->app->input->get('option'); if (!$this->checkLoggable($option)) { return; } $params = ActionlogsHelper::getLogContentTypeParams($context); // Not found a valid content type, don't process further if ($params === null) { return; } // If the content type has it own language key, use it, otherwise, use default language key if ($this->app->getLanguage()->hasKey(strtoupper($params->text_prefix . '_' . $params->type_title . '_DELETED'))) { $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_DELETED'; } else { $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; } $id = empty($params->id_holder) ? 0 : $article->get($params->id_holder); $message = array( 'action' => 'delete', 'type' => $params->text_prefix . '_TYPE_' . $params->type_title, 'id' => $id, 'title' => $article->get($params->title_holder) ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On content change status logging method * This method adds a record to #__action_logs contains (message, date, context, user) * Method is called when the status of the article is changed * * @param string $context The context of the content passed to the plugin * @param array $pks An array 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.9.0 */ public function onContentChangeState($context, $pks, $value) { $option = $this->app->input->getCmd('option'); if (!$this->checkLoggable($option)) { return; } $params = ActionlogsHelper::getLogContentTypeParams($context); // Not found a valid content type, don't process further if ($params === null) { return; } list(, $contentType) = explode('.', $params->type_alias); switch ($value) { case 0: $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_UNPUBLISHED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UNPUBLISHED'; $action = 'unpublish'; break; case 1: $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_PUBLISHED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_PUBLISHED'; $action = 'publish'; break; case 2: $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_ARCHIVED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ARCHIVED'; $action = 'archive'; break; case -2: $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_TRASHED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_TRASHED'; $action = 'trash'; break; default: $messageLanguageKey = ''; $defaultLanguageKey = ''; $action = ''; break; } // If the content type doesn't has it own language key, use default language key if (!$this->app->getLanguage()->hasKey($messageLanguageKey)) { $messageLanguageKey = $defaultLanguageKey; } $db = $this->db; $query = $db->getQuery(true) ->select($db->quoteName(array($params->title_holder, $params->id_holder))) ->from($db->quoteName($params->table_name)) ->where($db->quoteName($params->id_holder) . ' IN (' . implode(',', ArrayHelper::toInteger($pks)) . ')'); $db->setQuery($query); try { $items = $db->loadObjectList($params->id_holder); } catch (RuntimeException $e) { $items = array(); } $messages = array(); foreach ($pks as $pk) { $message = array( 'action' => $action, 'type' => $params->text_prefix . '_TYPE_' . $params->type_title, 'id' => $pk, 'title' => $items[$pk]->{$params->title_holder}, 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $pk, $params->id_holder, null) ); $messages[] = $message; } $this->addLog($messages, $messageLanguageKey, $context); } /** * On Saving application configuration logging method * Method is called when the application config is being saved * * @param JRegistry $config JRegistry object with the new config * * @return void * * @since 3.9.0 */ public function onApplicationAfterSave($config) { $option = $this->app->input->getCmd('option'); if (!$this->checkLoggable($option)) { return; } $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_APPLICATION_CONFIG_UPDATED'; $action = 'update'; $message = array( 'action' => $action, 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_APPLICATION_CONFIG', 'extension_name' => 'com_config.application', 'itemlink' => 'index.php?option=com_config' ); $this->addLog(array($message), $messageLanguageKey, 'com_config.application'); } /** * On installing extensions logging method * This method adds a record to #__action_logs contains (message, date, context, user) * Method is called when an extension is installed * * @param JInstaller $installer Installer object * @param integer $eid Extension Identifier * * @return void * * @since 3.9.0 */ public function onExtensionAfterInstall($installer, $eid) { $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } $manifest = $installer->get('manifest'); if ($manifest === null) { return; } $extensionType = $manifest->attributes()->type; // If the extension type has it own language key, use it, otherwise, use default language key if ($this->app->getLanguage()->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_INSTALLED'))) { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_INSTALLED'; } else { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_EXTENSION_INSTALLED'; } $message = array( 'action' => 'install', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType, 'id' => $eid, 'name' => (string) $manifest->name, 'extension_name' => (string) $manifest->name ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On uninstalling extensions logging method * This method adds a record to #__action_logs contains (message, date, context, user) * Method is called when an extension is uninstalled * * @param JInstaller $installer Installer instance * @param integer $eid Extension id * @param integer $result Installation result * * @return void * * @since 3.9.0 */ public function onExtensionAfterUninstall($installer, $eid, $result) { $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } // If the process failed, we don't have manifest data, stop process to avoid fatal error if ($result === false) { return; } $manifest = $installer->get('manifest'); if ($manifest === null) { return; } $extensionType = $manifest->attributes()->type; // If the extension type has it own language key, use it, otherwise, use default language key if ($this->app->getLanguage()->hasKey(strtoupper('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UNINSTALLED'))) { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UNINSTALLED'; } else { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_EXTENSION_UNINSTALLED'; } $message = array( 'action' => 'install', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType, 'id' => $eid, 'name' => (string) $manifest->name, 'extension_name' => (string) $manifest->name ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On updating extensions logging method * This method adds a record to #__action_logs contains (message, date, context, user) * Method is called when an extension is updated * * @param JInstaller $installer Installer instance * @param integer $eid Extension id * * @return void * * @since 3.9.0 */ public function onExtensionAfterUpdate($installer, $eid) { $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } $manifest = $installer->get('manifest'); if ($manifest === null) { return; } $extensionType = $manifest->attributes()->type; // If the extension type has it own language key, use it, otherwise, use default language key if ($this->app->getLanguage()->hasKey('PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED')) { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_' . $extensionType . '_UPDATED'; } else { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_EXTENSION_UPDATED'; } $message = array( 'action' => 'update', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $extensionType, 'id' => $eid, 'name' => (string) $manifest->name, 'extension_name' => (string) $manifest->name ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On Saving extensions logging method * Method is called when an extension is being saved * * @param string $context The extension * @param JTable $table DataBase Table object * @param boolean $isNew If the extension is new or not * * @return void * * @since 3.9.0 */ public function onExtensionAfterSave($context, $table, $isNew) { $option = $this->app->input->getCmd('option'); if ($table->get('module') != null) { $option = 'com_modules'; } if (!$this->checkLoggable($option)) { return; } $params = ActionlogsHelper::getLogContentTypeParams($context); // Not found a valid content type, don't process further if ($params === null) { return; } list(, $contentType) = explode('.', $params->type_alias); if ($isNew) { $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_ADDED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'; } else { $messageLanguageKey = $params->text_prefix . '_' . $params->type_title . '_UPDATED'; $defaultLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'; } // If the extension type doesn't have it own language key, use default language key if (!$this->app->getLanguage()->hasKey($messageLanguageKey)) { $messageLanguageKey = $defaultLanguageKey; } $message = array( 'action' => $isNew ? 'add' : 'update', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $params->type_title, 'id' => $table->get($params->id_holder), 'title' => $table->get($params->title_holder), 'extension_name' => $table->get($params->title_holder), 'itemlink' => ActionlogsHelper::getContentTypeLink($option, $contentType, $table->get($params->id_holder), $params->id_holder, null) ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On Deleting extensions logging method * Method is called when an extension is being deleted * * @param string $context The extension * @param JTable $table DataBase Table object * * @return void * * @since 3.9.0 */ public function onExtensionAfterDelete($context, $table) { if (!$this->checkLoggable($this->app->input->get('option'))) { return; } $params = ActionlogsHelper::getLogContentTypeParams($context); // Not found a valid content type, don't process further if ($params === null) { return; } $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; $message = array( 'action' => 'delete', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_' . $params->type_title, 'title' => $table->get($params->title_holder) ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On saving user data logging method * * Method is called after user data is stored in the database. * This method logs who created/edited any user's data * * @param array $user Holds the new user data. * @param boolean $isnew True if a new user is stored. * @param boolean $success True if user was successfully stored in the database. * @param string $msg Message. * * @return void * * @since 3.9.0 */ public function onUserAfterSave($user, $isnew, $success, $msg) { $context = $this->app->input->get('option'); $task = $this->app->input->get->getCmd('task'); if (!$this->checkLoggable($context)) { return; } $jUser = Factory::getUser(); if (!$jUser->id) { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_REGISTERED'; $action = 'register'; // Reset request if ($task === 'reset.request') { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_RESET_REQUEST'; $action = 'resetrequest'; } // Reset complete if ($task === 'reset.complete') { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_RESET_COMPLETE'; $action = 'resetcomplete'; } // Registration Activation if ($task === 'registration.activate') { $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_REGISTRATION_ACTIVATE'; $action = 'activaterequest'; } } elseif ($isnew) { $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'; $action = 'add'; } else { $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'; $action = 'update'; } $userId = $jUser->id ?: $user['id']; $username = $jUser->username ?: $user['username']; $message = array( 'action' => $action, 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user['id'], 'title' => $user['name'], 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user['id'], 'userid' => $userId, 'username' => $username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $userId, ); $this->addLog(array($message), $messageLanguageKey, $context, $userId); } /** * On deleting user data logging method * * Method is called after user data is deleted from the database * * @param array $user Holds the user data * @param boolean $success True if user was successfully stored in the database * @param string $msg Message * * @return void * * @since 3.9.0 */ public function onUserAfterDelete($user, $success, $msg) { $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; $message = array( 'action' => 'delete', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user['id'], 'title' => $user['name'] ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On after save user group data logging method * * Method is called after user group is stored into the database * * @param string $context The context * @param JTable $table DataBase Table object * @param boolean $isNew Is new or not * * @return void * * @since 3.9.0 */ public function onUserAfterSaveGroup($context, $table, $isNew) { // Override context (com_users.group) with the component context (com_users) to pass the checkLoggable $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } if ($isNew) { $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_ADDED'; $action = 'add'; } else { $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_UPDATED'; $action = 'update'; } $message = array( 'action' => $action, 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER_GROUP', 'id' => $table->id, 'title' => $table->title, 'itemlink' => 'index.php?option=com_users&task=group.edit&id=' . $table->id ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * On deleting user group data logging method * * Method is called after user group is deleted from the database * * @param array $group Holds the group data * @param boolean $success True if user was successfully stored in the database * @param string $msg Message * * @return void * * @since 3.9.0 */ public function onUserAfterDeleteGroup($group, $success, $msg) { $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } $messageLanguageKey = 'PLG_SYSTEM_ACTIONLOGS_CONTENT_DELETED'; $message = array( 'action' => 'delete', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER_GROUP', 'id' => $group['id'], 'title' => $group['title'] ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * Method to log user login success action * * @param array $options Array holding options (user, responseType) * * @return void * * @since 3.9.0 */ public function onUserAfterLogin($options) { $context = 'com_users'; if (!$this->checkLoggable($context)) { return; } $loggedInUser = $options['user']; $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_LOGGED_IN'; $message = array( 'action' => 'login', 'userid' => $loggedInUser->id, 'username' => $loggedInUser->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $loggedInUser->id, 'app' => 'PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName(), ); $this->addLog(array($message), $messageLanguageKey, $context, $loggedInUser->id); } /** * Method to log user login failed action * * @param array $response Array of response data. * * @return void * * @since 3.9.0 */ public function onUserLoginFailure($response) { $context = 'com_users'; if (!$this->checkLoggable($context)) { return; } // Get the user id for the given username $query = $this->db->getQuery(true) ->select($this->db->quoteName(array('id', 'username'))) ->from($this->db->quoteName('#__users')) ->where($this->db->quoteName('username') . ' = ' . $this->db->quote($response['username'])); $this->db->setQuery($query); try { $loggedInUser = $this->db->loadObject(); } catch (JDatabaseExceptionExecuting $e) { return; } // Not a valid user, return if (!isset($loggedInUser->id)) { return; } $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_LOGIN_FAILED'; $message = array( 'action' => 'login', 'id' => $loggedInUser->id, 'userid' => $loggedInUser->id, 'username' => $loggedInUser->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $loggedInUser->id, 'app' => 'PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName(), ); $this->addLog(array($message), $messageLanguageKey, $context, $loggedInUser->id); } /** * Method to log user's logout action * * @param array $user Holds the user data * @param array $options Array holding options (remember, autoregister, group) * * @return void * * @since 3.9.0 */ public function onUserLogout($user, $options = array()) { $context = 'com_users'; if (!$this->checkLoggable($context)) { return; } $loggedOutUser = User::getInstance($user['id']); if ($loggedOutUser->block) { return; } $messageLanguageKey = 'PLG_ACTIONLOG_JOOMLA_USER_LOGGED_OUT'; $message = array( 'action' => 'logout', 'id' => $loggedOutUser->id, 'userid' => $loggedOutUser->id, 'username' => $loggedOutUser->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $loggedOutUser->id, 'app' => 'PLG_ACTIONLOG_JOOMLA_APPLICATION_' . $this->app->getName(), ); $this->addLog(array($message), $messageLanguageKey, $context); } /** * Function to check if a component is loggable or not * * @param string $extension The extension that triggered the event * * @return boolean * * @since 3.9.0 */ protected function checkLoggable($extension) { return in_array($extension, $this->loggableExtensions); } /** * On after Remind username request * * Method is called after user request to remind their username. * * @param array $user Holds the user data. * * @return void * * @since 3.9.0 */ public function onUserAfterRemind($user) { $context = $this->app->input->get('option'); if (!$this->checkLoggable($context)) { return; } $message = array( 'action' => 'remind', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user->id, 'title' => $user->name, 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'userid' => $user->id, 'username' => $user->name, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_REMIND', $context, $user->id); } /** * On after Check-in request * * Method is called after user request to check-in items. * * @param array $table Holds the table name. * * @return void * * @since 3.9.3 */ public function onAfterCheckin($table) { $context = 'com_checkin'; $user = Factory::getUser(); if (!$this->checkLoggable($context)) { return; } $message = array( 'action' => 'checkin', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user->id, 'title' => $user->username, 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'table' => $table, ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_CHECKIN', $context, $user->id); } /** * On after log action purge * * Method is called after user request to clean action log items. * * @param array $group Holds the group name. * * @return void * * @since 3.9.4 */ public function onAfterLogPurge($group = '') { $context = $this->app->input->get('option'); $user = Factory::getUser(); $message = array( 'action' => 'actionlogs', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user->id, 'title' => $user->username, 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_LOG', $context, $user->id); } /** * On after log export * * Method is called after user request to export action log items. * * @param array $group Holds the group name. * * @return void * * @since 3.9.4 */ public function onAfterLogExport($group = '') { $context = $this->app->input->get('option'); $user = Factory::getUser(); $message = array( 'action' => 'actionlogs', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user->id, 'title' => $user->username, 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_LOGEXPORT', $context, $user->id); } /** * On after Cache purge * * Method is called after user request to clean cached items. * * @param string $group Holds the group name. * * @return void * * @since 3.9.4 */ public function onAfterPurge($group = 'all') { $context = $this->app->input->get('option'); $user = JFactory::getUser(); if (!$this->checkLoggable($context)) { return; } $message = array( 'action' => 'cache', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user->id, 'title' => $user->username, 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'group' => $group, ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_CACHE', $context, $user->id); } /** * On after CMS Update * * Method is called after user update the CMS. * * @param string $oldVersion The Joomla version before the update * * @return void * * @since 3.9.21 */ public function onJoomlaAfterUpdate($oldVersion = null) { $context = $this->app->input->get('option'); $user = JFactory::getUser(); if (empty($oldVersion)) { $oldVersion = JText::_('JLIB_UNKNOWN'); } $message = array( 'action' => 'joomlaupdate', 'type' => 'PLG_ACTIONLOG_JOOMLA_TYPE_USER', 'id' => $user->id, 'title' => $user->username, 'itemlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'userid' => $user->id, 'username' => $user->username, 'accountlink' => 'index.php?option=com_users&task=user.edit&id=' . $user->id, 'version' => JVERSION, 'oldversion' => $oldVersion, ); $this->addLog(array($message), 'PLG_ACTIONLOG_JOOMLA_USER_UPDATE', $context, $user->id); } } home/wuectly/www/plugins/extension/joomla/joomla.php 0000604 00000016167 15245603136 0017000 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Extension.Joomla * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Joomla! master extension plugin. * * @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 * @param string $extraQuery Any additional request query to use when updating * * @return void * * @since 1.6 */ private function addUpdateSite($name, $type, $location, $enabled, $extraQuery = '') { $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'), $db->quoteName('extra_query') ) ) ->values( $db->quote($name) . ', ' . $db->quote($type) . ', ' // Trim to remove any whitespace from the XML file before saving the location to the db . $db->quote(trim($location)) . ', ' . (int) $enabled . ', ' . $db->quote($extraQuery) ); $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 boolean $result Installation result * * @return void * * @since 1.6 */ public function onExtensionAfterUninstall($installer, $eid, $result) { // If we have a valid extension ID and the extension was successfully uninstalled wipe out any // update sites for it if ($eid && $result) { $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'], trim($child), true, $this->installer->extraQuery); } } else { $data = trim((string) $updateservers); if ($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); } } } } home/wuectly/www/libraries/f0f/database/driver/joomla.php 0000604 00000036213 15245604354 0017505 0 ustar 00 <?php /** * @package FrameworkOnFramework * @subpackage database * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * * This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning F0FTable objects * instead of plain stdClass objects */ // Protect from unauthorized access defined('F0F_INCLUDED') or die; /** * This crazy three line bit is required to convince Joomla! to load JDatabaseInterface which is on the same file as the * abstract JDatabaseDriver class for reasons that beat me. It makes no sense. Furthermore, jimport on Joomla! 3.4 * doesn't seem to actually load the file, merely registering the association in the autoloader. Hence the class_exists * in here. */ jimport('joomla.database.driver'); jimport('joomla.database.driver.mysqli'); class_exists('JDatabaseDriver', true); /** * Joomla! pass-through database driver. */ class F0FDatabaseDriverJoomla extends F0FDatabase implements F0FDatabaseInterface { /** @var F0FDatabase The real database connection object */ private $dbo; /** * @var string The character(s) used to quote SQL statement names such as table names or field names, * etc. The child classes should define this as necessary. If a single character string the * same character is used for both sides of the quoted name, else the first character will be * used for the opening quote and the second for the closing quote. * @since 11.1 */ protected $nameQuote = ''; /** * Is this driver supported * * @since 11.2 */ public static function isSupported() { return true; } /** * Database object constructor * * @param array $options List of options used to configure the connection */ public function __construct($options = array()) { // Get best matching Akeeba Backup driver instance $this->dbo = JFactory::getDbo(); $reflection = new ReflectionClass($this->dbo); try { $refProp = $reflection->getProperty('nameQuote'); $refProp->setAccessible(true); $this->nameQuote = $refProp->getValue($this->dbo); } catch (Exception $e) { $this->nameQuote = '`'; } } public function close() { if (method_exists($this->dbo, 'close')) { $this->dbo->close(); } elseif (method_exists($this->dbo, 'disconnect')) { $this->dbo->disconnect(); } } public function disconnect() { $this->close(); } public function open() { if (method_exists($this->dbo, 'open')) { $this->dbo->open(); } elseif (method_exists($this->dbo, 'connect')) { $this->dbo->connect(); } } public function connect() { $this->open(); } public function connected() { if (method_exists($this->dbo, 'connected')) { return $this->dbo->connected(); } return true; } public function escape($text, $extra = false) { return $this->dbo->escape($text, $extra); } public function execute() { if (method_exists($this->dbo, 'execute')) { return $this->dbo->execute(); } return $this->dbo->query(); } public function getAffectedRows() { if (method_exists($this->dbo, 'getAffectedRows')) { return $this->dbo->getAffectedRows(); } return 0; } public function getCollation() { if (method_exists($this->dbo, 'getCollation')) { return $this->dbo->getCollation(); } return 'utf8_general_ci'; } public function getConnection() { if (method_exists($this->dbo, 'getConnection')) { return $this->dbo->getConnection(); } return null; } public function getCount() { if (method_exists($this->dbo, 'getCount')) { return $this->dbo->getCount(); } return 0; } public function getDateFormat() { if (method_exists($this->dbo, 'getDateFormat')) { return $this->dbo->getDateFormat(); } return 'Y-m-d H:i:s';; } public function getMinimum() { if (method_exists($this->dbo, 'getMinimum')) { return $this->dbo->getMinimum(); } return '5.0.40'; } public function getNullDate() { if (method_exists($this->dbo, 'getNullDate')) { return $this->dbo->getNullDate(); } return '0000-00-00 00:00:00'; } public function getNumRows($cursor = null) { if (method_exists($this->dbo, 'getNumRows')) { return $this->dbo->getNumRows($cursor); } return 0; } public function getQuery($new = false) { if (method_exists($this->dbo, 'getQuery')) { return $this->dbo->getQuery($new); } return null; } public function getTableColumns($table, $typeOnly = true) { if (method_exists($this->dbo, 'getTableColumns')) { return $this->dbo->getTableColumns($table, $typeOnly); } $result = $this->dbo->getTableFields(array($table), $typeOnly); return $result[$table]; } public function getTableKeys($tables) { if (method_exists($this->dbo, 'getTableKeys')) { return $this->dbo->getTableKeys($tables); } return array(); } public function getTableList() { if (method_exists($this->dbo, 'getTableList')) { return $this->dbo->getTableList(); } return array(); } public function getVersion() { if (method_exists($this->dbo, 'getVersion')) { return $this->dbo->getVersion(); } return '5.0.40'; } public function insertid() { if (method_exists($this->dbo, 'insertid')) { return $this->dbo->insertid(); } return null; } public function insertObject($table, &$object, $key = null) { if (method_exists($this->dbo, 'insertObject')) { return $this->dbo->insertObject($table, $object, $key); } return null; } public function loadAssoc() { if (method_exists($this->dbo, 'loadAssoc')) { return $this->dbo->loadAssoc(); } return null; } public function loadAssocList($key = null, $column = null) { if (method_exists($this->dbo, 'loadAssocList')) { return $this->dbo->loadAssocList($key, $column); } return null; } public function loadObject($class = 'stdClass') { if (method_exists($this->dbo, 'loadObject')) { return $this->dbo->loadObject($class); } return null; } public function loadObjectList($key = '', $class = 'stdClass') { if (method_exists($this->dbo, 'loadObjectList')) { return $this->dbo->loadObjectList($key, $class); } return null; } public function loadResult() { if (method_exists($this->dbo, 'loadResult')) { return $this->dbo->loadResult(); } return null; } public function loadRow() { if (method_exists($this->dbo, 'loadRow')) { return $this->dbo->loadRow(); } return null; } public function loadRowList($key = null) { if (method_exists($this->dbo, 'loadRowList')) { return $this->dbo->loadRowList($key); } return null; } public function lockTable($tableName) { if (method_exists($this->dbo, 'lockTable')) { return $this->dbo->lockTable($this); } return $this; } public function quote($text, $escape = true) { if (method_exists($this->dbo, 'quote')) { return $this->dbo->quote($text, $escape); } return $text; } public function select($database) { if (method_exists($this->dbo, 'select')) { return $this->dbo->select($database); } return false; } public function setQuery($query, $offset = 0, $limit = 0) { if (method_exists($this->dbo, 'setQuery')) { return $this->dbo->setQuery($query, $offset, $limit); } return false; } public function transactionCommit($toSavepoint = false) { if (method_exists($this->dbo, 'transactionCommit')) { $this->dbo->transactionCommit($toSavepoint); } } public function transactionRollback($toSavepoint = false) { if (method_exists($this->dbo, 'transactionRollback')) { $this->dbo->transactionRollback($toSavepoint); } } public function transactionStart($asSavepoint = false) { if (method_exists($this->dbo, 'transactionStart')) { $this->dbo->transactionStart($asSavepoint); } } public function unlockTables() { if (method_exists($this->dbo, 'unlockTables')) { return $this->dbo->unlockTables(); } return $this; } public function updateObject($table, &$object, $key, $nulls = false) { if (method_exists($this->dbo, 'updateObject')) { return $this->dbo->updateObject($table, $object, $key, $nulls); } return false; } public function getLog() { if (method_exists($this->dbo, 'getLog')) { return $this->dbo->getLog(); } return array(); } public function dropTable($table, $ifExists = true) { if (method_exists($this->dbo, 'dropTable')) { return $this->dbo->dropTable($table, $ifExists); } return $this; } public function getTableCreate($tables) { if (method_exists($this->dbo, 'getTableCreate')) { return $this->dbo->getTableCreate($tables); } return array(); } public function renameTable($oldTable, $newTable, $backup = null, $prefix = null) { if (method_exists($this->dbo, 'renameTable')) { return $this->dbo->renameTable($oldTable, $newTable, $backup, $prefix); } return $this; } public function setUtf() { if (method_exists($this->dbo, 'setUtf')) { return $this->dbo->setUtf(); } return false; } protected function freeResult($cursor = null) { return false; } /** * Method to get an array of values from the <var>$offset</var> field in each row of the result set from * the database query. * * @param integer $offset The row offset to use to build the result array. * * @return mixed The return value or null if the query failed. * * @since 11.1 * @throws RuntimeException */ public function loadColumn($offset = 0) { if (method_exists($this->dbo, 'loadColumn')) { return $this->dbo->loadColumn($offset); } return $this->dbo->loadResultArray($offset); } /** * Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection * risks and reserved word conflicts. * * @param mixed $name The identifier name to wrap in quotes, or an array of identifier names to wrap in quotes. * Each type supports dot-notation name. * @param mixed $as The AS query part associated to $name. It can be string or array, in latter case it has to be * same length of $name; if is null there will not be any AS part for string or array element. * * @return mixed The quote wrapped name, same type of $name. * * @since 11.1 */ public function quoteName($name, $as = null) { if (is_string($name)) { $quotedName = $this->quoteNameStr(explode('.', $name)); $quotedAs = ''; if (!is_null($as)) { settype($as, 'array'); $quotedAs .= ' AS ' . $this->quoteNameStr($as); } return $quotedName . $quotedAs; } else { $fin = array(); if (is_null($as)) { foreach ($name as $str) { $fin[] = $this->quoteName($str); } } elseif (is_array($name) && (count($name) == count($as))) { $count = count($name); for ($i = 0; $i < $count; $i++) { $fin[] = $this->quoteName($name[$i], $as[$i]); } } return $fin; } } /** * Quote strings coming from quoteName call. * * @param array $strArr Array of strings coming from quoteName dot-explosion. * * @return string Dot-imploded string of quoted parts. * * @since 11.3 */ protected function quoteNameStr($strArr) { $parts = array(); $q = $this->nameQuote; foreach ($strArr as $part) { if (is_null($part)) { continue; } if (strlen($q) == 1) { $parts[] = $q . $part . $q; } else { $parts[] = $q{0} . $part . $q{1}; } } return implode('.', $parts); } /** * Gets the error message from the database connection. * * @param boolean $escaped True to escape the message string for use in JavaScript. * * @return string The error message for the most recent query. * * @since 11.1 */ public function getErrorMsg($escaped = false) { if (method_exists($this->dbo, 'getErrorMsg')) { $errorMessage = $this->dbo->getErrorMsg(); } else { $errorMessage = $this->errorMsg; } if ($escaped) { return addslashes($errorMessage); } return $errorMessage; } /** * Gets the error number from the database connection. * * @return integer The error number for the most recent query. * * @since 11.1 * @deprecated 13.3 (Platform) & 4.0 (CMS) */ public function getErrorNum() { if (method_exists($this->dbo, 'getErrorNum')) { $errorNum = $this->dbo->getErrorNum(); } else { $errorNum = $this->getErrorNum; } return $errorNum; } /** * Return the most recent error message for the database connector. * * @param boolean $showSQL True to display the SQL statement sent to the database as well as the error. * * @return string The error message for the most recent query. */ public function stderr($showSQL = false) { if (method_exists($this->dbo, 'stderr')) { return $this->dbo->stderr($showSQL); } return parent::stderr($showSQL); } /** * Magic method to proxy all calls to the loaded database driver object */ public function __call($name, array $arguments) { if (is_null($this->dbo)) { throw new Exception('F0F database driver is not loaded'); } if (method_exists($this->dbo, $name) || in_array($name, array('q', 'nq', 'qn', 'query'))) { switch ($name) { case 'execute': $name = 'query'; break; case 'q': $name = 'quote'; break; case 'qn': case 'nq': switch (count($arguments)) { case 0 : $result = $this->quoteName(); break; case 1 : $result = $this->quoteName($arguments[0]); break; case 2: default: $result = $this->quoteName($arguments[0], $arguments[1]); break; } return $result; break; } switch (count($arguments)) { case 0 : $result = $this->dbo->$name(); break; case 1 : $result = $this->dbo->$name($arguments[0]); break; case 2: $result = $this->dbo->$name($arguments[0], $arguments[1]); break; case 3: $result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2]); break; case 4: $result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2], $arguments[3]); break; case 5: $result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]); break; default: // Resort to using call_user_func_array for many segments $result = call_user_func_array(array($this->dbo, $name), $arguments); } if (class_exists('JDatabase') && is_object($result) && ($result instanceof JDatabase)) { return $this; } return $result; } else { throw new \Exception('Method ' . $name . ' not found in F0FDatabase'); } } public function __get($name) { if (isset($this->dbo->$name) || property_exists($this->dbo, $name)) { return $this->dbo->$name; } else { $this->dbo->$name = null; user_error('Database driver does not support property ' . $name); } } public function __set($name, $value) { if (isset($this->dbo->name) || property_exists($this->dbo, $name)) { $this->dbo->$name = $value; } else { $this->dbo->$name = null; user_error('Database driver not support property ' . $name); } } } home/wuectly/www/libraries/joomla/session/handler/joomla.php 0000604 00000006622 15245604355 0020356 0 ustar 00 <?php /** * @package Joomla.Platform * @subpackage Session * * @copyright (C) 2015 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE */ defined('JPATH_PLATFORM') or die; /** * Interface for managing HTTP sessions * * @since 3.5 * @deprecated 4.0 The CMS' Session classes will be replaced with the `joomla/session` package */ class JSessionHandlerJoomla extends JSessionHandlerNative { /** * The input object * * @var JInput * @since 3.5 */ public $input = null; /** * Force cookies to be SSL only * * @var boolean * @since 3.5 */ protected $force_ssl = false; /** * Public constructor * * @param array $options An array of configuration options * * @since 3.5 */ public function __construct($options = array()) { if (!headers_sent()) { // Disable transparent sid support ini_set('session.use_trans_sid', '0'); // Only allow the session ID to come from cookies and nothing else. if ((int) ini_get('session.use_cookies') !== 1) { ini_set('session.use_only_cookies', 1); } } // Set options $this->setOptions($options); $this->setCookieParams(); } /** * Starts the session * * @return boolean True if started * * @since 3.5 * @throws RuntimeException If something goes wrong starting the session. */ public function start() { $session_name = $this->getName(); // Get the JInputCookie object $cookie = $this->input->cookie; if (is_null($cookie->get($session_name))) { $session_clean = $this->input->get($session_name, false, 'string'); if ($session_clean) { $this->setId($session_clean); $cookie->set($session_name, '', 1); } } return parent::start(); } /** * Clear all session data in memory. * * @return void * * @since 3.5 */ public function clear() { $sessionName = $this->getName(); /* * In order to kill the session altogether, such as to log the user out, the session id * must also be unset. If a cookie is used to propagate the session id (default behavior), * then the session cookie must be deleted. * We need to use setcookie here or we will get a warning in some session handlers (ex: files). */ if (isset($_COOKIE[$sessionName])) { $cookie = session_get_cookie_params(); setcookie($sessionName, '', 1, $cookie['path'], $cookie['domain'], $cookie['secure'], true); } parent::clear(); } /** * Set session cookie parameters * * @return void * * @since 3.5 */ protected function setCookieParams() { if (headers_sent()) { return; } $cookie = session_get_cookie_params(); if ($this->force_ssl) { $cookie['secure'] = true; } $config = JFactory::getConfig(); if ($config->get('cookie_domain', '') != '') { $cookie['domain'] = $config->get('cookie_domain'); } if ($config->get('cookie_path', '') != '') { $cookie['path'] = $config->get('cookie_path'); } session_set_cookie_params($cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'], true); } /** * Set additional session options * * @param array $options List of parameter * * @return boolean True on success * * @since 3.5 */ protected function setOptions(array $options) { if (isset($options['force_ssl'])) { $this->force_ssl = (bool) $options['force_ssl']; } return true; } } home/wuectly/www/libraries/fof/database/driver/joomla.php 0000604 00000036406 15245613244 0017606 0 ustar 00 <?php /** * @package FrameworkOnFramework * @subpackage database * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author. * * This file is adapted from the Joomla! Platform. It is used to iterate a database cursor returning FOFTable objects * instead of plain stdClass objects */ // Protect from unauthorized access defined('FOF_INCLUDED') or die; /** * This crazy three line bit is required to convince Joomla! to load JDatabaseInterface which is on the same file as the * abstract JDatabaseDriver class for reasons that beat me. It makes no sense. Furthermore, jimport on Joomla! 3.4 * doesn't seem to actually load the file, merely registering the association in the autoloader. Hence the class_exists * in here. */ jimport('joomla.database.driver'); jimport('joomla.database.driver.mysqli'); class_exists('JDatabaseDriver', true); /** * Joomla! pass-through database driver. */ class FOFDatabaseDriverJoomla extends FOFDatabase implements FOFDatabaseInterface { /** @var FOFDatabase The real database connection object */ private $dbo; /** * @var string The character(s) used to quote SQL statement names such as table names or field names, * etc. The child classes should define this as necessary. If a single character string the * same character is used for both sides of the quoted name, else the first character will be * used for the opening quote and the second for the closing quote. * @since 11.1 */ protected $nameQuote = ''; /** * Is this driver supported * * @since 11.2 */ public static function isSupported() { return true; } /** * Database object constructor * * @param array $options List of options used to configure the connection */ public function __construct($options = array()) { // Get best matching Akeeba Backup driver instance $this->dbo = JFactory::getDbo(); $reflection = new ReflectionClass($this->dbo); try { $refProp = $reflection->getProperty('nameQuote'); $refProp->setAccessible(true); $this->nameQuote = $refProp->getValue($this->dbo); } catch (Exception $e) { $this->nameQuote = '`'; } } public function close() { if (method_exists($this->dbo, 'close')) { $this->dbo->close(); } elseif (method_exists($this->dbo, 'disconnect')) { $this->dbo->disconnect(); } } public function disconnect() { $this->close(); } public function open() { if (method_exists($this->dbo, 'open')) { $this->dbo->open(); } elseif (method_exists($this->dbo, 'connect')) { $this->dbo->connect(); } } public function connect() { $this->open(); } public function connected() { if (method_exists($this->dbo, 'connected')) { return $this->dbo->connected(); } return true; } public function escape($text, $extra = false) { return $this->dbo->escape($text, $extra); } public function execute() { if (method_exists($this->dbo, 'execute')) { return $this->dbo->execute(); } return $this->dbo->query(); } public function getAffectedRows() { if (method_exists($this->dbo, 'getAffectedRows')) { return $this->dbo->getAffectedRows(); } return 0; } public function getCollation() { if (method_exists($this->dbo, 'getCollation')) { return $this->dbo->getCollation(); } return 'utf8_general_ci'; } public function getConnection() { if (method_exists($this->dbo, 'getConnection')) { return $this->dbo->getConnection(); } return null; } public function getCount() { if (method_exists($this->dbo, 'getCount')) { return $this->dbo->getCount(); } return 0; } public function getDateFormat() { if (method_exists($this->dbo, 'getDateFormat')) { return $this->dbo->getDateFormat(); } return 'Y-m-d H:i:s';; } public function getMinimum() { if (method_exists($this->dbo, 'getMinimum')) { return $this->dbo->getMinimum(); } return '5.0.40'; } public function getNullDate() { if (method_exists($this->dbo, 'getNullDate')) { return $this->dbo->getNullDate(); } return '0000-00-00 00:00:00'; } public function getNumRows($cursor = null) { if (method_exists($this->dbo, 'getNumRows')) { return $this->dbo->getNumRows($cursor); } return 0; } public function getQuery($new = false) { if (method_exists($this->dbo, 'getQuery')) { return $this->dbo->getQuery($new); } return null; } public function getTableColumns($table, $typeOnly = true) { if (method_exists($this->dbo, 'getTableColumns')) { return $this->dbo->getTableColumns($table, $typeOnly); } $result = $this->dbo->getTableFields(array($table), $typeOnly); return $result[$table]; } public function getTableKeys($tables) { if (method_exists($this->dbo, 'getTableKeys')) { return $this->dbo->getTableKeys($tables); } return array(); } public function getTableList() { if (method_exists($this->dbo, 'getTableList')) { return $this->dbo->getTableList(); } return array(); } public function getVersion() { if (method_exists($this->dbo, 'getVersion')) { return $this->dbo->getVersion(); } return '5.0.40'; } public function insertid() { if (method_exists($this->dbo, 'insertid')) { return $this->dbo->insertid(); } return null; } public function insertObject($table, &$object, $key = null) { if (method_exists($this->dbo, 'insertObject')) { return $this->dbo->insertObject($table, $object, $key); } return null; } public function loadAssoc() { if (method_exists($this->dbo, 'loadAssoc')) { return $this->dbo->loadAssoc(); } return null; } public function loadAssocList($key = null, $column = null) { if (method_exists($this->dbo, 'loadAssocList')) { return $this->dbo->loadAssocList($key, $column); } return null; } public function loadObject($class = 'stdClass') { if (method_exists($this->dbo, 'loadObject')) { return $this->dbo->loadObject($class); } return null; } public function loadObjectList($key = '', $class = 'stdClass') { if (method_exists($this->dbo, 'loadObjectList')) { return $this->dbo->loadObjectList($key, $class); } return null; } public function loadResult() { if (method_exists($this->dbo, 'loadResult')) { return $this->dbo->loadResult(); } return null; } public function loadRow() { if (method_exists($this->dbo, 'loadRow')) { return $this->dbo->loadRow(); } return null; } public function loadRowList($key = null) { if (method_exists($this->dbo, 'loadRowList')) { return $this->dbo->loadRowList($key); } return null; } public function lockTable($tableName) { if (method_exists($this->dbo, 'lockTable')) { return $this->dbo->lockTable($this); } return $this; } public function quote($text, $escape = true) { if (method_exists($this->dbo, 'quote')) { return $this->dbo->quote($text, $escape); } return $text; } public function select($database) { if (method_exists($this->dbo, 'select')) { return $this->dbo->select($database); } return false; } public function setQuery($query, $offset = 0, $limit = 0) { if (method_exists($this->dbo, 'setQuery')) { return $this->dbo->setQuery($query, $offset, $limit); } return false; } public function transactionCommit($toSavepoint = false) { if (method_exists($this->dbo, 'transactionCommit')) { $this->dbo->transactionCommit($toSavepoint); } } public function transactionRollback($toSavepoint = false) { if (method_exists($this->dbo, 'transactionRollback')) { $this->dbo->transactionRollback($toSavepoint); } } public function transactionStart($asSavepoint = false) { if (method_exists($this->dbo, 'transactionStart')) { $this->dbo->transactionStart($asSavepoint); } } public function unlockTables() { if (method_exists($this->dbo, 'unlockTables')) { return $this->dbo->unlockTables(); } return $this; } public function updateObject($table, &$object, $key, $nulls = false) { if (method_exists($this->dbo, 'updateObject')) { return $this->dbo->updateObject($table, $object, $key, $nulls); } return false; } public function getLog() { if (method_exists($this->dbo, 'getLog')) { return $this->dbo->getLog(); } return array(); } public function dropTable($table, $ifExists = true) { if (method_exists($this->dbo, 'dropTable')) { return $this->dbo->dropTable($table, $ifExists); } return $this; } public function getTableCreate($tables) { if (method_exists($this->dbo, 'getTableCreate')) { return $this->dbo->getTableCreate($tables); } return array(); } public function renameTable($oldTable, $newTable, $backup = null, $prefix = null) { if (method_exists($this->dbo, 'renameTable')) { return $this->dbo->renameTable($oldTable, $newTable, $backup, $prefix); } return $this; } public function setUtf() { if (method_exists($this->dbo, 'setUtf')) { return $this->dbo->setUtf(); } return false; } protected function freeResult($cursor = null) { return false; } /** * Method to get an array of values from the <var>$offset</var> field in each row of the result set from * the database query. * * @param integer $offset The row offset to use to build the result array. * * @return mixed The return value or null if the query failed. * * @since 11.1 * @throws RuntimeException */ public function loadColumn($offset = 0) { if (method_exists($this->dbo, 'loadColumn')) { return $this->dbo->loadColumn($offset); } return $this->dbo->loadResultArray($offset); } /** * Wrap an SQL statement identifier name such as column, table or database names in quotes to prevent injection * risks and reserved word conflicts. * * @param mixed $name The identifier name to wrap in quotes, or an array of identifier names to wrap in quotes. * Each type supports dot-notation name. * @param mixed $as The AS query part associated to $name. It can be string or array, in latter case it has to be * same length of $name; if is null there will not be any AS part for string or array element. * * @return mixed The quote wrapped name, same type of $name. * * @since 11.1 */ public function quoteName($name, $as = null) { if (is_string($name)) { $quotedName = $this->quoteNameStr(explode('.', $name)); $quotedAs = ''; if (!is_null($as)) { settype($as, 'array'); $quotedAs .= ' AS ' . $this->quoteNameStr($as); } return $quotedName . $quotedAs; } else { $fin = array(); if (is_null($as)) { foreach ($name as $str) { $fin[] = $this->quoteName($str); } } elseif (is_array($name) && (count($name) == count($as))) { $count = count($name); for ($i = 0; $i < $count; $i++) { $fin[] = $this->quoteName($name[$i], $as[$i]); } } return $fin; } } /** * Quote strings coming from quoteName call. * * @param array $strArr Array of strings coming from quoteName dot-explosion. * * @return string Dot-imploded string of quoted parts. * * @since 11.3 */ protected function quoteNameStr($strArr) { $parts = array(); $q = $this->nameQuote; foreach ($strArr as $part) { if (is_null($part)) { continue; } if (strlen($q) == 1) { $parts[] = $q . $part . $q; } else { $parts[] = $q[0] . $part . $q[1]; } } return implode('.', $parts); } /** * Gets the error message from the database connection. * * @param boolean $escaped True to escape the message string for use in JavaScript. * * @return string The error message for the most recent query. * * @since 11.1 */ public function getErrorMsg($escaped = false) { if (method_exists($this->dbo, 'getErrorMsg')) { $errorMessage = $this->dbo->getErrorMsg(); } else { $errorMessage = $this->errorMsg; } if ($escaped) { return addslashes($errorMessage); } return $errorMessage; } /** * Gets the error number from the database connection. * * @return integer The error number for the most recent query. * * @since 11.1 * @deprecated 13.3 (Platform) & 4.0 (CMS) */ public function getErrorNum() { if (method_exists($this->dbo, 'getErrorNum')) { $errorNum = $this->dbo->getErrorNum(); } else { $errorNum = $this->getErrorNum; } return $errorNum; } /** * Return the most recent error message for the database connector. * * @param boolean $showSQL True to display the SQL statement sent to the database as well as the error. * * @return string The error message for the most recent query. */ public function stderr($showSQL = false) { if (method_exists($this->dbo, 'stderr')) { return $this->dbo->stderr($showSQL); } return parent::stderr($showSQL); } /** * Magic method to proxy all calls to the loaded database driver object */ public function __call($name, array $arguments) { if (is_null($this->dbo)) { throw new Exception('FOF database driver is not loaded'); } if (method_exists($this->dbo, $name) || in_array($name, array('q', 'nq', 'qn', 'query'))) { switch ($name) { case 'execute': $name = 'query'; break; case 'q': $name = 'quote'; break; case 'qn': case 'nq': switch (count($arguments)) { case 0 : $result = $this->quoteName(); break; case 1 : $result = $this->quoteName($arguments[0]); break; case 2: default: $result = $this->quoteName($arguments[0], $arguments[1]); break; } return $result; break; } switch (count($arguments)) { case 0 : $result = $this->dbo->$name(); break; case 1 : $result = $this->dbo->$name($arguments[0]); break; case 2: $result = $this->dbo->$name($arguments[0], $arguments[1]); break; case 3: $result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2]); break; case 4: $result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2], $arguments[3]); break; case 5: $result = $this->dbo->$name($arguments[0], $arguments[1], $arguments[2], $arguments[3], $arguments[4]); break; default: // Resort to using call_user_func_array for many segments $result = call_user_func_array(array($this->dbo, $name), $arguments); } if (class_exists('JDatabase') && is_object($result) && ($result instanceof JDatabase)) { return $this; } return $result; } else { throw new \Exception('Method ' . $name . ' not found in FOFDatabase'); } } public function __get($name) { if (isset($this->dbo->$name) || property_exists($this->dbo, $name)) { return $this->dbo->$name; } else { $this->dbo->$name = null; user_error('Database driver does not support property ' . $name); } } public function __set($name, $value) { if (isset($this->dbo->name) || property_exists($this->dbo, $name)) { $this->dbo->$name = $value; } else { $this->dbo->$name = null; user_error('Database driver not support property ' . $name); } } } home/wuectly/www/plugins/content/joomla/joomla.php 0000604 00000021365 15245613321 0016427 0 ustar 00 <?php /** * @package Joomla.Plugin * @subpackage Content.joomla * * @copyright (C) 2010 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('_JEXEC') or die; /** * Example Content Plugin * * @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 frontend 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; } $db = JFactory::getDbo(); $query = $db->getQuery(true) ->select($db->quoteName('id')) ->from($db->quoteName('#__users')) ->where($db->quoteName('sendEmail') . ' = 1') ->where($db->quoteName('block') . ' = 0'); $db->setQuery($query); $users = (array) $db->loadColumn(); if (empty($users)) { 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'); $default_language = JComponentHelper::getParams('com_languages')->get('administrator'); $debug = JFactory::getConfig()->get('debug_lang'); $result = true; 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; } /** * The save event. * * @param string $context The context * @param object $table The item * @param boolean $isNew Is new item * * @return void * * @since 3.9.12 */ public function onContentBeforeSave($context, $table, $isNew) { // Check we are handling the frontend edit form. if ($context !== 'com_menus.item') { return true; } // Special case for Create article menu item if ($table->link !== 'index.php?option=com_content&view=form&layout=edit') { return true; } // Display error if catid is not set when enable_category is enabled $params = json_decode($table->params, true); if ($params['enable_category'] == 1 && empty($params['catid'])) { $table->setError(JText::_('COM_CONTENT_CREATE_ARTICLE_ERROR')); return false; } } } home/wuectly/www/libraries/fof/utils/update/joomla.php 0000604 00000040260 15245617035 0017164 0 ustar 00 <?php /** * @package FrameworkOnFramework * @subpackage utils * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author. */ // Protect from unauthorized access defined('FOF_INCLUDED') or die; /** * A helper class which provides update information for the Joomla! CMS itself. This is slightly different than the * regular "extension" files as we need to know if a Joomla! version is STS, LTS, testing, current and so on. */ class FOFUtilsUpdateJoomla extends FOFUtilsUpdateExtension { /** * The source for LTS updates * * @var string */ protected static $lts_url = 'http://update.joomla.org/core/list.xml'; /** * The source for STS updates * * @var string */ protected static $sts_url = 'http://update.joomla.org/core/sts/list_sts.xml'; /** * The source for test release updates * * @var string */ protected static $test_url = 'http://update.joomla.org/core/test/list_test.xml'; /** * Reads an "extension" XML update source and returns all listed update entries. * * If you have a "collection" XML update source you should do something like this: * $collection = new CmsupdateHelperCollection(); * $extensionUpdateURL = $collection->getExtensionUpdateSource($url, 'component', 'com_foobar', JVERSION); * $extension = new CmsupdateHelperExtension(); * $updates = $extension->getUpdatesFromExtension($extensionUpdateURL); * * @param string $url The extension XML update source URL to read from * * @return array An array of update entries */ public function getUpdatesFromExtension($url) { // Initialise $ret = array(); // Get and parse the XML source $downloader = new FOFDownload(); $xmlSource = $downloader->getFromURL($url); try { $xml = new SimpleXMLElement($xmlSource, LIBXML_NONET); } catch (Exception $e) { return $ret; } // Sanity check if (($xml->getName() != 'updates')) { unset($xml); return $ret; } // Let's populate the list of updates /** @var SimpleXMLElement $update */ foreach ($xml->children() as $update) { // Sanity check if ($update->getName() != 'update') { continue; } $entry = array( 'infourl' => array('title' => '', 'url' => ''), 'downloads' => array(), 'tags' => array(), 'targetplatform' => array(), ); $properties = get_object_vars($update); foreach ($properties as $nodeName => $nodeContent) { switch ($nodeName) { default: $entry[ $nodeName ] = $nodeContent; break; case 'infourl': case 'downloads': case 'tags': case 'targetplatform': break; } } $infourlNode = $update->xpath('infourl'); $entry['infourl']['title'] = (string) $infourlNode[0]['title']; $entry['infourl']['url'] = (string) $infourlNode[0]; $downloadNodes = $update->xpath('downloads/downloadurl'); foreach ($downloadNodes as $downloadNode) { $entry['downloads'][] = array( 'type' => (string) $downloadNode['type'], 'format' => (string) $downloadNode['format'], 'url' => (string) $downloadNode, ); } $tagNodes = $update->xpath('tags/tag'); foreach ($tagNodes as $tagNode) { $entry['tags'][] = (string) $tagNode; } /** @var SimpleXMLElement[] $targetPlatformNode */ $targetPlatformNode = $update->xpath('targetplatform'); $entry['targetplatform']['name'] = (string) $targetPlatformNode[0]['name']; $entry['targetplatform']['version'] = (string) $targetPlatformNode[0]['version']; $client = $targetPlatformNode[0]->xpath('client'); $entry['targetplatform']['client'] = (is_array($client) && count($client)) ? (string) $client[0] : ''; $folder = $targetPlatformNode[0]->xpath('folder'); $entry['targetplatform']['folder'] = is_array($folder) && count($folder) ? (string) $folder[0] : ''; $ret[] = $entry; } unset($xml); return $ret; } /** * Reads a "collection" XML update source and picks the correct source URL * for the extension update source. * * @param string $url The collection XML update source URL to read from * @param string $jVersion Joomla! version to fetch updates for, or null to use JVERSION * * @return string The URL of the extension update source, or empty if no updates are provided / fetching failed */ public function getUpdateSourceFromCollection($url, $jVersion = null) { $provider = new FOFUtilsUpdateCollection(); return $provider->getExtensionUpdateSource($url, 'file', 'joomla', $jVersion); } /** * Determines the properties of a version: STS/LTS, normal or testing * * @param string $jVersion The version number to check * @param string $currentVersion The current Joomla! version number * * @return array The properties analysis */ public function getVersionProperties($jVersion, $currentVersion = null) { // Initialise $ret = array( 'lts' => true, // Is this an LTS release? False means STS. 'current' => false, // Is this a release in the $currentVersion branch? 'upgrade' => 'none', // Upgrade relation of $jVersion to $currentVersion: 'none' (can't upgrade), 'lts' (next or current LTS), 'sts' (next or current STS) or 'current' (same release, no upgrade available) 'testing' => false, // Is this a testing (alpha, beta, RC) release? ); // Get the current version if none is defined if (is_null($currentVersion)) { $currentVersion = JVERSION; } // Sanitise version numbers $sameVersion = $jVersion == $currentVersion; $jVersion = $this->sanitiseVersion($jVersion); $currentVersion = $this->sanitiseVersion($currentVersion); $sameVersion = $sameVersion || ($jVersion == $currentVersion); // Get the base version $baseVersion = substr($jVersion, 0, 3); // Get the minimum and maximum current version numbers $current_minimum = substr($currentVersion, 0, 3); $current_maximum = $current_minimum . '.9999'; // Initialise STS/LTS version numbers $sts_minimum = false; $sts_maximum = false; $lts_minimum = false; // Is it an LTS or STS release? switch ($baseVersion) { case '1.5': $ret['lts'] = true; break; case '1.6': $ret['lts'] = false; $sts_minimum = '1.7'; $sts_maximum = '1.7.999'; $lts_minimum = '2.5'; break; case '1.7': $ret['lts'] = false; $sts_minimum = false; $lts_minimum = '2.5'; break; case '2.5': $ret['lts'] = true; $sts_minimum = false; $lts_minimum = '2.5'; break; default: $majorVersion = (int) substr($jVersion, 0, 1); //$minorVersion = (int) substr($jVersion, 2, 1); $ret['lts'] = true; $sts_minimum = false; $lts_minimum = $majorVersion . '.0'; break; } // Is it a current release? if (version_compare($jVersion, $current_minimum, 'ge') && version_compare($jVersion, $current_maximum, 'le')) { $ret['current'] = true; } // Is this a testing release? $versionParts = explode('.', $jVersion); $lastVersionPart = array_pop($versionParts); if (in_array(substr($lastVersionPart, 0, 1), array('a', 'b'))) { $ret['testing'] = true; } elseif (substr($lastVersionPart, 0, 2) == 'rc') { $ret['testing'] = true; } elseif (substr($lastVersionPart, 0, 3) == 'dev') { $ret['testing'] = true; } // Find the upgrade relation of $jVersion to $currentVersion if (version_compare($jVersion, $currentVersion, 'eq')) { $ret['upgrade'] = 'current'; } elseif (($sts_minimum !== false) && version_compare($jVersion, $sts_minimum, 'ge') && version_compare($jVersion, $sts_maximum, 'le')) { $ret['upgrade'] = 'sts'; } elseif (($lts_minimum !== false) && version_compare($jVersion, $lts_minimum, 'ge')) { $ret['upgrade'] = 'lts'; } elseif ($baseVersion == $current_minimum) { $ret['upgrade'] = $ret['lts'] ? 'lts' : 'sts'; } else { $ret['upgrade'] = 'none'; } if ($sameVersion) { $ret['upgrade'] = 'none'; } return $ret; } /** * Filters a list of updates, making sure they apply to the specified CMS * release. * * @param array $updates A list of update records returned by the getUpdatesFromExtension method * @param string $jVersion The current Joomla! version number * * @return array A filtered list of updates. Each update record also includes version relevance information. */ public function filterApplicableUpdates($updates, $jVersion = null) { if (empty($jVersion)) { $jVersion = JVERSION; } $versionParts = explode('.', $jVersion, 4); $platformVersionMajor = $versionParts[0]; $platformVersionMinor = $platformVersionMajor . '.' . $versionParts[1]; $platformVersionNormal = $platformVersionMinor . '.' . $versionParts[2]; //$platformVersionFull = (count($versionParts) > 3) ? $platformVersionNormal . '.' . $versionParts[3] : $platformVersionNormal; $ret = array(); foreach ($updates as $update) { // Check each update for platform match if (strtolower($update['targetplatform']['name']) != 'joomla') { continue; } $targetPlatformVersion = $update['targetplatform']['version']; if (!preg_match('/' . $targetPlatformVersion . '/', $platformVersionMinor)) { continue; } // Get some information from the version number $updateVersion = $update['version']; $versionProperties = $this->getVersionProperties($updateVersion, $jVersion); if ($versionProperties['upgrade'] == 'none') { continue; } // The XML files are ill-maintained. Maybe we already have this update? if (!array_key_exists($updateVersion, $ret)) { $ret[ $updateVersion ] = array_merge($update, $versionProperties); } } return $ret; } /** * Joomla! has a lousy track record in naming its alpha, beta and release * candidate releases. The convention used seems to be "what the hell the * current package maintainer thinks looks better". This method tries to * figure out what was in the mind of the maintainer and translate the * funky version number to an actual PHP-format version string. * * @param string $version The whatever-format version number * * @return string A standard formatted version number */ public function sanitiseVersion($version) { $test = strtolower($version); $alphaQualifierPosition = strpos($test, 'alpha-'); $betaQualifierPosition = strpos($test, 'beta-'); $betaQualifierPosition2 = strpos($test, '-beta'); $rcQualifierPosition = strpos($test, 'rc-'); $rcQualifierPosition2 = strpos($test, '-rc'); $rcQualifierPosition3 = strpos($test, 'rc'); $devQualifiedPosition = strpos($test, 'dev'); if ($alphaQualifierPosition !== false) { $betaRevision = substr($test, $alphaQualifierPosition + 6); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $alphaQualifierPosition) . '.a' . $betaRevision; } elseif ($betaQualifierPosition !== false) { $betaRevision = substr($test, $betaQualifierPosition + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $betaQualifierPosition) . '.b' . $betaRevision; } elseif ($betaQualifierPosition2 !== false) { $betaRevision = substr($test, $betaQualifierPosition2 + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $betaQualifierPosition2) . '.b' . $betaRevision; } elseif ($rcQualifierPosition !== false) { $betaRevision = substr($test, $rcQualifierPosition + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $rcQualifierPosition) . '.rc' . $betaRevision; } elseif ($rcQualifierPosition2 !== false) { $betaRevision = substr($test, $rcQualifierPosition2 + 3); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $rcQualifierPosition2) . '.rc' . $betaRevision; } elseif ($rcQualifierPosition3 !== false) { $betaRevision = substr($test, $rcQualifierPosition3 + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $rcQualifierPosition3) . '.rc' . $betaRevision; } elseif ($devQualifiedPosition !== false) { $betaRevision = substr($test, $devQualifiedPosition + 6); if (!$betaRevision) { $betaRevision = ''; } $test = substr($test, 0, $devQualifiedPosition) . '.dev' . $betaRevision; } return $test; } /** * Reloads the list of all updates available for the specified Joomla! version * from the network. * * @param array $sources The enabled sources to look into * @param string $jVersion The Joomla! version we are checking updates for * * @return array A list of updates for the installed, current, lts and sts versions */ public function getUpdates($sources = array(), $jVersion = null) { // Make sure we have a valid list of sources if (empty($sources) || !is_array($sources)) { $sources = array(); } $defaultSources = array('lts' => true, 'sts' => true, 'test' => true, 'custom' => ''); $sources = array_merge($defaultSources, $sources); // Use the current JVERSION if none is specified if (empty($jVersion)) { $jVersion = JVERSION; } // Get the current branch' min/max versions $versionParts = explode('.', $jVersion, 4); $currentMinVersion = $versionParts[0] . '.' . $versionParts[1]; $currentMaxVersion = $versionParts[0] . '.' . $versionParts[1] . '.9999'; // Retrieve all updates $allUpdates = array(); foreach ($sources as $source => $value) { if (($value === false) || empty($value)) { continue; } switch ($source) { case 'lts': $url = self::$lts_url; break; case 'sts': $url = self::$sts_url; break; case 'test': $url = self::$test_url; break; default: case 'custom': $url = $value; break; } $url = $this->getUpdateSourceFromCollection($url, $jVersion); if (!empty($url)) { $updates = $this->getUpdatesFromExtension($url); if (!empty($updates)) { $applicableUpdates = $this->filterApplicableUpdates($updates, $jVersion); if (!empty($applicableUpdates)) { $allUpdates = array_merge($allUpdates, $applicableUpdates); } } } } $ret = array( // Currently installed version (used to reinstall, if available) 'installed' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Current branch 'current' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Upgrade to STS release 'sts' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Upgrade to LTS release 'lts' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Upgrade to LTS release 'test' => array( 'version' => '', 'package' => '', 'infourl' => '', ), ); foreach ($allUpdates as $update) { $sections = array(); if ($update['upgrade'] == 'current') { $sections[0] = 'installed'; } elseif (version_compare($update['version'], $currentMinVersion, 'ge') && version_compare($update['version'], $currentMaxVersion, 'le')) { $sections[0] = 'current'; } else { $sections[0] = ''; } $sections[1] = $update['lts'] ? 'lts' : 'sts'; if ($update['testing']) { $sections = array('test'); } foreach ($sections as $section) { if (empty($section)) { continue; } $existingVersionForSection = $ret[ $section ]['version']; if (empty($existingVersionForSection)) { $existingVersionForSection = '0.0.0'; } if (version_compare($update['version'], $existingVersionForSection, 'ge')) { $ret[ $section ]['version'] = $update['version']; $ret[ $section ]['package'] = $update['downloads'][0]['url']; $ret[ $section ]['infourl'] = $update['infourl']['url']; } } } // Catch the case when the latest current branch version is the installed version (up to date site) if (empty($ret['current']['version']) && !empty($ret['installed']['version'])) { $ret['current'] = $ret['installed']; } return $ret; } } home/wuectly/www/libraries/cms/less/formatter/joomla.php 0000604 00000001246 15245632612 0017522 0 ustar 00 <?php /** * @package Joomla.Libraries * @subpackage Less * * @copyright (C) 2014 Open Source Matters, Inc. <https://www.joomla.org> * @license GNU General Public License version 2 or later; see LICENSE.txt */ defined('JPATH_PLATFORM') or die; /** * Formatter ruleset for Joomla formatted CSS generated via LESS * * @package Joomla.Libraries * @subpackage Less * @since 3.4 * @deprecated 4.0 without replacement */ class JLessFormatterJoomla extends lessc_formatter_classic { public $disableSingle = true; public $breakSelectors = true; public $assignSeparator = ': '; public $selectorSeparator = ','; public $indentChar = "\t"; } home/wuectly/www/libraries/f0f/utils/update/joomla.php 0000604 00000040064 15245653060 0017065 0 ustar 00 <?php /** * @package FrameworkOnFramework * @subpackage utils * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // Protect from unauthorized access defined('F0F_INCLUDED') or die; /** * A helper class which provides update information for the Joomla! CMS itself. This is slightly different than the * regular "extension" files as we need to know if a Joomla! version is STS, LTS, testing, current and so on. */ class F0FUtilsUpdateJoomla extends F0FUtilsUpdateExtension { /** * The source for LTS updates * * @var string */ protected static $lts_url = 'http://update.joomla.org/core/list.xml'; /** * The source for STS updates * * @var string */ protected static $sts_url = 'http://update.joomla.org/core/sts/list_sts.xml'; /** * The source for test release updates * * @var string */ protected static $test_url = 'http://update.joomla.org/core/test/list_test.xml'; /** * Reads an "extension" XML update source and returns all listed update entries. * * If you have a "collection" XML update source you should do something like this: * $collection = new CmsupdateHelperCollection(); * $extensionUpdateURL = $collection->getExtensionUpdateSource($url, 'component', 'com_foobar', JVERSION); * $extension = new CmsupdateHelperExtension(); * $updates = $extension->getUpdatesFromExtension($extensionUpdateURL); * * @param string $url The extension XML update source URL to read from * * @return array An array of update entries */ public function getUpdatesFromExtension($url) { // Initialise $ret = array(); // Get and parse the XML source $downloader = new F0FDownload(); $xmlSource = $downloader->getFromURL($url); try { $xml = new SimpleXMLElement($xmlSource, LIBXML_NONET); } catch (Exception $e) { return $ret; } // Sanity check if (($xml->getName() != 'updates')) { unset($xml); return $ret; } // Let's populate the list of updates /** @var SimpleXMLElement $update */ foreach ($xml->children() as $update) { // Sanity check if ($update->getName() != 'update') { continue; } $entry = array( 'infourl' => array('title' => '', 'url' => ''), 'downloads' => array(), 'tags' => array(), 'targetplatform' => array(), ); $properties = get_object_vars($update); foreach ($properties as $nodeName => $nodeContent) { switch ($nodeName) { default: $entry[ $nodeName ] = $nodeContent; break; case 'infourl': case 'downloads': case 'tags': case 'targetplatform': break; } } $infourlNode = $update->xpath('infourl'); $entry['infourl']['title'] = (string) $infourlNode[0]['title']; $entry['infourl']['url'] = (string) $infourlNode[0]; $downloadNodes = $update->xpath('downloads/downloadurl'); foreach ($downloadNodes as $downloadNode) { $entry['downloads'][] = array( 'type' => (string) $downloadNode['type'], 'format' => (string) $downloadNode['format'], 'url' => (string) $downloadNode, ); } $tagNodes = $update->xpath('tags/tag'); foreach ($tagNodes as $tagNode) { $entry['tags'][] = (string) $tagNode; } /** @var SimpleXMLElement[] $targetPlatformNode */ $targetPlatformNode = $update->xpath('targetplatform'); $entry['targetplatform']['name'] = (string) $targetPlatformNode[0]['name']; $entry['targetplatform']['version'] = (string) $targetPlatformNode[0]['version']; $client = $targetPlatformNode[0]->xpath('client'); $entry['targetplatform']['client'] = (is_array($client) && count($client)) ? (string) $client[0] : ''; $folder = $targetPlatformNode[0]->xpath('folder'); $entry['targetplatform']['folder'] = is_array($folder) && count($folder) ? (string) $folder[0] : ''; $ret[] = $entry; } unset($xml); return $ret; } /** * Reads a "collection" XML update source and picks the correct source URL * for the extension update source. * * @param string $url The collection XML update source URL to read from * @param string $jVersion Joomla! version to fetch updates for, or null to use JVERSION * * @return string The URL of the extension update source, or empty if no updates are provided / fetching failed */ public function getUpdateSourceFromCollection($url, $jVersion = null) { $provider = new F0FUtilsUpdateCollection(); return $provider->getExtensionUpdateSource($url, 'file', 'joomla', $jVersion); } /** * Determines the properties of a version: STS/LTS, normal or testing * * @param string $jVersion The version number to check * @param string $currentVersion The current Joomla! version number * * @return array The properties analysis */ public function getVersionProperties($jVersion, $currentVersion = null) { // Initialise $ret = array( 'lts' => true, // Is this an LTS release? False means STS. 'current' => false, // Is this a release in the $currentVersion branch? 'upgrade' => 'none', // Upgrade relation of $jVersion to $currentVersion: 'none' (can't upgrade), 'lts' (next or current LTS), 'sts' (next or current STS) or 'current' (same release, no upgrade available) 'testing' => false, // Is this a testing (alpha, beta, RC) release? ); // Get the current version if none is defined if (is_null($currentVersion)) { $currentVersion = JVERSION; } // Sanitise version numbers $sameVersion = $jVersion == $currentVersion; $jVersion = $this->sanitiseVersion($jVersion); $currentVersion = $this->sanitiseVersion($currentVersion); $sameVersion = $sameVersion || ($jVersion == $currentVersion); // Get the base version $baseVersion = substr($jVersion, 0, 3); // Get the minimum and maximum current version numbers $current_minimum = substr($currentVersion, 0, 3); $current_maximum = $current_minimum . '.9999'; // Initialise STS/LTS version numbers $sts_minimum = false; $sts_maximum = false; $lts_minimum = false; // Is it an LTS or STS release? switch ($baseVersion) { case '1.5': $ret['lts'] = true; break; case '1.6': $ret['lts'] = false; $sts_minimum = '1.7'; $sts_maximum = '1.7.999'; $lts_minimum = '2.5'; break; case '1.7': $ret['lts'] = false; $sts_minimum = false; $lts_minimum = '2.5'; break; case '2.5': $ret['lts'] = true; $sts_minimum = false; $lts_minimum = '2.5'; break; default: $majorVersion = (int) substr($jVersion, 0, 1); //$minorVersion = (int) substr($jVersion, 2, 1); $ret['lts'] = true; $sts_minimum = false; $lts_minimum = $majorVersion . '.0'; break; } // Is it a current release? if (version_compare($jVersion, $current_minimum, 'ge') && version_compare($jVersion, $current_maximum, 'le')) { $ret['current'] = true; } // Is this a testing release? $versionParts = explode('.', $jVersion); $lastVersionPart = array_pop($versionParts); if (in_array(substr($lastVersionPart, 0, 1), array('a', 'b'))) { $ret['testing'] = true; } elseif (substr($lastVersionPart, 0, 2) == 'rc') { $ret['testing'] = true; } elseif (substr($lastVersionPart, 0, 3) == 'dev') { $ret['testing'] = true; } // Find the upgrade relation of $jVersion to $currentVersion if (version_compare($jVersion, $currentVersion, 'eq')) { $ret['upgrade'] = 'current'; } elseif (($sts_minimum !== false) && version_compare($jVersion, $sts_minimum, 'ge') && version_compare($jVersion, $sts_maximum, 'le')) { $ret['upgrade'] = 'sts'; } elseif (($lts_minimum !== false) && version_compare($jVersion, $lts_minimum, 'ge')) { $ret['upgrade'] = 'lts'; } elseif ($baseVersion == $current_minimum) { $ret['upgrade'] = $ret['lts'] ? 'lts' : 'sts'; } else { $ret['upgrade'] = 'none'; } if ($sameVersion) { $ret['upgrade'] = 'none'; } return $ret; } /** * Filters a list of updates, making sure they apply to the specifed CMS * release. * * @param array $updates A list of update records returned by the getUpdatesFromExtension method * @param string $jVersion The current Joomla! version number * * @return array A filtered list of updates. Each update record also includes version relevance information. */ public function filterApplicableUpdates($updates, $jVersion = null) { if (empty($jVersion)) { $jVersion = JVERSION; } $versionParts = explode('.', $jVersion, 4); $platformVersionMajor = $versionParts[0]; $platformVersionMinor = $platformVersionMajor . '.' . $versionParts[1]; $platformVersionNormal = $platformVersionMinor . '.' . $versionParts[2]; //$platformVersionFull = (count($versionParts) > 3) ? $platformVersionNormal . '.' . $versionParts[3] : $platformVersionNormal; $ret = array(); foreach ($updates as $update) { // Check each update for platform match if (strtolower($update['targetplatform']['name']) != 'joomla') { continue; } $targetPlatformVersion = $update['targetplatform']['version']; if (!preg_match('/' . $targetPlatformVersion . '/', $platformVersionMinor)) { continue; } // Get some information from the version number $updateVersion = $update['version']; $versionProperties = $this->getVersionProperties($updateVersion, $jVersion); if ($versionProperties['upgrade'] == 'none') { continue; } // The XML files are ill-maintained. Maybe we already have this update? if (!array_key_exists($updateVersion, $ret)) { $ret[ $updateVersion ] = array_merge($update, $versionProperties); } } return $ret; } /** * Joomla! has a lousy track record in naming its alpha, beta and release * candidate releases. The convention used seems to be "what the hell the * current package maintainer thinks looks better". This method tries to * figure out what was in the mind of the maintainer and translate the * funky version number to an actual PHP-format version string. * * @param string $version The whatever-format version number * * @return string A standard formatted version number */ public function sanitiseVersion($version) { $test = strtolower($version); $alphaQualifierPosition = strpos($test, 'alpha-'); $betaQualifierPosition = strpos($test, 'beta-'); $betaQualifierPosition2 = strpos($test, '-beta'); $rcQualifierPosition = strpos($test, 'rc-'); $rcQualifierPosition2 = strpos($test, '-rc'); $rcQualifierPosition3 = strpos($test, 'rc'); $devQualifiedPosition = strpos($test, 'dev'); if ($alphaQualifierPosition !== false) { $betaRevision = substr($test, $alphaQualifierPosition + 6); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $alphaQualifierPosition) . '.a' . $betaRevision; } elseif ($betaQualifierPosition !== false) { $betaRevision = substr($test, $betaQualifierPosition + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $betaQualifierPosition) . '.b' . $betaRevision; } elseif ($betaQualifierPosition2 !== false) { $betaRevision = substr($test, $betaQualifierPosition2 + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $betaQualifierPosition2) . '.b' . $betaRevision; } elseif ($rcQualifierPosition !== false) { $betaRevision = substr($test, $rcQualifierPosition + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $rcQualifierPosition) . '.rc' . $betaRevision; } elseif ($rcQualifierPosition2 !== false) { $betaRevision = substr($test, $rcQualifierPosition2 + 3); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $rcQualifierPosition2) . '.rc' . $betaRevision; } elseif ($rcQualifierPosition3 !== false) { $betaRevision = substr($test, $rcQualifierPosition3 + 5); if (!$betaRevision) { $betaRevision = 1; } $test = substr($test, 0, $rcQualifierPosition3) . '.rc' . $betaRevision; } elseif ($devQualifiedPosition !== false) { $betaRevision = substr($test, $devQualifiedPosition + 6); if (!$betaRevision) { $betaRevision = ''; } $test = substr($test, 0, $devQualifiedPosition) . '.dev' . $betaRevision; } return $test; } /** * Reloads the list of all updates available for the specified Joomla! version * from the network. * * @param array $sources The enabled sources to look into * @param string $jVersion The Joomla! version we are checking updates for * * @return array A list of updates for the installed, current, lts and sts versions */ public function getUpdates($sources = array(), $jVersion = null) { // Make sure we have a valid list of sources if (empty($sources) || !is_array($sources)) { $sources = array(); } $defaultSources = array('lts' => true, 'sts' => true, 'test' => true, 'custom' => ''); $sources = array_merge($defaultSources, $sources); // Use the current JVERSION if none is specified if (empty($jVersion)) { $jVersion = JVERSION; } // Get the current branch' min/max versions $versionParts = explode('.', $jVersion, 4); $currentMinVersion = $versionParts[0] . '.' . $versionParts[1]; $currentMaxVersion = $versionParts[0] . '.' . $versionParts[1] . '.9999'; // Retrieve all updates $allUpdates = array(); foreach ($sources as $source => $value) { if (($value === false) || empty($value)) { continue; } switch ($source) { case 'lts': $url = self::$lts_url; break; case 'sts': $url = self::$sts_url; break; case 'test': $url = self::$test_url; break; default: case 'custom': $url = $value; break; } $url = $this->getUpdateSourceFromCollection($url, $jVersion); if (!empty($url)) { $updates = $this->getUpdatesFromExtension($url); if (!empty($updates)) { $applicableUpdates = $this->filterApplicableUpdates($updates, $jVersion); if (!empty($applicableUpdates)) { $allUpdates = array_merge($allUpdates, $applicableUpdates); } } } } $ret = array( // Currently installed version (used to reinstall, if available) 'installed' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Current branch 'current' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Upgrade to STS release 'sts' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Upgrade to LTS release 'lts' => array( 'version' => '', 'package' => '', 'infourl' => '', ), // Upgrade to LTS release 'test' => array( 'version' => '', 'package' => '', 'infourl' => '', ), ); foreach ($allUpdates as $update) { $sections = array(); if ($update['upgrade'] == 'current') { $sections[0] = 'installed'; } elseif (version_compare($update['version'], $currentMinVersion, 'ge') && version_compare($update['version'], $currentMaxVersion, 'le')) { $sections[0] = 'current'; } else { $sections[0] = ''; } $sections[1] = $update['lts'] ? 'lts' : 'sts'; if ($update['testing']) { $sections = array('test'); } foreach ($sections as $section) { if (empty($section)) { continue; } $existingVersionForSection = $ret[ $section ]['version']; if (empty($existingVersionForSection)) { $existingVersionForSection = '0.0.0'; } if (version_compare($update['version'], $existingVersionForSection, 'ge')) { $ret[ $section ]['version'] = $update['version']; $ret[ $section ]['package'] = $update['downloads'][0]['url']; $ret[ $section ]['infourl'] = $update['infourl']['url']; } } } // Catch the case when the latest current branch version is the installed version (up to date site) if (empty($ret['current']['version']) && !empty($ret['installed']['version'])) { $ret['current'] = $ret['installed']; } return $ret; } } home/wuectly/www/libraries/f0f/less/formatter/joomla.php 0000604 00000001525 15245662551 0017420 0 ustar 00 <?php /** * @package FrameworkOnFramework * @subpackage less * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt */ // Protect from unauthorized access defined('F0F_INCLUDED') or die; /** * This class is taken verbatim from: * * lessphp v0.3.9 * http://leafo.net/lessphp * * LESS css compiler, adapted from http://lesscss.org * * Copyright 2012, Leaf Corcoran <leafot@gmail.com> * Licensed under MIT or GPLv3, see LICENSE * * @package FrameworkOnFramework * @since 2.1 */ class F0FLessFormatterJoomla extends F0FLessFormatterClassic { public $disableSingle = true; public $breakSelectors = true; public $assignSeparator = ": "; public $selectorSeparator = ","; public $indentChar = "\t"; } home/wuectly/www/libraries/fof/render/joomla.php 0000604 00000052471 15245667575 0016046 0 ustar 00 <?php /** * @package FrameworkOnFramework * @subpackage render * @copyright Copyright (C) 2010-2016 Nicholas K. Dionysopoulos / Akeeba Ltd. All rights reserved. * @license GNU General Public License version 2 or later; see LICENSE.txt * @note This file has been modified by the Joomla! Project and no longer reflects the original work of its author. */ defined('FOF_INCLUDED') or die; /** * Default Joomla! 1.5, 1.7, 2.5 view renderer class * * @package FrameworkOnFramework * @since 2.0 */ class FOFRenderJoomla extends FOFRenderAbstract { /** * Public constructor. Determines the priority of this class and if it should be enabled */ public function __construct() { $this->priority = 50; $this->enabled = true; } /** * Echoes any HTML to show before the view template * * @param string $view The current view * @param string $task The current task * @param FOFInput $input The input array (request parameters) * @param array $config The view configuration array * * @return void */ public function preRender($view, $task, $input, $config = array()) { $format = $input->getCmd('format', 'html'); if (empty($format)) { $format = 'html'; } if ($format != 'html') { return; } $platform = FOFPlatform::getInstance(); if ($platform->isCli()) { return; } if (version_compare(JVERSION, '3.0.0', 'lt')) { JHtml::_('behavior.framework'); } else { if (version_compare(JVERSION, '3.3.0', 'ge')) { JHtml::_('behavior.core'); } else { JHtml::_('behavior.framework', true); } JHtml::_('jquery.framework'); } // Wrap output in various classes $version = new JVersion; $versionParts = explode('.', $version->RELEASE); $minorVersion = str_replace('.', '', $version->RELEASE); $majorVersion = array_shift($versionParts); if ($platform->isBackend()) { $area = $platform->isBackend() ? 'admin' : 'site'; $option = $input->getCmd('option', ''); $view = $input->getCmd('view', ''); $layout = $input->getCmd('layout', ''); $task = $input->getCmd('task', ''); $classes = array( 'joomla-version-' . $majorVersion, 'joomla-version-' . $minorVersion, $area, $option, 'view-' . $view, 'layout-' . $layout, 'task-' . $task, ); } elseif ($platform->isFrontend()) { // @TODO: Remove the frontend Joomla! version classes in FOF 3 $classes = array( 'joomla-version-' . $majorVersion, 'joomla-version-' . $minorVersion, ); } echo '<div id="akeeba-renderjoomla" class="' . implode(' ', $classes) . "\">\n"; // Render submenu and toolbar (only if asked to) if ($input->getBool('render_toolbar', true)) { $this->renderButtons($view, $task, $input, $config); $this->renderLinkbar($view, $task, $input, $config); } } /** * Echoes any HTML to show after the view template * * @param string $view The current view * @param string $task The current task * @param FOFInput $input The input array (request parameters) * @param array $config The view configuration array * * @return void */ public function postRender($view, $task, $input, $config = array()) { $format = $input->getCmd('format', 'html'); if (empty($format)) { $format = 'html'; } if ($format != 'html') { return; } // Closing tag only if we're not in CLI if (FOFPlatform::getInstance()->isCli()) { return; } echo "</div>\n"; // Closes akeeba-renderjoomla div } /** * Renders a FOFForm for a Browse view and returns the corresponding HTML * * @param FOFForm &$form The form to render * @param FOFModel $model The model providing our data * @param FOFInput $input The input object * * @return string The HTML rendering of the form */ protected function renderFormBrowse(FOFForm &$form, FOFModel $model, FOFInput $input) { JHtml::_('behavior.multiselect'); // Getting all header row elements $headerFields = $form->getHeaderset(); // Start the form $html = ''; $filter_order = $form->getView()->getLists()->order; $filter_order_Dir = $form->getView()->getLists()->order_Dir; $actionUrl = FOFPlatform::getInstance()->isBackend() ? 'index.php' : JUri::root().'index.php'; if (FOFPlatform::getInstance()->isFrontend() && ($input->getCmd('Itemid', 0) != 0)) { $itemid = $input->getCmd('Itemid', 0); $uri = new JUri($actionUrl); if ($itemid) { $uri->setVar('Itemid', $itemid); } $actionUrl = JRoute::_($uri->toString()); } $html .= '<form action="'.$actionUrl.'" method="post" name="adminForm" id="adminForm">' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="view" value="' . FOFInflector::pluralize($input->getCmd('view')) . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="task" value="" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="layout" value="' . $input->getCmd('layout', '') . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="boxchecked" value="" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="hidemainmenu" value="" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="filter_order" value="' . $filter_order . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="filter_order_Dir" value="' . $filter_order_Dir . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL; // Start the table output $html .= "\t\t" . '<table class="adminlist" id="adminList">' . PHP_EOL; // Get form parameters $show_header = $form->getAttribute('show_header', 1); $show_filters = $form->getAttribute('show_filters', 1); $show_pagination = $form->getAttribute('show_pagination', 1); $norows_placeholder = $form->getAttribute('norows_placeholder', ''); // Open the table header region if required if ($show_header || $show_filters) { $html .= "\t\t\t<thead>" . PHP_EOL; } // Pre-render the header and filter rows if ($show_header || $show_filters) { $header_html = ''; $filter_html = ''; foreach ($headerFields as $header) { // Make sure we have a header field. Under Joomla! 2.5 we cannot // render filter-only fields. $tmpHeader = $header->header; if (empty($tmpHeader)) { continue; } $tdwidth = $header->tdwidth; if (!empty($tdwidth)) { $tdwidth = 'width="' . $tdwidth . '"'; } else { $tdwidth = ''; } $header_html .= "\t\t\t\t\t<th $tdwidth>" . PHP_EOL; $header_html .= "\t\t\t\t\t\t" . $tmpHeader; $header_html .= "\t\t\t\t\t</th>" . PHP_EOL; $filter = $header->filter; $buttons = $header->buttons; $options = $header->options; $filter_html .= "\t\t\t\t\t<td>" . PHP_EOL; if (!empty($filter)) { $filter_html .= "\t\t\t\t\t\t$filter" . PHP_EOL; if (!empty($buttons)) { $filter_html .= "\t\t\t\t\t\t<nobr>$buttons</nobr>" . PHP_EOL; } } elseif (!empty($options)) { $label = $header->label; $emptyOption = JHtml::_('select.option', '', '- ' . JText::_($label) . ' -'); array_unshift($options, $emptyOption); $attribs = array( 'onchange' => 'document.adminForm.submit();' ); $filter = JHtml::_('select.genericlist', $options, $header->name, $attribs, 'value', 'text', $header->value, false, true); $filter_html .= "\t\t\t\t\t\t$filter" . PHP_EOL; } $filter_html .= "\t\t\t\t\t</td>" . PHP_EOL; } } // Render header if enabled if ($show_header) { $html .= "\t\t\t\t<tr>" . PHP_EOL; $html .= $header_html; $html .= "\t\t\t\t</tr>" . PHP_EOL; } // Render filter row if enabled if ($show_filters) { $html .= "\t\t\t\t<tr>"; $html .= $filter_html; $html .= "\t\t\t\t</tr>"; } // Close the table header region if required if ($show_header || $show_filters) { $html .= "\t\t\t</thead>" . PHP_EOL; } // Loop through rows and fields, or show placeholder for no rows $html .= "\t\t\t<tbody>" . PHP_EOL; $fields = $form->getFieldset('items'); $num_columns = count($fields); $items = $form->getModel()->getItemList(); if ($count = count($items)) { $m = 1; foreach ($items as $i => $item) { $table_item = $form->getModel()->getTable(); $table_item->reset(); $table_item->bind($item); $form->bind($item); $m = 1 - $m; $class = 'row' . $m; $html .= "\t\t\t\t<tr class=\"$class\">" . PHP_EOL; $fields = $form->getFieldset('items'); foreach ($fields as $field) { $field->rowid = $i; $field->item = $table_item; $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass; // Joomla! 2.5/3.x use different case for the same name $class = $labelClass ? 'class ="' . $labelClass . '"' : ''; $html .= "\t\t\t\t\t<td $class>" . $field->getRepeatable() . '</td>' . PHP_EOL; } $html .= "\t\t\t\t</tr>" . PHP_EOL; } } elseif ($norows_placeholder) { $html .= "\t\t\t\t<tr><td colspan=\"$num_columns\">"; $html .= JText::_($norows_placeholder); $html .= "</td></tr>\n"; } $html .= "\t\t\t</tbody>" . PHP_EOL; // Render the pagination bar, if enabled if ($show_pagination) { $pagination = $form->getModel()->getPagination(); $html .= "\t\t\t<tfoot>" . PHP_EOL; $html .= "\t\t\t\t<tr><td colspan=\"$num_columns\">"; if (($pagination->total > 0)) { $html .= $pagination->getListFooter(); } $html .= "</td></tr>\n"; $html .= "\t\t\t</tfoot>" . PHP_EOL; } // End the table output $html .= "\t\t" . '</table>' . PHP_EOL; // End the form $html .= '</form>' . PHP_EOL; return $html; } /** * Renders a FOFForm for a Read view and returns the corresponding HTML * * @param FOFForm &$form The form to render * @param FOFModel $model The model providing our data * @param FOFInput $input The input object * * @return string The HTML rendering of the form */ protected function renderFormRead(FOFForm &$form, FOFModel $model, FOFInput $input) { $html = $this->renderFormRaw($form, $model, $input, 'read'); return $html; } /** * Renders a FOFForm for an Edit view and returns the corresponding HTML * * @param FOFForm &$form The form to render * @param FOFModel $model The model providing our data * @param FOFInput $input The input object * * @return string The HTML rendering of the form */ protected function renderFormEdit(FOFForm &$form, FOFModel $model, FOFInput $input) { // Get the key for this model's table $key = $model->getTable()->getKeyName(); $keyValue = $model->getId(); JHTML::_('behavior.tooltip'); $html = ''; $validate = strtolower($form->getAttribute('validate')); $class = ''; if (in_array($validate, array('true', 'yes', '1', 'on'))) { JHtml::_('behavior.formvalidation'); $class = 'form-validate '; $this->loadValidationScript($form); } // Check form enctype. Use enctype="multipart/form-data" to upload binary files in your form. $template_form_enctype = $form->getAttribute('enctype'); if (!empty($template_form_enctype)) { $enctype = ' enctype="' . $form->getAttribute('enctype') . '" '; } else { $enctype = ''; } // Check form name. Use name="yourformname" to modify the name of your form. $formname = $form->getAttribute('name'); if (empty($formname)) { $formname = 'adminForm'; } // Check form ID. Use id="yourformname" to modify the id of your form. $formid = $form->getAttribute('name'); if (empty($formid)) { $formid = 'adminForm'; } // Check if we have a custom task $customTask = $form->getAttribute('customTask'); if (empty($customTask)) { $customTask = ''; } // Get the form action URL $actionUrl = FOFPlatform::getInstance()->isBackend() ? 'index.php' : JUri::root().'index.php'; if (FOFPlatform::getInstance()->isFrontend() && ($input->getCmd('Itemid', 0) != 0)) { $itemid = $input->getCmd('Itemid', 0); $uri = new JUri($actionUrl); if ($itemid) { $uri->setVar('Itemid', $itemid); } $actionUrl = JRoute::_($uri->toString()); } $html .= '<form action="'.$actionUrl.'" method="post" name="' . $formname . '" id="' . $formid . '"' . $enctype . ' class="' . $class . '">' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="option" value="' . $input->getCmd('option') . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="view" value="' . $input->getCmd('view', 'edit') . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="task" value="' . $customTask . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="' . $key . '" value="' . $keyValue . '" />' . PHP_EOL; $html .= "\t" . '<input type="hidden" name="' . JFactory::getSession()->getFormToken() . '" value="1" />' . PHP_EOL; $html .= $this->renderFormRaw($form, $model, $input, 'edit'); $html .= '</form>'; return $html; } /** * Renders a raw FOFForm and returns the corresponding HTML * * @param FOFForm &$form The form to render * @param FOFModel $model The model providing our data * @param FOFInput $input The input object * @param string $formType The form type e.g. 'edit' or 'read' * * @return string The HTML rendering of the form */ protected function renderFormRaw(FOFForm &$form, FOFModel $model, FOFInput $input, $formType) { $html = ''; foreach ($form->getFieldsets() as $fieldset) { $html .= $this->renderFieldset($fieldset, $form, $model, $input, $formType, false); } return $html; } /** * Renders a raw fieldset of a FOFForm and returns the corresponding HTML * * @param stdClass &$fieldset The fieldset to render * @param FOFForm &$form The form to render * @param FOFModel $model The model providing our data * @param FOFInput $input The input object * @param string $formType The form type e.g. 'edit' or 'read' * @param boolean $showHeader Should I render the fieldset's header? * * @return string The HTML rendering of the fieldset */ protected function renderFieldset(stdClass &$fieldset, FOFForm &$form, FOFModel $model, FOFInput $input, $formType, $showHeader = true) { $html = ''; $fields = $form->getFieldset($fieldset->name); if (isset($fieldset->class)) { $class = 'class="' . $fieldset->class . '"'; } else { $class = ''; } $element = empty($fields) ? 'div' : 'fieldset'; $html .= "\t" . '<' . $element . ' id="' . $fieldset->name . '" ' . $class . '>' . PHP_EOL; $isTabbedFieldset = $this->isTabFieldset($fieldset); if (isset($fieldset->label) && !empty($fieldset->label) && !$isTabbedFieldset) { $html .= "\t\t" . '<h3>' . JText::_($fieldset->label) . '</h3>' . PHP_EOL; } foreach ($fields as $field) { $groupClass = $form->getFieldAttribute($field->fieldname, 'groupclass', '', $field->group); // Auto-generate label and description if needed // Field label $title = $form->getFieldAttribute($field->fieldname, 'label', '', $field->group); $emptylabel = $form->getFieldAttribute($field->fieldname, 'emptylabel', false, $field->group); if (empty($title) && !$emptylabel) { $model->getName(); $title = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_LABEL'); } // Field description $description = $form->getFieldAttribute($field->fieldname, 'description', '', $field->group); /** * The following code is backwards incompatible. Most forms don't require a description in their form * fields. Having to use emptydescription="1" on each one of them is an overkill. Removed. */ /* $emptydescription = $form->getFieldAttribute($field->fieldname, 'emptydescription', false, $field->group); if (empty($description) && !$emptydescription) { $description = strtoupper($input->get('option') . '_' . $model->getName() . '_' . $field->id . '_DESC'); } */ if ($formType == 'read') { $inputField = $field->static; } elseif ($formType == 'edit') { $inputField = $field->input; } if (empty($title)) { $html .= "\t\t\t" . $inputField . PHP_EOL; if (!empty($description) && $formType == 'edit') { $html .= "\t\t\t\t" . '<span class="help-block">'; $html .= JText::_($description) . '</span>' . PHP_EOL; } } else { $html .= "\t\t\t" . '<div class="fof-row ' . $groupClass . '">' . PHP_EOL; $html .= $this->renderFieldsetLabel($field, $form, $title); $html .= "\t\t\t\t" . $inputField . PHP_EOL; if (!empty($description)) { $html .= "\t\t\t\t" . '<span class="help-block">'; $html .= JText::_($description) . '</span>' . PHP_EOL; } $html .= "\t\t\t" . '</div>' . PHP_EOL; } } $element = empty($fields) ? 'div' : 'fieldset'; $html .= "\t" . '</' . $element . '>' . PHP_EOL; return $html; } /** * Renders a label for a fieldset. * * @param object $field The field of the label to render * @param FOFForm &$form The form to render * @param string $title The title of the label * * @return string The rendered label */ protected function renderFieldsetLabel($field, FOFForm &$form, $title) { $html = ''; $labelClass = $field->labelClass ? $field->labelClass : $field->labelclass; // Joomla! 2.5/3.x use different case for the same name $required = $field->required; if ($required) { $labelClass .= ' required'; } $tooltip = $form->getFieldAttribute($field->fieldname, 'tooltip', '', $field->group); if (!empty($tooltip)) { JHtml::_('behavior.tooltip'); $tooltipText = JText::_($title) . '::' . JText::_($tooltip); $labelClass .= ' hasTip'; $html .= "\t\t\t\t" . '<label id="' . $field->id . '-lbl" class="' . $labelClass . '" for="' . $field->id . '" title="' . $tooltipText . '" rel="tooltip">'; } else { $html .= "\t\t\t\t" . '<label class="' . $labelClass . '" for="' . $field->id . '">'; } $html .= JText::_($title); if ($required) { $html .= '<span class="star"> *</span>'; } $html .= "\t\t\t\t" . '</label>' . PHP_EOL; return $html; } /** * Loads the validation script for an edit form * * @param FOFForm &$form The form we are rendering * * @return void */ protected function loadValidationScript(FOFForm &$form) { $message = $form->getView()->escape(JText::_('JGLOBAL_VALIDATION_FORM_FAILED')); $js = <<<JS Joomla.submitbutton = function(task) { if (task == 'cancel' || document.formvalidator.isValid(document.id('adminForm'))) { Joomla.submitform(task, document.getElementById('adminForm')); } else { alert('$message'); } }; JS; $document = FOFPlatform::getInstance()->getDocument(); if ($document instanceof JDocument) { $document->addScriptDeclaration($js); } } /** * Renders the submenu (link bar) * * @param string $view The active view name * @param string $task The current task * @param FOFInput $input The input object * @param array $config Extra configuration variables for the toolbar * * @return void */ protected function renderLinkbar($view, $task, $input, $config = array()) { // On command line don't do anything if (FOFPlatform::getInstance()->isCli()) { return; } // Do not render a submenu unless we are in the the admin area $toolbar = FOFToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config); $renderFrontendSubmenu = $toolbar->getRenderFrontendSubmenu(); if (!FOFPlatform::getInstance()->isBackend() && !$renderFrontendSubmenu) { return; } $this->renderLinkbarItems($toolbar); } /** * do the rendering job for the linkbar * * @param FOFToolbar $toolbar A toolbar object * * @return void */ protected function renderLinkbarItems($toolbar) { $links = $toolbar->getLinks(); if (!empty($links)) { foreach ($links as $link) { JSubMenuHelper::addEntry($link['name'], $link['link'], $link['active']); } } } /** * Renders the toolbar buttons * * @param string $view The active view name * @param string $task The current task * @param FOFInput $input The input object * @param array $config Extra configuration variables for the toolbar * * @return void */ protected function renderButtons($view, $task, $input, $config = array()) { // On command line don't do anything if (FOFPlatform::getInstance()->isCli()) { return; } // Do not render buttons unless we are in the the frontend area and we are asked to do so $toolbar = FOFToolbar::getAnInstance($input->getCmd('option', 'com_foobar'), $config); $renderFrontendButtons = $toolbar->getRenderFrontendButtons(); if (FOFPlatform::getInstance()->isBackend() || !$renderFrontendButtons) { return; } // Load main backend language, in order to display toolbar strings // (JTOOLBAR_BACK, JTOOLBAR_PUBLISH etc etc) FOFPlatform::getInstance()->loadTranslations('joomla'); $title = JFactory::getApplication()->get('JComponentTitle'); $bar = JToolbar::getInstance('toolbar'); // Delete faux links, since if SEF is on, Joomla will follow the link instead of submitting the form $bar_content = str_replace('href="#"', '', $bar->render()); echo '<div id="FOFHeaderHolder">', $bar_content, $title, '<div style="clear:both"></div>', '</div>'; } }
| ver. 1.4 |
Github
|
.
| PHP 8.1.34 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка