From cc4c11a0fe647b84c390db03668a5ea4dd42c23a Mon Sep 17 00:00:00 2001 From: Pavel Kulbakin Date: Sat, 28 Dec 2013 22:36:54 +0200 Subject: [PATCH] fix: strict notifications [...] since legacy joomla seems not going away soon, update it so strict warnings are not issued by php 5 --- src/administrator/includes/toolbar.php | 964 +++++----- src/libraries/anahita/domain/query/helper.php | 4 +- src/libraries/anahita/domain/query/query.php | 4 +- .../anahita/service/locator/repository.php | 64 +- .../com_application/application.php | 2 +- .../components/com_cache/admin.cache.html.php | 240 ++- .../components/com_cache/admin.cache.php | 158 +- .../com_cache/toolbar.cache.html.php | 55 +- .../com_config/toolbar.config.html.php | 39 +- .../com_config/views/application/view.php | 213 +-- .../com_cpanel/admin.cpanel.html.php | 65 +- .../com_cpanel/toolbar.cpanel.html.php | 34 +- .../com_languages/admin.languages.html.php | 285 ++- .../com_languages/admin.languages.php | 2 +- .../com_languages/toolbar.languages.html.php | 33 +- .../components/com_menus/classes/ilink.php | 2 +- .../components/com_menus/controller.php | 1 + .../components/com_menus/helpers/helper.php | 336 ++-- .../components/com_menus/models/list.php | 2 +- .../components/com_menus/models/menutype.php | 529 +++--- .../com_modules/admin.modules.html.php | 1208 ++++++------ .../components/com_modules/controller.php | 2 +- .../com_modules/toolbar.modules.html.php | 127 +- .../components/com_plugins/controller.php | 4 +- .../com_plugins/views/plugin/tmpl/form.php | 1 + .../com_plugins/views/plugin/view.html.php | 2 +- .../components/com_templates/controller.php | 4 +- .../com_templates/toolbar.templates.html.php | 133 +- .../components/com_users/controller.php | 8 +- .../administrator/language/en-GB/en-GB.ini | 3 - .../joomla/application/application.php | 5 +- .../application/component/controller.php | 2 +- .../joomla/application/component/model.php | 659 ++++--- .../libraries/joomla/application/helper.php | 620 +++---- .../libraries/joomla/application/menu.php | 531 +++--- .../joomla/libraries/joomla/cache/cache.php | 591 +++--- .../joomla/cache/handler/callback.php | 230 ++- .../libraries/joomla/cache/handler/output.php | 121 +- .../libraries/joomla/cache/handler/page.php | 238 ++- .../libraries/joomla/cache/handler/view.php | 258 ++- .../joomla/libraries/joomla/cache/storage.php | 309 ++-- .../libraries/joomla/cache/storage/apc.php | 276 ++- .../joomla/cache/storage/eaccelerator.php | 309 ++-- .../libraries/joomla/cache/storage/file.php | 490 +++-- .../joomla/cache/storage/memcache.php | 398 ++-- .../libraries/joomla/cache/storage/xcache.php | 249 ++- .../joomla/libraries/joomla/client/helper.php | 438 +++-- .../libraries/joomla/database/table.php | 1618 ++++++++--------- .../joomla/database/table/menutypes.php | 2 +- .../libraries/joomla/document/document.php | 3 +- .../libraries/joomla/document/error/error.php | 2 +- .../libraries/joomla/document/html/html.php | 6 +- .../libraries/joomla/environment/response.php | 506 +++--- .../libraries/joomla/environment/uri.php | 1553 ++++++++-------- .../joomla/libraries/joomla/error/error.php | 44 +- .../libraries/joomla/filesystem/file.php | 746 ++++---- .../libraries/joomla/filesystem/folder.php | 1099 ++++++----- .../libraries/joomla/filesystem/path.php | 473 +++-- .../libraries/joomla/filter/filterinput.php | 984 +++++----- .../libraries/joomla/filter/filteroutput.php | 261 ++- .../joomla/libraries/joomla/html/editor.php | 603 +++--- vendor/joomla/libraries/joomla/html/html.php | 618 +++---- .../libraries/joomla/html/html/behavior.php | 730 ++++---- .../libraries/joomla/html/html/form.php | 50 +- .../libraries/joomla/html/html/grid.php | 303 ++- .../libraries/joomla/html/html/image.php | 272 ++- .../libraries/joomla/html/html/list.php | 436 +++-- .../libraries/joomla/html/html/menu.php | 267 ++- .../libraries/joomla/html/html/select.php | 510 +++--- vendor/joomla/libraries/joomla/html/pane.php | 529 +++--- .../libraries/joomla/html/parameter.php | 2 +- .../joomla/libraries/joomla/html/toolbar.php | 480 +++-- .../joomla/html/toolbar/button/link.php | 2 +- .../libraries/joomla/language/helper.php | 152 +- .../libraries/joomla/language/language.php | 16 +- .../libraries/joomla/registry/format.php | 142 +- .../libraries/joomla/registry/format/ini.php | 480 +++-- .../libraries/joomla/session/session.php | 1393 +++++++------- .../libraries/joomla/session/storage.php | 347 ++-- .../libraries/joomla/session/storage/apc.php | 230 ++- .../joomla/session/storage/database.php | 257 ++- .../joomla/session/storage/eaccelerator.php | 233 ++- .../joomla/session/storage/memcache.php | 381 ++-- .../libraries/joomla/session/storage/none.php | 49 +- .../joomla/session/storage/xcache.php | 242 ++- .../joomla/libraries/joomla/user/helper.php | 719 ++++---- vendor/joomla/libraries/joomla/user/user.php | 1172 ++++++------ .../joomla/utilities/arrayhelper.php | 518 +++--- .../libraries/joomla/utilities/string.php | 785 ++++---- .../elements/colorchooser.php | 2 +- .../elements/logoupload.php | 10 +- .../elements/updatecheck.php | 11 +- .../html/com_menus/item/form.php | 4 +- vendor/mc/rt_missioncontrol_j15/index.php | 2 +- .../lib/missioncontrol.class.php | 456 +++-- .../lib/rtmcupdater.class.php | 25 +- .../lib/toolbar/button/link.php | 2 +- .../libraries/installer/adapters/module.php | 2 +- .../libraries/installer/adapters/template.php | 2 +- vendor/mc/rt_missioncontrol_j15/login.php | 2 +- 100 files changed, 14350 insertions(+), 15631 deletions(-) diff --git a/src/administrator/includes/toolbar.php b/src/administrator/includes/toolbar.php index 16faa20fc..a2f662b11 100644 --- a/src/administrator/includes/toolbar.php +++ b/src/administrator/includes/toolbar.php @@ -1,493 +1,509 @@ \n"; - $html .= "$title\n"; - $html .= "\n"; - - $mainframe->set('JComponentTitle', $html); - } - - /** - * Writes a spacer cell - * @param string The width for the cell - * @since 1.0 - */ - function spacer($width = '') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a spacer - $bar->appendButton( 'Separator', 'spacer', $width ); - } - - /** - * Write a divider between menu buttons - * @since 1.0 - */ - function divider() - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a divider - $bar->appendButton( 'Separator', 'divider' ); - } - - /** - * Writes a custom option and task button for the button bar - * @param string The task to perform (picked up by the switch($task) blocks - * @param string The image to display - * @param string The image to display when moused over - * @param string The alt text for the icon image - * @param boolean True if required to check that a standard list item is checked - * @param boolean True if required to include callinh hideMainMenu() - * @since 1.0 - */ - function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true, $x = false) - { - $bar = & JToolBar::getInstance('toolbar'); - - //strip extension - $icon = preg_replace('#\.[^.]*$#', '', $icon); - - // Add a standard button - $bar->appendButton( 'Standard', $icon, $alt, $task, $listSelect, $x ); - } - - /** - * Writes a custom option and task button for the button bar. - * Extended version of custom() calling hideMainMenu() before submitbutton(). - * @param string The task to perform (picked up by the switch($task) blocks - * @param string The image to display - * @param string The image to display when moused over - * @param string The alt text for the icon image - * @param boolean True if required to check that a standard list item is checked - * @since 1.0 - * (NOTE this is being deprecated) - */ - function customX($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true) - { - $bar = & JToolBar::getInstance('toolbar'); - - //strip extension - $icon = preg_replace('#\.[^.]*$#', '', $icon); - - // Add a standard button - $bar->appendButton( 'Standard', $icon, $alt, $task, $listSelect, true ); - } - - /** - * Writes a preview button for a given option (opens a popup window) - * @param string The name of the popup file (excluding the file extension) - * @since 1.0 - */ - function preview($url = '', $updateEditors = false) - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a preview button - $bar->appendButton( 'Popup', 'preview', 'Preview', "$url&task=preview" ); - } - - /** - * Writes a preview button for a given option (opens a popup window) - * @param string The name of the popup file (excluding the file extension for an xml file) - * @param boolean Use the help file in the component directory - * @since 1.0 - */ - function help($ref, $com = false) - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a help button - $bar->appendButton( 'Help', $ref, $com ); - } - - /** - * Writes a cancel button that will go back to the previous page without doing - * any other operation - * @since 1.0 - */ - function back($alt = 'Back', $href = 'javascript:history.back();') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a back button - $bar->appendButton( 'Link', 'back', $alt, $href ); - } - - /** - * Writes the common 'new' icon for the button bar - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function addNew($task = 'add', $alt = 'New') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a new button - $bar->appendButton( 'Standard', 'new', $alt, $task, false, false ); - } - - /** - * Writes the common 'new' icon for the button bar. - * Extended version of addNew() calling hideMainMenu() before submitbutton(). - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function addNewX($task = 'add', $alt = 'New') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a new button (hide menu) - $bar->appendButton( 'Standard', 'new', $alt, $task, false, true ); - } - - /** - * Writes a common 'publish' button - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function publish($task = 'publish', $alt = 'Publish') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a publish button - //$bar->appendButton( 'Publish', false, $alt, $task ); - $bar->appendButton( 'Standard', 'publish', $alt, $task, false, false ); - } - - /** - * Writes a common 'publish' button for a list of records - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function publishList($task = 'publish', $alt = 'Publish') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a publish button (list) - $bar->appendButton( 'Standard', 'publish', $alt, $task, true, false ); - } - - /** - * Writes a common 'default' button for a record - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function makeDefault($task = 'default', $alt = 'Default') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a default button - $bar->appendButton( 'Standard', 'default', $alt, $task, true, false ); - } - - /** - * Writes a common 'assign' button for a record - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function assign($task = 'assign', $alt = 'Assign') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an assign button - $bar->appendButton( 'Standard', 'assign', $alt, $task, true, false ); - } - - /** - * Writes a common 'unpublish' button - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function unpublish($task = 'unpublish', $alt = 'Unpublish') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an unpublish button - $bar->appendButton( 'Standard', 'unpublish', $alt, $task, false, false ); - } - - /** - * Writes a common 'unpublish' button for a list of records - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function unpublishList($task = 'unpublish', $alt = 'Unpublish') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an unpublish button (list) - - $bar->appendButton( 'Standard', 'unpublish', $alt, $task, true, false ); - } - - /** - * Writes a common 'archive' button for a list of records - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function archiveList($task = 'archive', $alt = 'Archive') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an archive button - $bar->appendButton( 'Standard', 'archive', $alt, $task, true, false ); - } - - /** - * Writes an unarchive button for a list of records - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function unarchiveList($task = 'unarchive', $alt = 'Unarchive') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an unarchive button (list) - $bar->appendButton( 'Standard', 'unarchive', $alt, $task, true, false ); - } - - /** - * Writes a common 'edit' button for a list of records - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function editList($task = 'edit', $alt = 'Edit') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an edit button - $bar->appendButton( 'Standard', 'edit', $alt, $task, true, false ); - } - - /** - * Writes a common 'edit' button for a list of records. - * Extended version of editList() calling hideMainMenu() before submitbutton(). - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function editListX($task = 'edit', $alt = 'Edit') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an edit button (hide) - $bar->appendButton( 'Standard', 'edit', $alt, $task, true, true ); - } - - /** - * Writes a common 'edit' button for a template html - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function editHtml($task = 'edit_source', $alt = 'Edit HTML') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an edit html button - $bar->appendButton( 'Standard', 'edithtml', $alt, $task, true, false ); - } - - /** - * Writes a common 'edit' button for a template html. - * Extended version of editHtml() calling hideMainMenu() before submitbutton(). - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function editHtmlX($task = 'edit_source', $alt = 'Edit HTML') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an edit html button (hide) - $bar->appendButton( 'Standard', 'edithtml', $alt, $task, true, true ); - } - - /** - * Writes a common 'edit' button for a template css - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function editCss($task = 'edit_css', $alt = 'Edit CSS') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an edit css button (hide) - $bar->appendButton( 'Standard', 'editcss', $alt, $task, true, false ); - } - - /** - * Writes a common 'edit' button for a template css. - * Extended version of editCss() calling hideMainMenu() before submitbutton(). - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function editCssX($task = 'edit_css', $alt = 'Edit CSS') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an edit css button (hide) - $bar->appendButton( 'Standard', 'editcss', $alt, $task, true, true ); - } - - /** - * Writes a common 'delete' button for a list of records - * @param string Postscript for the 'are you sure' message - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function deleteList($msg = '', $task = 'remove', $alt = 'Delete') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a delete button - if ($msg) { - $bar->appendButton( 'Confirm', $msg, 'delete', $alt, $task, true, false ); - } else { - $bar->appendButton( 'Standard', 'delete', $alt, $task, true, false ); - } - } - - /** - * Writes a common 'delete' button for a list of records. - * Extended version of deleteList() calling hideMainMenu() before submitbutton(). - * @param string Postscript for the 'are you sure' message - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function deleteListX($msg = '', $task = 'remove', $alt = 'Delete') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a delete button (hide) - if ($msg) { - $bar->appendButton( 'Confirm', $msg, 'delete', $alt, $task, true, true ); - } else { - $bar->appendButton( 'Standard', 'delete', $alt, $task, true, true ); - } - } - - /** - * Write a trash button that will move items to Trash Manager - * @since 1.0 - */ - function trash($task = 'remove', $alt = 'Trash', $check = true) - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a trash button - $bar->appendButton( 'Standard', 'trash', $alt, $task, $check, false ); - } - - /** - * Writes a save button for a given option - * Apply operation leads to a save action only (does not leave edit mode) - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function apply($task = 'apply', $alt = 'Apply') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add an apply button - $bar->appendButton( 'Standard', 'apply', $alt, $task, false, false ); - } - - /** - * Writes a save button for a given option - * Save operation leads to a save and then close action - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function save($task = 'save', $alt = 'Save') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a save button - $bar->appendButton( 'Standard', 'save', $alt, $task, false, false ); - } - - /** - * Writes a cancel button and invokes a cancel operation (eg a checkin) - * @param string An override for the task - * @param string An override for the alt text - * @since 1.0 - */ - function cancel($task = 'cancel', $alt = 'Cancel') - { - $bar = & JToolBar::getInstance('toolbar'); - // Add a cancel button - $bar->appendButton( 'Standard', 'cancel', $alt, $task, false, false ); - } - - /** - * Writes a configuration button and invokes a cancel operation (eg a checkin) - * @param string The name of the component, eg, com_content - * @param int The height of the popup - * @param int The width of the popup - * @param string The name of the button - * @param string An alternative path for the configuation xml relative to JPATH_SITE - * @since 1.0 - */ - function preferences($component, $height='150', $width='570', $alt = 'Preferences', $path = '') - { - $user =& JFactory::getUser(); - if ($user->get('gid') != 25) { - return; - } - - $component = urlencode( $component ); - $path = urlencode( $path ); - $bar = & JToolBar::getInstance('toolbar'); - // Add a configuration button - $bar->appendButton( 'Popup', 'config', $alt, 'index.php?option=com_config&controller=component&component='.$component.'&path='.$path, $width, $height ); - } + /** + * Title cell + * For the title and toolbar to be rendered correctly, + * this title fucntion must be called before the starttable function and the toolbars icons + * this is due to the nature of how the css has been used to postion the title in respect to the toolbar + * + * @param string The title + * @param string The name of the image + * @since 1.5 + */ + public static function title($title, $icon = 'generic.png') + { + global $mainframe; + + //strip the extension + $icon = preg_replace('#\.[^.]*$#', '', $icon); + $html = "
\n"; + $html .= "$title\n"; + $html .= "
\n"; + + $mainframe->set('JComponentTitle', $html); + } + + /** + * Writes a spacer cell + * + * @param string The width for the cell + * @since 1.0 + */ + public static function spacer($width = '') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a spacer + $bar->appendButton( 'Separator', 'spacer', $width ); + } + + /** + * Write a divider between menu buttons + * @since 1.0 + */ + public static function divider() + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a divider + $bar->appendButton('Separator', 'divider'); + } + + /** + * Writes a custom option and task button for the button bar + * + * @param string The task to perform (picked up by the switch($task) blocks + * @param string The image to display + * @param string The image to display when moused over + * @param string The alt text for the icon image + * @param boolean True if required to check that a standard list item is checked + * @param boolean True if required to include callinh hideMainMenu() + * @since 1.0 + */ + public static function custom($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true, $x = false) + { + $bar =& JToolBar::getInstance('toolbar'); + + //strip extension + $icon = preg_replace('#\.[^.]*$#', '', $icon); + + // Add a standard button + $bar->appendButton('Standard', $icon, $alt, $task, $listSelect, $x); + } + + /** + * Writes a custom option and task button for the button bar. + * Extended version of custom() calling hideMainMenu() before submitbutton(). + * + * @param string The task to perform (picked up by the switch($task) blocks + * @param string The image to display + * @param string The image to display when moused over + * @param string The alt text for the icon image + * @param boolean True if required to check that a standard list item is checked + * @since 1.0 + * (NOTE this is being deprecated) + */ + public static function customX($task = '', $icon = '', $iconOver = '', $alt = '', $listSelect = true) + { + $bar =& JToolBar::getInstance('toolbar'); + + //strip extension + $icon = preg_replace('#\.[^.]*$#', '', $icon); + + // Add a standard button + $bar->appendButton('Standard', $icon, $alt, $task, $listSelect, true); + } + + /** + * Writes a preview button for a given option (opens a popup window) + * + * @param string The name of the popup file (excluding the file extension) + * @since 1.0 + */ + public static function preview($url = '', $updateEditors = false) + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a preview button + $bar->appendButton('Popup', 'preview', 'Preview', "$url&task=preview"); + } + + /** + * Writes a preview button for a given option (opens a popup window) + * + * @param string The name of the popup file (excluding the file extension for an xml file) + * @param boolean Use the help file in the component directory + * @since 1.0 + */ + public static function help($ref, $com = false) + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a help button + $bar->appendButton('Help', $ref, $com); + } + + /** + * Writes a cancel button that will go back to the previous page without doing + * any other operation + * + * @since 1.0 + */ + public static function back($alt = 'Back', $href = 'javascript:history.back();') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a back button + $bar->appendButton('Link', 'back', $alt, $href); + } + + /** + * Writes the common 'new' icon for the button bar + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function addNew($task = 'add', $alt = 'New') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a new button + $bar->appendButton('Standard', 'new', $alt, $task, false, false); + } + + /** + * Writes the common 'new' icon for the button bar. + * Extended version of addNew() calling hideMainMenu() before submitbutton(). + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function addNewX($task = 'add', $alt = 'New') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a new button (hide menu) + $bar->appendButton('Standard', 'new', $alt, $task, false, true); + } + + /** + * Writes a common 'publish' button + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function publish($task = 'publish', $alt = 'Publish') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a publish button + //$bar->appendButton( 'Publish', false, $alt, $task ); + $bar->appendButton('Standard', 'publish', $alt, $task, false, false); + } + + /** + * Writes a common 'publish' button for a list of records + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function publishList($task = 'publish', $alt = 'Publish') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a publish button (list) + $bar->appendButton('Standard', 'publish', $alt, $task, true, false); + } + + /** + * Writes a common 'default' button for a record + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function makeDefault($task = 'default', $alt = 'Default') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a default button + $bar->appendButton('Standard', 'default', $alt, $task, true, false); + } + + /** + * Writes a common 'assign' button for a record + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function assign($task = 'assign', $alt = 'Assign') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an assign button + $bar->appendButton('Standard', 'assign', $alt, $task, true, false); + } + + /** + * Writes a common 'unpublish' button + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function unpublish($task = 'unpublish', $alt = 'Unpublish') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an unpublish button + $bar->appendButton('Standard', 'unpublish', $alt, $task, false, false); + } + + /** + * Writes a common 'unpublish' button for a list of records + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function unpublishList($task = 'unpublish', $alt = 'Unpublish') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an unpublish button (list) + $bar->appendButton('Standard', 'unpublish', $alt, $task, true, false); + } + + /** + * Writes a common 'archive' button for a list of records + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function archiveList($task = 'archive', $alt = 'Archive') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an archive button + $bar->appendButton('Standard', 'archive', $alt, $task, true, false); + } + + /** + * Writes an unarchive button for a list of records + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function unarchiveList($task = 'unarchive', $alt = 'Unarchive') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an unarchive button (list) + $bar->appendButton('Standard', 'unarchive', $alt, $task, true, false); + } + + /** + * Writes a common 'edit' button for a list of records + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function editList($task = 'edit', $alt = 'Edit') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an edit button + $bar->appendButton('Standard', 'edit', $alt, $task, true, false); + } + + /** + * Writes a common 'edit' button for a list of records. + * Extended version of editList() calling hideMainMenu() before submitbutton(). + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function editListX($task = 'edit', $alt = 'Edit') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an edit button (hide) + $bar->appendButton('Standard', 'edit', $alt, $task, true, true); + } + + /** + * Writes a common 'edit' button for a template html + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function editHtml($task = 'edit_source', $alt = 'Edit HTML') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an edit html button + $bar->appendButton('Standard', 'edithtml', $alt, $task, true, false); + } + + /** + * Writes a common 'edit' button for a template html. + * Extended version of editHtml() calling hideMainMenu() before submitbutton(). + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function editHtmlX($task = 'edit_source', $alt = 'Edit HTML') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an edit html button (hide) + $bar->appendButton('Standard', 'edithtml', $alt, $task, true, true); + } + + /** + * Writes a common 'edit' button for a template css + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function editCss($task = 'edit_css', $alt = 'Edit CSS') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an edit css button (hide) + $bar->appendButton('Standard', 'editcss', $alt, $task, true, false); + } + + /** + * Writes a common 'edit' button for a template css. + * Extended version of editCss() calling hideMainMenu() before submitbutton(). + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function editCssX($task = 'edit_css', $alt = 'Edit CSS') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an edit css button (hide) + $bar->appendButton('Standard', 'editcss', $alt, $task, true, true); + } + + /** + * Writes a common 'delete' button for a list of records + * + * @param string Postscript for the 'are you sure' message + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function deleteList($msg = '', $task = 'remove', $alt = 'Delete') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a delete button + if ($msg) { + $bar->appendButton('Confirm', $msg, 'delete', $alt, $task, true, false); + } else { + $bar->appendButton('Standard', 'delete', $alt, $task, true, false); + } + } + + /** + * Writes a common 'delete' button for a list of records. + * Extended version of deleteList() calling hideMainMenu() before submitbutton(). + * + * @param string Postscript for the 'are you sure' message + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function deleteListX($msg = '', $task = 'remove', $alt = 'Delete') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a delete button (hide) + if ($msg) { + $bar->appendButton('Confirm', $msg, 'delete', $alt, $task, true, true); + } else { + $bar->appendButton('Standard', 'delete', $alt, $task, true, true); + } + } + + /** + * Write a trash button that will move items to Trash Manager + * + * @since 1.0 + */ + public static function trash($task = 'remove', $alt = 'Trash', $check = true) + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a trash button + $bar->appendButton('Standard', 'trash', $alt, $task, $check, false); + } + + /** + * Writes a save button for a given option + * + * Apply operation leads to a save action only (does not leave edit mode) + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function apply($task = 'apply', $alt = 'Apply') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add an apply button + $bar->appendButton('Standard', 'apply', $alt, $task, false, false); + } + + /** + * Writes a save button for a given option + * + * Save operation leads to a save and then close action + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function save($task = 'save', $alt = 'Save') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a save button + $bar->appendButton('Standard', 'save', $alt, $task, false, false); + } + + /** + * Writes a cancel button and invokes a cancel operation (eg a checkin) + * + * @param string An override for the task + * @param string An override for the alt text + * @since 1.0 + */ + public static function cancel($task = 'cancel', $alt = 'Cancel') + { + $bar =& JToolBar::getInstance('toolbar'); + // Add a cancel button + $bar->appendButton('Standard', 'cancel', $alt, $task, false, false); + } + + /** + * Writes a configuration button and invokes a cancel operation (eg a checkin) + * + * @param string The name of the component, eg, com_content + * @param int The height of the popup + * @param int The width of the popup + * @param string The name of the button + * @param string An alternative path for the configuation xml relative to JPATH_SITE + * @since 1.0 + */ + public static function preferences($component, $height='150', $width='570', $alt = 'Preferences', $path = '') + { + $user =& JFactory::getUser(); + if ($user->get('gid') != 25) { + return; + } + + $component = urlencode($component); + $path = urlencode($path); + $bar =& JToolBar::getInstance('toolbar'); + // Add a configuration button + $bar->appendButton('Popup', 'config', $alt, 'index.php?option=com_config&controller=component&component='.$component.'&path='.$path, $width, $height); + } } /** * Utility class for the submenu -* -* @package Joomla +* +* @package Joomla */ class JSubMenuHelper { - function addEntry($name, $link = '', $active = false) - { - $menu = &JToolBar::getInstance('submenu'); - $menu->appendButton($name, $link, $active); - } + public static function addEntry($name, $link = '', $active = false) + { + $menu = &JToolBar::getInstance('submenu'); + $menu->appendButton($name, $link, $active); + } } -?> diff --git a/src/libraries/anahita/domain/query/helper.php b/src/libraries/anahita/domain/query/helper.php index a8e7b02e6..352030f04 100644 --- a/src/libraries/anahita/domain/query/helper.php +++ b/src/libraries/anahita/domain/query/helper.php @@ -1,5 +1,4 @@ getParent()) { throw new AnDomainQueryException('Query Building Failed. Unkown Parent'); } elseif ($child_belongs_to_property->isPolymorphic()) { - $columns = array(array_shift(array_keys($columns)) => array_shift(array_values($columns))); + list($k) = array_keys($columns); + $columns = array($k => $columns[$k]); } $condition = array(); diff --git a/src/libraries/anahita/domain/query/query.php b/src/libraries/anahita/domain/query/query.php index e3ad8705c..829284c88 100644 --- a/src/libraries/anahita/domain/query/query.php +++ b/src/libraries/anahita/domain/query/query.php @@ -474,8 +474,8 @@ public function getKey() $key = false; if (count($this->where) == 1) { - $where = array_pop(array_values($this->where)); - if ( isset($where['property']) ) { + list($where) = array_values($this->where); + if (isset($where['property'])) { $property = $where['property']; $keys = $this->getRepository()->getDescription()->getIdentifyingProperties(); if (isset($keys[$property]) && isset($where['constraint']) && $where['constraint'] == '=' && !is_array($where['value'])) { diff --git a/src/libraries/anahita/service/locator/repository.php b/src/libraries/anahita/service/locator/repository.php index cf331eb3b..de08c4d46 100644 --- a/src/libraries/anahita/service/locator/repository.php +++ b/src/libraries/anahita/service/locator/repository.php @@ -1,19 +1,4 @@ - * @author Rastin Mehr - * @copyright 2008 - 2010 rmdStudio Inc./Peerglobe Technology Inc - * @license GNU GPLv3 - * @version SVN: $Id$ - * @link http://www.anahitapolis.com - */ - /** * Repositroy locator is KService locator to return repository objects of any entities. * @@ -26,77 +11,74 @@ * @author Arash Sanieyan * @author Rastin Mehr * @license GNU GPLv3 - * @link http://www.anahitapolis.com + * @copyright 2008 - 2010 rmdStudio Inc./Peerglobe Technology Inc */ class AnServiceLocatorRepository extends KServiceLocatorAbstract implements KServiceInstantiatable { /** * Return - * - * @param KConfigInterface $config An optional KConfig object with configuration options - * @param KServiceInterface $container A KServiceInterface object - * + * + * @param KConfigInterface $config An optional KConfig object with configuration options + * @param KServiceInterface $container A KServiceInterface object * @return KServiceInstantiatable */ public static function getInstance(KConfigInterface $config, KServiceInterface $container) { - if (!$container->has($config->service_identifier)) - { + if ( ! $container->has($config->service_identifier)) { $identifier = self::_identifier($config->service_identifier); $instance = AnDomain::getRepository($identifier, $config->toArray()); $container->set($config->service_identifier, $instance); } - + return $container->get($config->service_identifier); } - + /** * The type - * + * * @var string */ protected $_type = 'repos'; /** * Get the classname based on an identifier - * - * @param mixed An identifier object - koowa:[path].name + * + * @param mixed An identifier object - koowa:[path].name * @return string|false Return object on success, returns FALSE on failure */ public function findClass(KServiceIdentifier $identifier) - { + { return __CLASS__; - } - + } + /** * Get the path based on an identifier * - * @param object An identifier object - koowa:[path].name - * @return string Returns the path + * @param object An identifier object - koowa:[path].name + * @return string Returns the path */ public function findPath(KServiceIdentifier $identifier) { return self::_identifier($identifier)->filepath; - } - + } + /** * Converts a repos locator identifier repos:[//application/]. to a * component identifier - * - * @param KServiceIdentifier $identifier * + * @param KServiceIdentifier $identifier * @return KServiceIdentifier */ - protected function _identifier(KServiceIdentifier $identifier) + protected static function _identifier(KServiceIdentifier $identifier) { $identifier = clone $identifier; - if ( !$identifier->name ) { + if ( ! $identifier->name ) { $identifier->name = KInflector::singularize($identifier->package); } $identifier->type = 'com'; - $identifier->path = array('domain','entity'); - return $identifier; + $identifier->path = array('domain', 'entity'); + return $identifier; } -} \ No newline at end of file +} diff --git a/src/site/components/com_application/application.php b/src/site/components/com_application/application.php index 668373bad..019981f9a 100644 --- a/src/site/components/com_application/application.php +++ b/src/site/components/com_application/application.php @@ -194,7 +194,7 @@ public function setTemplate( $template ) * * @return JMenu */ - public function &getMenu() + public static function &getMenu() { $options = array(); $menu =& parent::getMenu('site', $options); diff --git a/vendor/joomla/administrator/components/com_cache/admin.cache.html.php b/vendor/joomla/administrator/components/com_cache/admin.cache.html.php index a1c9f850e..11f566231 100644 --- a/vendor/joomla/administrator/components/com_cache/admin.cache.html.php +++ b/vendor/joomla/administrator/components/com_cache/admin.cache.html.php @@ -1,153 +1,145 @@ -
- - - - - - - - - - - - - - - - - - " > - - - - - - - - -
- - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset( $i ); ?> - - - - - group; ?> - - - count; ?> - - size ?> -
- - - - - - -
- + /** + * Displays the cache + * + * @param array An array of records + * @param string The URL option + */ + public static function displayCache(&$rows, &$client, &$page) + { + ?> +
+ + + + + + + + + + + + + + + + + + " > + + + + + + + + +
+ + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + + group; ?> + + + count; ?> + + size ?> +
+ + + + + + +
+
- - - + + + - - + - + +
- -
+ +
-
+
+
-
- +
- +
- - - + + + - - - + + +
- -
+ +
- -
+ +
- +
- authorize( 'com_cache', 'manage' )) { - $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); + $mainframe->redirect( 'index.php', JText::_('ALERTNOTAUTH') ); } // Load the html output class and the model class @@ -36,81 +23,84 @@ */ switch ( JRequest::getVar( 'task' ) ) { - case 'delete': - CacheController::deleteCache($cid); - CacheController::showCache(); - break; - case 'purgeadmin': - CacheController::showPurgeCache(); - break; - case 'purge': - CacheController::purgeCache(); - break; - default : - CacheController::showCache(); - break; + case 'delete': + CacheController::deleteCache($cid); + CacheController::showCache(); + break; + case 'purgeadmin': + CacheController::showPurgeCache(); + break; + case 'purge': + CacheController::purgeCache(); + break; + default : + CacheController::showCache(); + break; } /** * Static class to hold controller functions for the Cache component - * - * @static - * @package Joomla - * @subpackage Weblinks - * @since 1.5 + * + * @package Joomla + * @subpackage Weblinks + * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * @since 1.5 */ class CacheController { - /** - * Show the cache - * - * @since 1.5 - */ - function showCache() - { - global $mainframe, $option; - $submenu = JRequest::getVar('client', '0', '', 'int'); - $client =& JApplicationHelper::getClientInfo($submenu); - if ($submenu == 1) { - JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_cache&client=0'); - JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_cache&client=1', true); - } else { - JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_cache&client=0', true); - JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_cache&client=1'); - } - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit')); - $limitstart = $mainframe->getUserStateFromRequest( $option.'.limitstart', 'limitstart', 0 ); - - $cmData = new CacheData($client->path.DS.'cache'); - - jimport('joomla.html.pagination'); - $pageNav = new JPagination( $cmData->getGroupCount(), $limitstart, $limit ); - - CacheView::displayCache( $cmData->getRows( $limitstart, $limit ), $client, $pageNav ); - } - - function deleteCache($cid) - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - - $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); - - $cmData = new CacheData($client->path.DS.'cache'); - $cmData->cleanCacheList( $cid ); - } - function showPurgeCache() - { - // Check for request forgeries - CacheView::showPurgeExecute(); - } - function purgeCache() - { - // Check for request forgeries - JRequest::checkToken() or jexit( 'Invalid Token' ); - $cache =& JFactory::getCache(''); - $cache->gc(); - CacheView::purgeSuccess(); - } + /** + * Show the cache + * + * @since 1.5 + */ + public static function showCache() + { + global $mainframe, $option; + $submenu = JRequest::getVar('client', '0', '', 'int'); + $client =& JApplicationHelper::getClientInfo($submenu); + if ($submenu == 1) { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_cache&client=0'); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_cache&client=1', true); + } else { + JSubMenuHelper::addEntry(JText::_('Site'), 'index.php?option=com_cache&client=0', true); + JSubMenuHelper::addEntry(JText::_('Administrator'), 'index.php?option=com_cache&client=1'); + } + + $limit = $mainframe->getUserStateFromRequest('global.list.limit', 'limit', $mainframe->getCfg('list_limit')); + $limitstart = $mainframe->getUserStateFromRequest($option.'.limitstart', 'limitstart', 0); + $cmData = new CacheData($client->path.DS.'cache'); + + jimport('joomla.html.pagination'); + $pageNav = new JPagination($cmData->getGroupCount(), $limitstart, $limit); + + $rows = $cmData->getRows($limitstart, $limit); + CacheView::displayCache($rows, $client, $pageNav); + } + + public static function deleteCache($cid) + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + + $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); + + $cmData = new CacheData($client->path.DS.'cache'); + $cmData->cleanCacheList( $cid ); + } + + public static function showPurgeCache() + { + // Check for request forgeries + CacheView::showPurgeExecute(); + } + + public static function purgeCache() + { + // Check for request forgeries + JRequest::checkToken() or jexit( 'Invalid Token' ); + $cache =& JFactory::getCache(''); + $cache->gc(); + CacheView::purgeSuccess(); + } } diff --git a/vendor/joomla/administrator/components/com_cache/toolbar.cache.html.php b/vendor/joomla/administrator/components/com_cache/toolbar.cache.html.php index d45988eaa..d61fa7612 100644 --- a/vendor/joomla/administrator/components/com_cache/toolbar.cache.html.php +++ b/vendor/joomla/administrator/components/com_cache/toolbar.cache.html.php @@ -1,40 +1,29 @@ loadByOption( 'com_users' ); - $userparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_users'.DS.'config.xml' ); - - // Build the component's submenu - $contents = ''; - $tmplpath = dirname(__FILE__).DS.'tmpl'; - ob_start(); - require_once($tmplpath.DS.'navigation.php'); - $contents = ob_get_contents(); - ob_end_clean(); - - // Set document data - $document =& JFactory::getDocument(); - $document->setBuffer($contents, 'modules', 'submenu'); - - // Load settings for the FTP layer - jimport('joomla.client.helper'); - $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); - ?> -
- -
-
- - - - - -
- - - -
-
-
- - - - - -
- -
- - render('userparams'); ?> -
-
- - - -
-
-
- - - - - -
- - - - - - -
-
-
-
- - - - - - - -
- loadByOption( 'com_users' ); + $userparams = new JParameter( $table->params, JPATH_ADMINISTRATOR.DS.'components'.DS.'com_users'.DS.'config.xml' ); + + // Build the component's submenu + $contents = ''; + $tmplpath = dirname(__FILE__).DS.'tmpl'; + ob_start(); + require_once($tmplpath.DS.'navigation.php'); + $contents = ob_get_contents(); + ob_end_clean(); + + // Set document data + $document =& JFactory::getDocument(); + $document->setBuffer($contents, 'modules', 'submenu'); + + // Load settings for the FTP layer + jimport('joomla.client.helper'); + $ftp =& JClientHelper::setCredentialsFromRequest('ftp'); + ?> +
+ +
+
+ + + + + +
+ + + +
+
+
+ + + + + +
+ +
+ + render('userparams'); ?> +
+
+ + + +
+
+
+ + + + + +
+ + + + + + +
+
+
+
+ + + + + + + +
+ true)); - echo $pane->startPane("content-pane"); - - foreach ($modules as $module) { - $title = $module->title ; - echo $pane->startPanel( $title, 'cpanel-panel-'.$module->name ); - echo JModuleHelper::renderModule($module); - echo $pane->endPanel(); - } - - echo $pane->endPane(); - } -} \ No newline at end of file + $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); + echo $pane->startPane("content-pane"); + + foreach ($modules as $module) { + $title = $module->title ; + echo $pane->startPanel($title, 'cpanel-panel-'.$module->name); + echo JModuleHelper::renderModule($module); + echo $pane->endPanel(); + } + + echo $pane->endPane(); + } +} diff --git a/vendor/joomla/administrator/components/com_cpanel/toolbar.cpanel.html.php b/vendor/joomla/administrator/components/com_cpanel/toolbar.cpanel.html.php index e3b203ab4..508d7ac48 100644 --- a/vendor/joomla/administrator/components/com_cpanel/toolbar.cpanel.html.php +++ b/vendor/joomla/administrator/components/com_cpanel/toolbar.cpanel.html.php @@ -1,28 +1,18 @@ -
- - -
- - - - - -

message); ?>

- - - - - - - - - - - - - -
- - - -
- - - -
-
- - - - - - - - - - - - - - - - - - - - - - - "> - - - - - - - - - - - -
- - -   - - - - - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset( $i ); ?> - - - - name;?> - - published == 1) { ?> - <?php echo JText::_( 'Default' ); ?> - -   - - - version; ?> - - creationdate; ?> - - author; ?> - - authorEmail; ?> -
- - - - - - -
- +
+ + +
+ + + + + +

message); ?>

+ + + + + + + + + + + + + +
+ + + +
+ + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + "> + + + + + + + + + + + +
+ + +   + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + name;?> + + published == 1) { ?> + <?php echo JText::_( 'Default' ); ?> + +   + + + version; ?> + + creationdate; ?> + + author; ?> + + authorEmail; ?> +
+ + + + + + +
+ clean(@$cid[0], 'cmd')); $client = JRequest::getVar('client', 0, '', 'int'); if ($client == 1) { diff --git a/vendor/joomla/administrator/components/com_languages/toolbar.languages.html.php b/vendor/joomla/administrator/components/com_languages/toolbar.languages.html.php index 30f7e0834..7188686ee 100644 --- a/vendor/joomla/administrator/components/com_languages/toolbar.languages.html.php +++ b/vendor/joomla/administrator/components/com_languages/toolbar.languages.html.php @@ -1,30 +1,19 @@ _menutype = "&menutype=" . JFilterInput::clean($menutype, 'menutype'); + $this->_menutype = "&menutype=" . JFilterInput::getInstance()->clean($menutype, 'menutype'); } else { $this->_menutype = null; } diff --git a/vendor/joomla/administrator/components/com_menus/controller.php b/vendor/joomla/administrator/components/com_menus/controller.php index e1241438f..055a0dce5 100644 --- a/vendor/joomla/administrator/components/com_menus/controller.php +++ b/vendor/joomla/administrator/components/com_menus/controller.php @@ -574,6 +574,7 @@ function saveMenu() return false; } + $msg = null; if ($isNew) { if ($title = JRequest::getVar( 'module_title', $menuType->menutype, 'post', 'string' )) diff --git a/vendor/joomla/administrator/components/com_menus/helpers/helper.php b/vendor/joomla/administrator/components/com_menus/helpers/helper.php index 42800fead..49d298a98 100644 --- a/vendor/joomla/administrator/components/com_menus/helpers/helper.php +++ b/vendor/joomla/administrator/components/com_menus/helpers/helper.php @@ -1,192 +1,176 @@ setQuery( $query ); - return $db->loadObjectList(); - } - - /** - * Get a list of the menutypes - * @return array An array of menu type names - */ - function getMenuTypes() - { - $db = &JFactory::getDBO(); - $query = 'SELECT menutype' . - ' FROM #__menu_types'; - $db->setQuery( $query ); - return $db->loadResultArray(); - } - - /** - * Gets a list of components that can link to the menu - */ - function getComponentList() - { - $db = &JFactory::getDBO(); - $query = 'SELECT c.id, c.name, c.link, c.option' . - ' FROM #__components AS c' . - ' WHERE c.link <> "" AND parent = 0 AND enabled = 1' . - ' ORDER BY c.name'; - $db->setQuery( $query ); - $components = $db->loadObjectList( ); + /** + * Get a list of the menu_types records + * @return array An array of records as objects + */ + public static function getMenuTypeList() + { + $db = &JFactory::getDBO(); + $query = 'SELECT a.*, SUM(b.home) AS home' . + ' FROM #__menu_types AS a' . + ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' . + ' GROUP BY a.id'; + $db->setQuery( $query ); + return $db->loadObjectList(); + } + + /** + * Get a list of the menutypes + * @return array An array of menu type names + */ + public static function getMenuTypes() + { + $db = &JFactory::getDBO(); + $query = 'SELECT menutype' . + ' FROM #__menu_types'; + $db->setQuery( $query ); + return $db->loadResultArray(); + } + + /** + * Gets a list of components that can link to the menu + */ + public static function getComponentList() + { + $db = &JFactory::getDBO(); + $query = 'SELECT c.id, c.name, c.link, c.option' . + ' FROM #__components AS c' . + ' WHERE c.link <> "" AND parent = 0 AND enabled = 1' . + ' ORDER BY c.name'; + $db->setQuery( $query ); + $components = $db->loadObjectList( ); $result = array(); - foreach($components as $component) - { + foreach ($components as $component) { $path = JPATH_SITE.DS.'components'.DS.$component->option; - if ( !file_exists($path) ) - continue; + if ( ! file_exists($path)) + continue; $path = $path.DS.'views'; - if ( !file_exists($path) ) - continue; + if ( ! file_exists($path)) + continue; $path = $path.DS.'metadata.xml'; - if ( is_readable($path) ) { + if (is_readable($path)) { $data = file_get_contents($path); - if ( preg_match('/hidden="true"/', $data) ) { - continue; + if (preg_match('/hidden="true"/', $data)) { + continue; } } - $result[] = $component; + $result[] = $component; } + return $result; + } + + /** + * Build the select list for parent menu item + */ + public static function Parent(&$row) + { + $db =& JFactory::getDBO(); + + // If a not a new item, lets set the menu item id + if ($row->id) { + $id = ' AND id != '.(int)$row->id; + } else { + $id = null; + } + + // In case the parent was null + if ( ! $row->parent) { + $row->parent = 0; + } + + // get a list of the menu items + // excluding the current menu item and its child elements + $query = 'SELECT m.*' . + ' FROM #__menu m' . + ' WHERE menutype = '.$db->Quote($row->menutype) . + ' AND published != -2' . + $id . + ' ORDER BY parent, ordering'; + $db->setQuery( $query ); + $mitems = $db->loadObjectList(); + + // establish the hierarchy of the menu + $children = array(); + + if ($mitems) { + // first pass - collect children + foreach ($mitems as $v) { + $pt = $v->parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + } + + // second pass - get an indent list of the items + $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0); + + // assemble menu items to the array + $mitems = array(); + $mitems[] = JHTML::_('select.option', '0', JText::_( 'Top' ) ); + + foreach ($list as $item) { + $mitems[] = JHTML::_('select.option', $item->id, '   '. $item->treename ); + } + + $output = JHTML::_('select.genericlist', $mitems, 'parent', 'class="inputbox" size="10"', 'value', 'text', $row->parent ); + + return $output; + } + + /** + * build the select list for target window + */ + public static function Target(&$row) + { + $click[] = JHTML::_('select.option', '0', JText::_('Parent Window With Browser Navigation')); + $click[] = JHTML::_('select.option', '1', JText::_('New Window With Browser Navigation')); + $click[] = JHTML::_('select.option', '2', JText::_('New Window Without Browser Navigation')); + $target = JHTML::_('select.genericlist', $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval($row->browserNav)); + + return $target; + } + + /** + * build the select list for target window + */ + public static function Published(&$row) + { + $put[] = JHTML::_('select.option', '0', JText::_('No')); + $put[] = JHTML::_('select.option', '1', JText::_('Yes')); + + // If not a new item, trash is not an option + if ( !$row->id ) { + $row->published = 1; + } + $published = JHTML::_('select.radiolist', $put, 'published', '', 'value', 'text', $row->published); + return $published; + } + + /** + * clean system cache + */ + public static function cleanCache() + { + global $mainframe; + + if ($mainframe->getCfg('caching')) { + // clean system cache + $cache =& JFactory::getCache('_system'); + $cache->clean(); - - return $result; - } - - /** - * Build the select list for parent menu item - */ - function Parent( &$row ) - { - $db =& JFactory::getDBO(); - - // If a not a new item, lets set the menu item id - if ( $row->id ) { - $id = ' AND id != '.(int) $row->id; - } else { - $id = null; - } - - // In case the parent was null - if (!$row->parent) { - $row->parent = 0; - } - - // get a list of the menu items - // excluding the current menu item and its child elements - $query = 'SELECT m.*' . - ' FROM #__menu m' . - ' WHERE menutype = '.$db->Quote($row->menutype) . - ' AND published != -2' . - $id . - ' ORDER BY parent, ordering'; - $db->setQuery( $query ); - $mitems = $db->loadObjectList(); - - // establish the hierarchy of the menu - $children = array(); - - if ( $mitems ) - { - // first pass - collect children - foreach ( $mitems as $v ) - { - $pt = $v->parent; - $list = @$children[$pt] ? $children[$pt] : array(); - array_push( $list, $v ); - $children[$pt] = $list; - } - } - - // second pass - get an indent list of the items - $list = JHTML::_('menu.treerecurse', 0, '', array(), $children, 9999, 0, 0 ); - - // assemble menu items to the array - $mitems = array(); - $mitems[] = JHTML::_('select.option', '0', JText::_( 'Top' ) ); - - foreach ( $list as $item ) { - $mitems[] = JHTML::_('select.option', $item->id, '   '. $item->treename ); - } - - $output = JHTML::_('select.genericlist', $mitems, 'parent', 'class="inputbox" size="10"', 'value', 'text', $row->parent ); - - return $output; - } - - /** - * build the select list for target window - */ - function Target( &$row ) - { - $click[] = JHTML::_('select.option', '0', JText::_( 'Parent Window With Browser Navigation' ) ); - $click[] = JHTML::_('select.option', '1', JText::_( 'New Window With Browser Navigation' ) ); - $click[] = JHTML::_('select.option', '2', JText::_( 'New Window Without Browser Navigation' ) ); - $target = JHTML::_('select.genericlist', $click, 'browserNav', 'class="inputbox" size="4"', 'value', 'text', intval( $row->browserNav ) ); - - return $target; - } - - /** - * build the select list for target window - */ - function Published( &$row ) - { - $put[] = JHTML::_('select.option', '0', JText::_( 'No' )); - $put[] = JHTML::_('select.option', '1', JText::_( 'Yes' )); - - // If not a new item, trash is not an option - if ( !$row->id ) { - $row->published = 1; - } - $published = JHTML::_('select.radiolist', $put, 'published', '', 'value', 'text', $row->published ); - return $published; - } - - /** - * clean system cache - */ - function cleanCache() - { - global $mainframe; - - if ($mainframe->getCfg('caching')) { - // clean system cache - $cache =& JFactory::getCache('_system'); - $cache->clean(); - - // clean mod_mainmenu cache - $cache2 =& JFactory::getCache('mod_mainmenu'); - $cache2->clean(); - } - } + // clean mod_mainmenu cache + $cache2 =& JFactory::getCache('mod_mainmenu'); + $cache2->clean(); + } + } } diff --git a/vendor/joomla/administrator/components/com_menus/models/list.php b/vendor/joomla/administrator/components/com_menus/models/list.php index f1ae3c590..680843b42 100644 --- a/vendor/joomla/administrator/components/com_menus/models/list.php +++ b/vendor/joomla/administrator/components/com_menus/models/list.php @@ -32,7 +32,7 @@ class MenusModelList extends JModel * Returns the internal table object * @return JTable */ - function &getTable() + function &getTable($name = '', $prefix = 'Table', $options = array()) { if ($this->_table == null) { diff --git a/vendor/joomla/administrator/components/com_menus/models/menutype.php b/vendor/joomla/administrator/components/com_menus/models/menutype.php index 1195ea375..6fd6503a0 100644 --- a/vendor/joomla/administrator/components/com_menus/models/menutype.php +++ b/vendor/joomla/administrator/components/com_menus/models/menutype.php @@ -1,280 +1,271 @@ _table == null) { - $this->_table = & JTable::getInstance('menuTypes'); - if ($id = JRequest::getVar('id', false, '', 'int')) { - $this->_table->load($id); - } - } - return $this->_table; - } - - /** - * Get a list of the menu records associated with the type - * - * @param string The menu type - * @return array An array of records as objects - */ - function getMenus() - { - global $mainframe; - - $menus= array(); - $db = &$this->getDBO(); - - // Preselect some aggregate data - - // Query to get published menu item counts - $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . - ' FROM #__menu AS a' . - ' WHERE a.published = 1' . - ' GROUP BY a.menutype'; - $db->setQuery( $query ); - $published = $db->loadObjectList( 'menutype' ); - - // Query to get unpublished menu item counts - $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . - ' FROM #__menu AS a' . - ' WHERE a.published = 0' . - ' GROUP BY a.menutype'; - $db->setQuery( $query ); - $unpublished = $db->loadObjectList( 'menutype' ); - - // Query to get trash menu item counts - $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . - ' FROM #__menu AS a' . - ' WHERE a.published = -2' . - ' GROUP BY a.menutype'; - $db->setQuery( $query ); - $trash = $db->loadObjectList( 'menutype' ); - - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' ); - - $query = 'SELECT a.*, SUM(b.home) AS home' . - ' FROM #__menu_types AS a' . - ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' . - ' GROUP BY a.id'; - $db->setQuery( $query, $limitstart, $limit ); - $menuTypes = $db->loadObjectList(); - - $total = count( $menuTypes ); - $i = 0; - for ($i = 0; $i < $total; $i++) { - $row = &$menuTypes[$i]; - - // query to get number of modules for menutype - $query = 'SELECT count( id )' . - ' FROM #__modules' . - ' WHERE module = "mod_mainmenu"' . - ' AND params LIKE '.$db->Quote('%menutype='.$row->menutype.'%'); - $db->setQuery( $query ); - $modules = $db->loadResult(); - - if ( !$modules ) { - $modules = '-'; - } - $row->modules = $modules; - $row->published = @$published[$row->menutype]->num ? $published[$row->menutype]->num : '-' ; - $row->unpublished = @$unpublished[$row->menutype]->num ? $unpublished[$row->menutype]->num : '-'; - $row->trash = @$trash[$row->menutype]->num ? $trash[$row->menutype]->num : '-'; - $menus[] = $row; - } - return $menus; - } - - /** - * Get a list of the menu records associated with the type - * - * @param string The menu type - * @return array An array of records as objects - */ - function getPagination() - { - global $mainframe; - - $menutypes = MenusHelper::getMenuTypeList(); - $total = count( $menutypes ); - $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); - $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' ); - - jimport('joomla.html.pagination'); - $pagination = new JPagination( $total, $limitstart, $limit ); - return $pagination; - } - - /** - * Get a list of the menu records associated with the type - * @param string The menu type - * @return array An array of records as objects - */ - function getMenuItems() - { - $table = & $this->getTable(); - if ($table->menutype == '') { - $table->menutype = JRequest::getVar('menutype', '', '', 'menutype'); - } - - $db = &$this->getDBO(); - $query = 'SELECT a.name, a.id' . - ' FROM #__menu AS a' . - ' WHERE a.menutype = ' . $db->Quote( $table->menutype ) . - ' ORDER BY a.name'; - $db->setQuery( $query ); - $result = $db->loadObjectList(); - return $result; - } - - /** - * Get a list of the menu records associated with the type - * @param string The menu type - * @return array An array of records as objects - */ - function getModules( $type='' ) - { - if ($type == '') { - $type = $this->_table->menutype; - } - - $db = &$this->getDBO(); - $query = 'SELECT id, title, params' . - ' FROM #__modules' . - ' WHERE module = "mod_mainmenu"' . - ' AND params LIKE ' . $db->Quote( '%menutype=' . $type . '%' ); - $db->setQuery( $query ); - $temp = $db->loadObjectList(); - - $result = array(); - $n = count( $temp ); - for ($i = 0; $i < $n; $i++) - { - $params = new JParameter( $temp[$i]->params ); - if ($params->get( 'menutype' ) == $type) { - $result[] = $temp[$i]; - } - } - return $result; - } - - /** - * Checks if the menu can be deleted - * @param string The menu type - * @return boolean - */ - function canDelete( $type='' ) - { - if ($type == '') { - $type = $this->_table->menutype; - } - if ($type == 'mainmenu') { - $this->setError( JText::_( 'WARNDELMAINMENU' ) ); - return false; - } - return true; - } - - /** - * Deletes menu type and associations - * @param string The id of the menu type - * @return boolean - */ - function delete( $id = 0 ) - { - $table = &$this->getTable(); - if ($id != 0) { - $table->load( $id ); - } - - $db = &$this->getDBO(); - - // Delete Associations - if (!$this->deleteByType( $table->menutype )) { - $this->setError( $this->getError() ); - return false; - } - - // TODO: Should invoke JModuleModel::delete to delete the actual module - $moduleTable= &JTable::getInstance( 'module'); - $items = &$this->getModules( $table->menutype ); - $modulesIds = array(); - foreach ($items as $item) - { - if (!$moduleTable->delete( $item->id )) { - $this->setError( $moduleTable->getErrorMsg() ); - return false; - } - $modulesIds[] = (int) $item->id; - } - - if (count( $modulesIds )) { - $query = 'DELETE FROM #__modules_menu' . - ' WHERE menuid = '.implode( ' OR moduleid = ', $modulesIds ); - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $menuTable->getErrorMsg() ); - return false; - } - } - - $result = $table->delete(); - - return $result; - } - - /** - * Delete menu items by type - */ - function deleteByType( $type = '' ) - { - if (!$type) { - return false; - } - $db = &$this->getDBO(); - $query = 'DELETE FROM #__menu' . - ' WHERE menutype = '.$db->Quote( $type ); - $db->setQuery( $query ); - if (!$db->query()) { - $this->setError( $menuTable->getErrorMsg() ); - return false; - } - - // clean cache - MenusHelper::cleanCache(); - - return true; - } + var $_modelName = 'menutype'; + + /** @var object JTable object */ + var $_table = null; + + /** + * Returns the internal table object + * @return JTable + */ + function &getTable($name = '', $prefix = 'Table', $options = array()) + { + if ($this->_table == null) { + $this->_table =& JTable::getInstance('menuTypes'); + if ($id = JRequest::getVar('id', false, '', 'int')) { + $this->_table->load($id); + } + } + return $this->_table; + } + + /** + * Get a list of the menu records associated with the type + * + * @param string The menu type + * @return array An array of records as objects + */ + function getMenus() + { + global $mainframe; + + $menus= array(); + $db = &$this->getDBO(); + + // Preselect some aggregate data + + // Query to get published menu item counts + $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . + ' FROM #__menu AS a' . + ' WHERE a.published = 1' . + ' GROUP BY a.menutype'; + $db->setQuery( $query ); + $published = $db->loadObjectList( 'menutype' ); + + // Query to get unpublished menu item counts + $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . + ' FROM #__menu AS a' . + ' WHERE a.published = 0' . + ' GROUP BY a.menutype'; + $db->setQuery( $query ); + $unpublished = $db->loadObjectList( 'menutype' ); + + // Query to get trash menu item counts + $query = 'SELECT a.menutype, COUNT( a.menutype ) AS num' . + ' FROM #__menu AS a' . + ' WHERE a.published = -2' . + ' GROUP BY a.menutype'; + $db->setQuery( $query ); + $trash = $db->loadObjectList( 'menutype' ); + + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' ); + + $query = 'SELECT a.*, SUM(b.home) AS home' . + ' FROM #__menu_types AS a' . + ' LEFT JOIN #__menu AS b ON b.menutype = a.menutype' . + ' GROUP BY a.id'; + $db->setQuery( $query, $limitstart, $limit ); + $menuTypes = $db->loadObjectList(); + + $total = count( $menuTypes ); + $i = 0; + for ($i = 0; $i < $total; $i++) { + $row = &$menuTypes[$i]; + + // query to get number of modules for menutype + $query = 'SELECT count( id )' . + ' FROM #__modules' . + ' WHERE module = "mod_mainmenu"' . + ' AND params LIKE '.$db->Quote('%menutype='.$row->menutype.'%'); + $db->setQuery( $query ); + $modules = $db->loadResult(); + + if ( !$modules ) { + $modules = '-'; + } + $row->modules = $modules; + $row->published = @$published[$row->menutype]->num ? $published[$row->menutype]->num : '-' ; + $row->unpublished = @$unpublished[$row->menutype]->num ? $unpublished[$row->menutype]->num : '-'; + $row->trash = @$trash[$row->menutype]->num ? $trash[$row->menutype]->num : '-'; + $menus[] = $row; + } + return $menus; + } + + /** + * Get a list of the menu records associated with the type + * + * @param string The menu type + * @return array An array of records as objects + */ + function getPagination() + { + global $mainframe; + + $menutypes = MenusHelper::getMenuTypeList(); + $total = count( $menutypes ); + $limit = $mainframe->getUserStateFromRequest( 'global.list.limit', 'limit', $mainframe->getCfg('list_limit'), 'int' ); + $limitstart = $mainframe->getUserStateFromRequest( 'com_menus.limitstart', 'limitstart', 0, 'int' ); + + jimport('joomla.html.pagination'); + $pagination = new JPagination( $total, $limitstart, $limit ); + return $pagination; + } + + /** + * Get a list of the menu records associated with the type + * + * @param string The menu type + * @return array An array of records as objects + */ + function getMenuItems() + { + $table = & $this->getTable(); + if ($table->menutype == '') { + $table->menutype = JRequest::getVar('menutype', '', '', 'menutype'); + } + + $db = &$this->getDBO(); + $query = 'SELECT a.name, a.id' . + ' FROM #__menu AS a' . + ' WHERE a.menutype = ' . $db->Quote( $table->menutype ) . + ' ORDER BY a.name'; + $db->setQuery( $query ); + $result = $db->loadObjectList(); + return $result; + } + + /** + * Get a list of the menu records associated with the type + * + * @param string The menu type + * @return array An array of records as objects + */ + function getModules( $type='' ) + { + if ($type == '') { + $type = $this->_table->menutype; + } + + $db = &$this->getDBO(); + $query = 'SELECT id, title, params' . + ' FROM #__modules' . + ' WHERE module = "mod_mainmenu"' . + ' AND params LIKE ' . $db->Quote( '%menutype=' . $type . '%' ); + $db->setQuery( $query ); + $temp = $db->loadObjectList(); + + $result = array(); + $n = count( $temp ); + for ($i = 0; $i < $n; $i++) { + $params = new JParameter( $temp[$i]->params ); + if ($params->get( 'menutype' ) == $type) { + $result[] = $temp[$i]; + } + } + return $result; + } + + /** + * Checks if the menu can be deleted + * + * @param string The menu type + * @return boolean + */ + function canDelete($type = '') + { + if ($type == '') { + $type = $this->getTable()->menutype; + } + if ($type == 'mainmenu') { + $this->setError(JText::_('WARNDELMAINMENU')); + return false; + } + return true; + } + + /** + * Deletes menu type and associations + * + * @param string The id of the menu type + * @return boolean + */ + function delete($id = 0) + { + $table = &$this->getTable(); + if ($id != 0) { + $table->load( $id ); + } + + $db = &$this->getDBO(); + + // Delete Associations + if (!$this->deleteByType( $table->menutype )) { + $this->setError( $this->getError() ); + return false; + } + + // TODO: Should invoke JModuleModel::delete to delete the actual module + $moduleTable = &JTable::getInstance( 'module'); + $items = $this->getModules($table->menutype ); + $modulesIds = array(); + foreach ($items as $item) { + if ( ! $moduleTable->delete( $item->id )) { + $this->setError($moduleTable->getErrorMsg()); + return false; + } + $modulesIds[] = (int) $item->id; + } + + if (count( $modulesIds )) { + $query = 'DELETE FROM #__modules_menu' . + ' WHERE menuid = '.implode( ' OR moduleid = ', $modulesIds ); + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + } + + $result = $table->delete(); + + return $result; + } + + /** + * Delete menu items by type + */ + function deleteByType($type = '') + { + if ( ! $type) { + return false; + } + $db = &$this->getDBO(); + $query = 'DELETE FROM #__menu' . + ' WHERE menutype = '.$db->Quote( $type ); + $db->setQuery( $query ); + if (!$db->query()) { + $this->setError( $menuTable->getErrorMsg() ); + return false; + } + + // clean cache + MenusHelper::cleanCache(); + + return true; + } } diff --git a/vendor/joomla/administrator/components/com_modules/admin.modules.html.php b/vendor/joomla/administrator/components/com_modules/admin.modules.html.php index 36f373bf3..6a24e2ac2 100644 --- a/vendor/joomla/administrator/components/com_modules/admin.modules.html.php +++ b/vendor/joomla/administrator/components/com_modules/admin.modules.html.php @@ -1,622 +1,606 @@ -
- - - - - - -
- : - - - - - -
- - - - - - - - - - - id == 0 ) { - ?> - - - - - - - - - - - - - - - id .'&task=edit&cid[]='. $row->id ); - - $access = JHTML::_('grid.access', $row, $i ); - $checked = JHTML::_('grid.checkedout', $row, $i ); - $published = JHTML::_('grid.published', $row, $i ); - ?> - "> - - - - - - id == 0 ) { - ?> - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - -
- getListFooter(); ?> -
- getRowOffset( $i ); ?> - - - - get ('id'), $row->checked_out ) ) { - echo htmlspecialchars($row->title); - } else { - ?> - - - title); ?> - - - - - - orderUpIcon( $i, ($row->position == @$rows[$i-1]->position), 'orderup', 'Move Up', $ordering ); ?> - orderDownIcon( $i, $n, ($row->position == @$rows[$i+1]->position),'orderdown', 'Move Down', $ordering ); ?> - - class="text_area" style="text-align: center" /> - - - - position; ?> - - pages )) { - echo JText::_( 'None' ); - } else if ($row->pages > 0) { - echo JText::_( 'Varies' ); - } else { - echo JText::_( 'All' ); - } - ?> - - module ? $row->module : JText::_( 'User' );?> - - id;?> -
- - - - - - - - -
- $row is passed with the id - * property set to 0. - * @param JTableCategory The category object - * @param array

The modules of the left side. The array elements are in the form - * $leftorder[order] = label - * where order is the module order from the db table and label is a - * text label associciated with the order.

- * @param array See notes for leftorder - * @param array An array of select lists - * @param object Parameters - */ - function edit( &$model, &$row, &$orders2, &$lists, &$params, $client ) - { - JRequest::setVar( 'hidemainmenu', 1 ); - - // clean item data - JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' ); - - // Check for component metadata.xml file - //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module ); - //$params = new JParameter( $row->params, $path ); - $document =& JFactory::getDocument(); - - JHTML::_('behavior.combobox'); - - jimport('joomla.html.pane'); + /** + * Writes a list of the defined modules + * @param array An array of category objects + */ + public static function view( &$rows, &$client, &$page, &$lists ) + { + $user =& JFactory::getUser(); + + //Ordering allowed ? + $ordering = ($lists['order'] == 'm.ordering' || $lists['order'] == 'm.position'); + + JHTML::_('behavior.tooltip'); + ?> +
+ + + + + + +
+ : + + + + + +
+ + + + + + + + + + + id == 0 ) { + ?> + + + + + + + + + + + + + + + id .'&task=edit&cid[]='. $row->id ); + $access = JHTML::_('grid.access', $row, $i ); + $checked = JHTML::_('grid.checkedout', $row, $i ); + $published = JHTML::_('grid.published', $row, $i ); + ?> + "> + + + + + + id == 0 ) { + ?> + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + +
+ getListFooter(); ?> +
+ getRowOffset( $i ); ?> + + + + get ('id'), $row->checked_out ) ) { + echo htmlspecialchars($row->title); + } else { + ?> + + + title); ?> + + + + + + orderUpIcon( $i, ($row->position == @$rows[$i-1]->position), 'orderup', 'Move Up', $ordering ); ?> + orderDownIcon( $i, $n, ($row->position == @$rows[$i+1]->position),'orderdown', 'Move Down', $ordering ); ?> + + class="text_area" style="text-align: center" /> + + + + position; ?> + + pages )) { + echo JText::_( 'None' ); + } else if ($row->pages > 0) { + echo JText::_( 'Varies' ); + } else { + echo JText::_( 'All' ); + } + ?> + + module ? $row->module : JText::_( 'User' );?> + + id;?> +
+ + + + + + + + +
+ $row is passed with the id + * property set to 0. + * + * @param JTableCategory The category object + * @param array

The modules of the left side. The array elements are in the form + * $leftorder[order] = label + * where order is the module order from the db table and label is a + * text label associciated with the order.

+ * @param array See notes for leftorder + * @param array An array of select lists + * @param object Parameters + */ + public static function edit( &$model, &$row, &$orders2, &$lists, &$params, $client ) + { + JRequest::setVar( 'hidemainmenu', 1 ); + + // clean item data + JFilterOutput::objectHTMLSafe( $row, ENT_QUOTES, 'content' ); + + // Check for component metadata.xml file + //$path = JApplicationHelper::getPath( 'mod'.$client->id.'_xml', $row->module ); + //$params = new JParameter( $row->params, $path ); + $document =& JFactory::getDocument(); + + JHTML::_('behavior.combobox'); + + jimport('joomla.html.pane'); // TODO: allowAllClose should default true in J!1.6, so remove the array when it does. - $pane = &JPane::getInstance('sliders', array('allowAllClose' => true)); - $editor =& JFactory::getEditor(); - - JHTML::_('behavior.tooltip'); - ?> - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- : - - - module); ?> - -
- - - -
- : - - -
- : - - -
- - - - -
- - - -
- - - -
- : - - id; ?> -
- : - - description); ?> -
-
-
- - - - - - - - - - - -
- : - - client_id != 1) : ?> - pages == 'all') { ?> - - - - pages == 'none') { ?> - - - - - - - - - -
- : - - -
- client_id != 1) : ?> - pages == 'all') { ?> - - pages == 'none') { ?> - - - - -
-
- -
-
- - - startPane("menu-pane"); - echo $pane->startPanel(JText :: _('Module Parameters'), "param-page"); - $p = $params; - if($params = $p->render('params')) : - echo $params; - else : - echo "
".JText::_('There are no parameters for this item')."
"; - endif; - echo $pane->endPanel(); - - if ($p->getNumParams('advanced')) { - echo $pane->startPanel(JText :: _('Advanced Parameters'), "advanced-page"); - if($params = $p->render('params', 'advanced')) : - echo $params; - else : - echo "
".JText::_('There are no advanced parameters for this item')."
"; - endif; - echo $pane->endPanel(); - } - - if ($p->getNumParams('legacy')) { - echo $pane->startPanel(JText :: _('Legacy Parameters'), "legacy-page"); - if($params = $p->render('params', 'legacy')) : - echo $params; - else : - echo "
".JText::_('There are no legacy parameters for this item')."
"; - endif; - echo $pane->endPanel(); - } - - - if ($p->getNumParams('other')) { - echo $pane->startPanel(JText :: _('Other Parameters'), "other-page"); - if($params = $p->render('params', 'other')) : - echo $params; - else : - echo "
".JText::_('There are no other parameters for this item')."
"; - endif; - echo $pane->endPanel(); - } - echo $pane->endPane(); - ?> -
-
-
- - module || $row->module == 'custom' || $row->module == 'mod_custom' ) { - ?> -
- - - display( 'content', $row->content, '100%', '400', '60', '20', array('pagebreak', 'readmore') ) ; - ?> - -
- - - - - - - - - - -
- - - - - - - - - - -
- -
- - - - - - - - - - - - - - - - = $count) : - ?> - - module . '&created=1&client=' . $client->id; - ?> - - - - - -
- -
  -
  - - name, ENT_QUOTES, 'UTF-8'); ?> -
- - - - - - - -
- true)); + $editor =& JFactory::getEditor(); + + JHTML::_('behavior.tooltip'); + ?> + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ : + + + module); ?> + +
+ + + +
+ : + + +
+ : + + +
+ + + + +
+ + + +
+ + + +
+ : + + id; ?> +
+ : + + description); ?> +
+
+
+ + + + + + + + + + + +
+ : + + client_id != 1) : ?> + pages == 'all') { ?> + + + + pages == 'none') { ?> + + + + + + + + + +
+ : + + +
+ client_id != 1) : ?> + pages == 'all') { ?> + + pages == 'none') { ?> + + + + +
+
+ +
+
+ + + startPane("menu-pane"); + echo $pane->startPanel(JText :: _('Module Parameters'), "param-page"); + $p = $params; + if($params = $p->render('params')) : + echo $params; + else : + echo "
".JText::_('There are no parameters for this item')."
"; + endif; + echo $pane->endPanel(); + + if ($p->getNumParams('advanced')) { + echo $pane->startPanel(JText :: _('Advanced Parameters'), "advanced-page"); + if($params = $p->render('params', 'advanced')) : + echo $params; + else : + echo "
".JText::_('There are no advanced parameters for this item')."
"; + endif; + echo $pane->endPanel(); + } + + if ($p->getNumParams('legacy')) { + echo $pane->startPanel(JText :: _('Legacy Parameters'), "legacy-page"); + if($params = $p->render('params', 'legacy')) : + echo $params; + else : + echo "
".JText::_('There are no legacy parameters for this item')."
"; + endif; + echo $pane->endPanel(); + } + + if ($p->getNumParams('other')) { + echo $pane->startPanel(JText :: _('Other Parameters'), "other-page"); + if($params = $p->render('params', 'other')) : + echo $params; + else : + echo "
".JText::_('There are no other parameters for this item')."
"; + endif; + echo $pane->endPanel(); + } + echo $pane->endPane(); + ?> +
+
+
+ + module || $row->module == 'custom' || $row->module == 'mod_custom' ) { + ?> +
+ + + display( 'content', $row->content, '100%', '400', '60', '20', array('pagebreak', 'readmore') ) ; + ?> + +
+ + + + + + + + + + +
+ + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + + + = $count) : + ?> + + module . '&created=1&client=' . $client->id; + ?> + + + + + +
+ +
  +
  + + name, ENT_QUOTES, 'UTF-8'); ?> +
+ + + + + + + +
+ load( (int) $cid[0] ); // fail if checked out not by 'me' - if ($row->isCheckedOut( $user->get('id') )) { + if (JTable::isCheckedOut($user->get('id'), $row->checked_out)) { $this->setRedirect( 'index.php?option=com_modules&client='.$client->id ); return JError::raiseWarning( 500, JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The module' ), $row->title ) ); } diff --git a/vendor/joomla/administrator/components/com_modules/toolbar.modules.html.php b/vendor/joomla/administrator/components/com_modules/toolbar.modules.html.php index 1dcd37cf7..119b60294 100644 --- a/vendor/joomla/administrator/components/com_modules/toolbar.modules.html.php +++ b/vendor/joomla/administrator/components/com_modules/toolbar.modules.html.php @@ -1,73 +1,62 @@ [ '. JText::_( 'New' ) .' ]', 'module.png' ); - JToolBarHelper::customX( 'edit', 'forward.png', 'forward_f2.png', 'Next', true ); - JToolBarHelper::cancel(); - if ($client->name == 'site') { - JToolBarHelper::help( 'screen.modulessite.edit' ); - } - else { - JToolBarHelper::help( 'screen.modulesadministrator.edit'); - } - } - - /** - * Draws the menu for Editing an existing module - */ - function _EDIT( $client ) - { - $moduleType = JRequest::getCmd( 'module' ); - $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); - JArrayHelper::toInteger($cid, array(0)); - - JToolBarHelper::title( JText::_( 'Module' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'module.png' ); - - if($moduleType == 'custom') { - JToolBarHelper::Preview('index.php?option=com_modules&tmpl=component&client='.$client->id.'&pollid='.$cid[0]); - } - - JToolBarHelper::save(); - JToolBarHelper::apply(); - if ( $cid[0] ) { - // for existing items the button is renamed `close` - JToolBarHelper::cancel( 'cancel', 'Close' ); - } else { - JToolBarHelper::cancel(); - } - JToolBarHelper::help( 'screen.modules.edit' ); - } - - function _DEFAULT($client) - { - JToolBarHelper::title( JText::_( 'Module Manager' ), 'module.png' ); - JToolBarHelper::publishList(); - JToolBarHelper::unpublishList(); - JToolBarHelper::custom( 'copy', 'copy.png', 'copy_f2.png', 'Copy', true ); - JToolBarHelper::deleteList(); - JToolBarHelper::editListX(); - JToolBarHelper::addNewX(); - JToolBarHelper::help( 'screen.modules' ); - } +class TOOLBAR_modules +{ + /** + * Draws the menu for a New module + */ + public static function _NEW($client) + { + JToolBarHelper::title( JText::_( 'Module' ) . ': [ '. JText::_( 'New' ) .' ]', 'module.png' ); + JToolBarHelper::customX( 'edit', 'forward.png', 'forward_f2.png', 'Next', true ); + JToolBarHelper::cancel(); + if ($client->name == 'site') { + JToolBarHelper::help( 'screen.modulessite.edit' ); + } else { + JToolBarHelper::help( 'screen.modulesadministrator.edit'); + } + } + + /** + * Draws the menu for Editing an existing module + */ + public static function _EDIT($client) + { + $moduleType = JRequest::getCmd( 'module' ); + $cid = JRequest::getVar( 'cid', array(0), '', 'array' ); + JArrayHelper::toInteger($cid, array(0)); + + JToolBarHelper::title(JText::_('Module').': [ '.JText::_('Edit').' ]', 'module.png'); + + if($moduleType == 'custom') { + JToolBarHelper::Preview('index.php?option=com_modules&tmpl=component&client='.$client->id.'&pollid='.$cid[0]); + } + + JToolBarHelper::save(); + JToolBarHelper::apply(); + if ($cid[0]) { + // for existing items the button is renamed `close` + JToolBarHelper::cancel( 'cancel', 'Close' ); + } else { + JToolBarHelper::cancel(); + } + JToolBarHelper::help('screen.modules.edit'); + } + + public static function _DEFAULT($client) + { + JToolBarHelper::title(JText::_('Module Manager' ), 'module.png'); + JToolBarHelper::publishList(); + JToolBarHelper::unpublishList(); + JToolBarHelper::custom('copy', 'copy.png', 'copy_f2.png', 'Copy', true); + JToolBarHelper::deleteList(); + JToolBarHelper::editListX(); + JToolBarHelper::addNewX(); + JToolBarHelper::help('screen.modules'); + } } diff --git a/vendor/joomla/administrator/components/com_plugins/controller.php b/vendor/joomla/administrator/components/com_plugins/controller.php index 9ea95244e..8d7c6972b 100644 --- a/vendor/joomla/administrator/components/com_plugins/controller.php +++ b/vendor/joomla/administrator/components/com_plugins/controller.php @@ -46,7 +46,7 @@ function __construct( $default = array()) } - function display( ) + function display($cachable = false) { switch($this->getTask()) { @@ -59,7 +59,7 @@ function display( ) } break; } - parent::display(); + parent::display($cachable); } function save() diff --git a/vendor/joomla/administrator/components/com_plugins/views/plugin/tmpl/form.php b/vendor/joomla/administrator/components/com_plugins/views/plugin/tmpl/form.php index 0a84d9a0f..90819f177 100644 --- a/vendor/joomla/administrator/components/com_plugins/views/plugin/tmpl/form.php +++ b/vendor/joomla/administrator/components/com_plugins/views/plugin/tmpl/form.php @@ -16,6 +16,7 @@ ?> plugin->nameA = ''; if ( $this->plugin->id ) { $row->nameA = '[ '. $this->plugin->name .' ]'; diff --git a/vendor/joomla/administrator/components/com_plugins/views/plugin/view.html.php b/vendor/joomla/administrator/components/com_plugins/views/plugin/view.html.php index 86b83a17f..048ad0dd7 100644 --- a/vendor/joomla/administrator/components/com_plugins/views/plugin/view.html.php +++ b/vendor/joomla/administrator/components/com_plugins/views/plugin/view.html.php @@ -46,7 +46,7 @@ function display( $tpl = null ) // fail if checked out not by 'me' - if ($row->isCheckedOut( $user->get('id') )) + if (JTable::isCheckedOut($user->get('id'), $row->checked_out)) { $msg = JText::sprintf( 'DESCBEINGEDITTED', JText::_( 'The plugin' ), $row->title ); $this->setRedirect( 'index.php?option='. $option .'&client='. $client, $msg, 'error' ); diff --git a/vendor/joomla/administrator/components/com_templates/controller.php b/vendor/joomla/administrator/components/com_templates/controller.php index f84a38204..5f3518d7e 100644 --- a/vendor/joomla/administrator/components/com_templates/controller.php +++ b/vendor/joomla/administrator/components/com_templates/controller.php @@ -96,7 +96,7 @@ function publishTemplate() // Initialize some variables $db = & JFactory::getDBO(); $cid = JRequest::getVar('cid', array(), 'method', 'array'); - $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + $cid = array(JFilterInput::getInstance()->clean(@$cid[0], 'cmd')); $option = JRequest::getCmd('option'); $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); @@ -124,7 +124,7 @@ function editTemplate() // Initialize some variables $db = & JFactory::getDBO(); $cid = JRequest::getVar('cid', array(), 'method', 'array'); - $cid = array(JFilterInput::clean(@$cid[0], 'cmd')); + $cid = array(JFilterInput::getInstance()->clean(@$cid[0], 'cmd')); $template = $cid[0]; $option = JRequest::getCmd('option'); $client =& JApplicationHelper::getClientInfo(JRequest::getVar('client', '0', '', 'int')); diff --git a/vendor/joomla/administrator/components/com_templates/toolbar.templates.html.php b/vendor/joomla/administrator/components/com_templates/toolbar.templates.html.php index 3f4f7abc8..37d5068fe 100644 --- a/vendor/joomla/administrator/components/com_templates/toolbar.templates.html.php +++ b/vendor/joomla/administrator/components/com_templates/toolbar.templates.html.php @@ -1,77 +1,70 @@ id == '1') { - JToolBarHelper::makeDefault('publish'); - } else { - JToolBarHelper::makeDefault(); - } - JToolBarHelper::editListX( 'edit', 'Edit' ); - //JToolBarHelper::addNew(); - JToolBarHelper::help( 'screen.templates' ); - } - function _VIEW(&$client){ - - JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' ); - JToolBarHelper::back(); - } - - function _EDIT_SOURCE(&$client){ - - JToolBarHelper::title( JText::_( 'Template HTML Editor' ), 'thememanager' ); - JToolBarHelper::save( 'save_source' ); - JToolBarHelper::apply( 'apply_source' ); - JToolBarHelper::cancel('edit'); - JToolBarHelper::help( 'screen.templates' ); - } - - function _EDIT(&$client){ - JToolBarHelper::title( JText::_( 'Template' ) . ': [ '. JText::_( 'Edit' ) .' ]', 'thememanager' ); - //JToolBarHelper::custom('preview', 'preview.png', 'preview_f2.png', 'Preview', false, false); - //JToolBarHelper::custom( 'edit_source', 'html.png', 'html_f2.png', 'Edit HTML', false, false ); - //JToolBarHelper::custom( 'choose_css', 'css.png', 'css_f2.png', 'Edit CSS', false, false ); - JToolBarHelper::save( 'save' ); - JToolBarHelper::apply(); - JToolBarHelper::cancel( 'cancel', 'Close' ); - JToolBarHelper::help( 'screen.templates' ); - } - - function _CHOOSE_CSS(&$client){ - JToolBarHelper::title( JText::_( 'Template CSS Editor' ), 'thememanager' ); - JToolBarHelper::custom( 'edit_css', 'edit.png', 'edit_f2.png', 'Edit', true ); - JToolBarHelper::cancel('edit'); - JToolBarHelper::help( 'screen.templates' ); - } - - function _EDIT_CSS(&$client){ - JToolBarHelper::title( JText::_( 'Template Manager' ), 'thememanager' ); - JToolBarHelper::save( 'save_css' ); - JToolBarHelper::apply( 'apply_css'); - JToolBarHelper::cancel('choose_css'); - JToolBarHelper::help( 'screen.templates' ); - } -} \ No newline at end of file + public static function _DEFAULT(&$client) + { + JToolBarHelper::title(JText::_('Template Manager'), 'thememanager'); + + if ($client->id == '1') { + JToolBarHelper::makeDefault('publish'); + } else { + JToolBarHelper::makeDefault(); + } + JToolBarHelper::editListX( 'edit', 'Edit' ); + //JToolBarHelper::addNew(); + JToolBarHelper::help( 'screen.templates' ); + } + + public static function _VIEW(&$client) + { + JToolBarHelper::title(JText::_('Template Manager'), 'thememanager'); + JToolBarHelper::back(); + } + + public static function _EDIT_SOURCE(&$client) + { + JToolBarHelper::title(JText::_('Template HTML Editor'), 'thememanager'); + JToolBarHelper::save('save_source'); + JToolBarHelper::apply('apply_source'); + JToolBarHelper::cancel('edit'); + JToolBarHelper::help('screen.templates'); + } + + public static function _EDIT(&$client) + { + JToolBarHelper::title(JText::_('Template').': [ '.JText::_( 'Edit' ).' ]', 'thememanager'); + //JToolBarHelper::custom('preview', 'preview.png', 'preview_f2.png', 'Preview', false, false); + //JToolBarHelper::custom( 'edit_source', 'html.png', 'html_f2.png', 'Edit HTML', false, false ); + //JToolBarHelper::custom( 'choose_css', 'css.png', 'css_f2.png', 'Edit CSS', false, false ); + JToolBarHelper::save('save'); + JToolBarHelper::apply(); + JToolBarHelper::cancel( 'cancel', 'Close' ); + JToolBarHelper::help( 'screen.templates' ); + } + + public static function _CHOOSE_CSS(&$client) + { + JToolBarHelper::title(JText::_('Template CSS Editor' ), 'thememanager'); + JToolBarHelper::custom('edit_css', 'edit.png', 'edit_f2.png', 'Edit', true); + JToolBarHelper::cancel('edit'); + JToolBarHelper::help('screen.templates' ); + } + + public static function _EDIT_CSS(&$client) + { + JToolBarHelper::title( JText::_('Template Manager'), 'thememanager'); + JToolBarHelper::save('save_css'); + JToolBarHelper::apply('apply_css'); + JToolBarHelper::cancel('choose_css'); + JToolBarHelper::help( 'screen.templates' ); + } +} diff --git a/vendor/joomla/administrator/components/com_users/controller.php b/vendor/joomla/administrator/components/com_users/controller.php index 586e35afc..b66a0a2f3 100644 --- a/vendor/joomla/administrator/components/com_users/controller.php +++ b/vendor/joomla/administrator/components/com_users/controller.php @@ -46,17 +46,17 @@ function __construct($config = array()) /** * Displays a view */ - function display( ) + function display($cachable = false) { switch($this->getTask()) { - case 'add' : + case 'add': { JRequest::setVar( 'hidemainmenu', 1 ); JRequest::setVar( 'layout', 'form' ); JRequest::setVar( 'view', 'user' ); JRequest::setVar( 'edit', false ); } break; - case 'edit' : + case 'edit': { JRequest::setVar( 'hidemainmenu', 1 ); JRequest::setVar( 'layout', 'form' ); @@ -65,7 +65,7 @@ function display( ) } break; } - parent::display(); + parent::display($cachable); } /** diff --git a/vendor/joomla/administrator/language/en-GB/en-GB.ini b/vendor/joomla/administrator/language/en-GB/en-GB.ini index b835b37ac..57cd61675 100644 --- a/vendor/joomla/administrator/language/en-GB/en-GB.ini +++ b/vendor/joomla/administrator/language/en-GB/en-GB.ini @@ -606,6 +606,3 @@ WRITABLE=Writable YES=Yes YOU MUST SELECT A CATEGORY=You must select a Category YOU MUST SELECT A SECTION=You must select a Section - - - diff --git a/vendor/joomla/libraries/joomla/application/application.php b/vendor/joomla/libraries/joomla/application/application.php index 1b5fe1130..b50657d26 100644 --- a/vendor/joomla/libraries/joomla/application/application.php +++ b/vendor/joomla/libraries/joomla/application/application.php @@ -703,14 +703,13 @@ function &getPathway($name = null, $options = array()) /** * Return a reference to the application JPathway object. * - * @access public * @param array $options An optional associative array of configuration settings. * @return object JMenu. * @since 1.5 */ - function &getMenu($name = null, $options = array()) + public static function &getMenu($name = null, $options = array()) { - if(!isset($name)) { + if( ! isset($name)) { $name = $this->_name; } diff --git a/vendor/joomla/libraries/joomla/application/component/controller.php b/vendor/joomla/libraries/joomla/application/component/controller.php index b79b16ad0..bfefb7f3e 100644 --- a/vendor/joomla/libraries/joomla/application/component/controller.php +++ b/vendor/joomla/libraries/joomla/application/component/controller.php @@ -354,7 +354,7 @@ function &getModel( $name = '', $prefix = '', $config = array() ) // Lets get the application object and set menu information if its available $app = &JFactory::getApplication(); - $menu = &$app->getMenu(); + $menu = call_user_func(array(get_class($app), 'getMenu'), $app->getName()); if (is_object( $menu )) { if ($item = $menu->getActive()) diff --git a/vendor/joomla/libraries/joomla/application/component/model.php b/vendor/joomla/libraries/joomla/application/component/model.php index 228569172..dcb9d657b 100644 --- a/vendor/joomla/libraries/joomla/application/component/model.php +++ b/vendor/joomla/libraries/joomla/application/component/model.php @@ -1,353 +1,332 @@ _name )) - { - if (array_key_exists('name', $config)) { - $this->_name = $config['name']; - } else { - $this->_name = $this->getName(); - } - } - - //set the model state - if (array_key_exists('state', $config)) { - $this->_state = $config['state']; - } else { - $this->_state = new JObject(); - } - - //set the model dbo - if (array_key_exists('dbo', $config)) { - $this->_db = $config['dbo']; - } else { - $this->_db = &JFactory::getDBO(); - } - - // set the default view search path - if (array_key_exists('table_path', $config)) { - $this->addTablePath($config['table_path']); - } else if (defined( 'JPATH_COMPONENT_ADMINISTRATOR' )){ - $this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); - } - } - - /** - * Returns a reference to the a Model object, always creating it - * - * @param string The model type to instantiate - * @param string Prefix for the model class name. Optional. - * @param array Configuration array for model. Optional. - * @return mixed A model object, or false on failure - * @since 1.5 - */ - function &getInstance( $type, $prefix = '', $config = array() ) - { - $type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type); - $modelClass = $prefix.ucfirst($type); - $result = false; - - if (!class_exists( $modelClass )) - { - jimport('joomla.filesystem.path'); - $path = JPath::find( - JModel::addIncludePath(), - JModel::_createFileName( 'model', array( 'name' => $type)) - ); - if ($path) - { - require_once $path; - - if (!class_exists( $modelClass )) - { - JError::raiseWarning( 0, 'Model class ' . $modelClass . ' not found in file.' ); - return $result; - } - } - else return $result; - } - - $result = new $modelClass($config); - return $result; - } - - /** - * Method to set model state variables - * - * @access public - * @param string The name of the property - * @param mixed The value of the property to set - * @return mixed The previous value of the property - * @since 1.5 - */ - function setState( $property, $value=null ) - { - return $this->_state->set($property, $value); - } - - /** - * Method to get model state variables - * - * @access public - * @param string Optional parameter name - * @return object The property where specified, the state object where omitted - * @since 1.5 - */ - function getState($property = null) - { - return $property === null ? $this->_state : $this->_state->get($property); - } - - /** - * Method to get the database connector object - * - * @access public - * @return object JDatabase connector object - * @since 1.5 - */ - function &getDBO() - { - return $this->_db; - } - - /** - * Method to set the database connector object - * - * @param object $db A JDatabase based object - * @return void - * @since 1.5 - */ - function setDBO(&$db) - { - $this->_db =& $db; - } - - /** - * Method to get the model name - * - * The model name by default parsed using the classname, or it can be set - * by passing a $config['name�] in the class constructor - * - * @access public - * @return string The name of the model - * @since 1.5 - */ - function getName() - { - $name = $this->_name; - - if (empty( $name )) - { - $r = null; - if (!preg_match('/Model(.*)/i', get_class($this), $r)) { - JError::raiseError (500, "JModel::getName() : Can't get or parse class name."); - } - $name = strtolower( $r[1] ); - } - - return $name; - } - - /** - * Method to get a table object, load it if necessary. - * - * @access public - * @param string The table name. Optional. - * @param string The class prefix. Optional. - * @param array Configuration array for model. Optional. - * @return object The table - * @since 1.5 - */ - function &getTable($name='', $prefix='Table', $options = array()) - { - if (empty($name)) { - $name = $this->getName(); - } - - if($table = &$this->_createTable( $name, $prefix, $options )) { - return $table; - } - - JError::raiseError( 0, 'Table ' . $name . ' not supported. File not found.' ); - $null = null; + /** + * The model (base) name + * + * @var string + * @access protected + */ + var $_name; + + /** + * Database Connector + * + * @var object + * @access protected + */ + var $_db; + + /** + * An state object + * + * @var string + * @access protected + */ + var $_state; + + /** + * Constructor + * + * @since 1.5 + */ + function __construct($config = array()) + { + //set the view name + if (empty($this->_name)) { + if (array_key_exists('name', $config)) { + $this->_name = $config['name']; + } else { + $this->_name = $this->getName(); + } + } + + //set the model state + if (array_key_exists('state', $config)) { + $this->_state = $config['state']; + } else { + $this->_state = new JObject(); + } + + //set the model dbo + if (array_key_exists('dbo', $config)) { + $this->_db = $config['dbo']; + } else { + $this->_db = &JFactory::getDBO(); + } + + // set the default view search path + if (array_key_exists('table_path', $config)) { + $this->addTablePath($config['table_path']); + } else if (defined( 'JPATH_COMPONENT_ADMINISTRATOR' )){ + $this->addTablePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'tables'); + } + } + + /** + * Returns a reference to the a Model object, always creating it + * + * @param string The model type to instantiate + * @param string Prefix for the model class name. Optional. + * @param array Configuration array for model. Optional. + * @return mixed A model object, or false on failure + * @since 1.5 + */ + public static function &getInstance($type, $prefix = '', $config = array()) + { + $type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type); + $modelClass = $prefix.ucfirst($type); + $result = false; + + if ( ! class_exists($modelClass)) { + jimport('joomla.filesystem.path'); + $path = JPath::find( + JModel::addIncludePath(), + JModel::_createFileName('model', array('name' => $type)) + ); + if ($path) { + require_once $path; + + if ( ! class_exists($modelClass)) { + JError::raiseWarning(0, 'Model class '.$modelClass.' not found in file.'); + return $result; + } + } + else return $result; + } + + $result = new $modelClass($config); + return $result; + } + + /** + * Method to set model state variables + * + * @access public + * @param string The name of the property + * @param mixed The value of the property to set + * @return mixed The previous value of the property + * @since 1.5 + */ + function setState($property, $value = null) + { + return $this->_state->set($property, $value); + } + + /** + * Method to get model state variables + * + * @access public + * @param string Optional parameter name + * @return object The property where specified, the state object where omitted + * @since 1.5 + */ + function getState($property = null) + { + return $property === null ? $this->_state : $this->_state->get($property); + } + + /** + * Method to get the database connector object + * + * @access public + * @return object JDatabase connector object + * @since 1.5 + */ + function &getDBO() + { + return $this->_db; + } + + /** + * Method to set the database connector object + * + * @param object $db A JDatabase based object + * @return void + * @since 1.5 + */ + function setDBO(&$db) + { + $this->_db =& $db; + } + + /** + * Method to get the model name + * + * The model name by default parsed using the classname, or it can be set + * by passing a $config['name�] in the class constructor + * + * @access public + * @return string The name of the model + * @since 1.5 + */ + function getName() + { + $name = $this->_name; + + if (empty($name)) { + $r = null; + if ( ! preg_match('/Model(.*)/i', get_class($this), $r)) { + JError::raiseError (500, "JModel::getName() : Can't get or parse class name."); + } + $name = strtolower( $r[1] ); + } + + return $name; + } + + /** + * Method to get a table object, load it if necessary. + * + * @access public + * @param string The table name. Optional. + * @param string The class prefix. Optional. + * @param array Configuration array for model. Optional. + * @return object The table + * @since 1.5 + */ + function &getTable($name = '', $prefix = 'Table', $options = array()) + { + if (empty($name)) { + $name = $this->getName(); + } + + if($table = &$this->_createTable($name, $prefix, $options)) { + return $table; + } + + JError::raiseError(0, 'Table ' . $name . ' not supported. File not found.'); + $null = null; return $null; - } - - /** - * Add a directory where JModel should search for models. You may - * either pass a string or an array of directories. - * - * @access public - * @param string A path to search. - * @return array An array with directory elements - * @since 1.5 - */ - function addIncludePath( $path='' ) - { - static $paths; - - if (!isset($paths)) { - $paths = array(); - } - if (!empty( $path ) && !in_array( $path, $paths )) { - jimport('joomla.filesystem.path'); - array_unshift($paths, JPath::clean( $path )); - } - return $paths; - } - - /** - * Adds to the stack of model table paths in LIFO order. - * - * @static - * @param string|array The directory (-ies) to add. - * @return void - */ - function addTablePath($path) - { - jimport('joomla.database.table'); - JTable::addIncludePath($path); - } - - /** - * Returns an object list - * - * @param string The query - * @param int Offset - * @param int The number of records - * @return array - * @access protected - * @since 1.5 - */ - function &_getList( $query, $limitstart=0, $limit=0 ) - { - $this->_db->setQuery( $query, $limitstart, $limit ); - $result = $this->_db->loadObjectList(); - - return $result; - } - - /** - * Returns a record count for the query - * - * @param string The query - * @return int - * @access protected - * @since 1.5 - */ - function _getListCount( $query ) - { - $this->_db->setQuery( $query ); - $this->_db->query(); - - return $this->_db->getNumRows(); - } - - /** - * Method to load and return a model object. - * - * @access private - * @param string The name of the view - * @param string The class prefix. Optional. - * @return mixed Model object or boolean false if failed - * @since 1.5 - */ - function &_createTable( $name, $prefix = 'Table', $config = array()) - { - $result = null; - - // Clean the model name - $name = preg_replace( '/[^A-Z0-9_]/i', '', $name ); - $prefix = preg_replace( '/[^A-Z0-9_]/i', '', $prefix ); - - //Make sure we are returning a DBO object - if (!array_key_exists('dbo', $config)) { - $config['dbo'] =& $this->getDBO();; - } - - $instance =& JTable::getInstance($name, $prefix, $config ); - return $instance; - } - - /** - * Create the filename for a resource - * - * @access private - * @param string $type The resource type to create the filename for - * @param array $parts An associative array of filename information - * @return string The filename - * @since 1.5 - */ - function _createFileName($type, $parts = array()) - { - $filename = ''; - - switch($type) - { - case 'model': - $filename = strtolower($parts['name']).'.php'; - break; - - } - return $filename; - } -} \ No newline at end of file + } + + /** + * Add a directory where JModel should search for models. You may + * either pass a string or an array of directories. + * + * @param string A path to search. + * @return array An array with directory elements + * @since 1.5 + */ + public static function addIncludePath($path = '') + { + static $paths; + + if ( ! isset($paths)) { + $paths = array(); + } + if ( ! empty( $path ) && !in_array( $path, $paths )) { + jimport('joomla.filesystem.path'); + array_unshift($paths, JPath::clean( $path )); + } + return $paths; + } + + /** + * Adds to the stack of model table paths in LIFO order. + * + * @param string|array The directory (-ies) to add. + * @return void + */ + public static function addTablePath($path) + { + jimport('joomla.database.table'); + JTable::addIncludePath($path); + } + + /** + * Returns an object list + * + * @param string The query + * @param int Offset + * @param int The number of records + * @return array + * @access protected + * @since 1.5 + */ + function &_getList($query, $limitstart = 0, $limit = 0) + { + $this->_db->setQuery($query, $limitstart, $limit); + $result = $this->_db->loadObjectList(); + + return $result; + } + + /** + * Returns a record count for the query + * + * @param string The query + * @return int + * @access protected + * @since 1.5 + */ + function _getListCount($query) + { + $this->_db->setQuery($query); + $this->_db->query(); + + return $this->_db->getNumRows(); + } + + /** + * Method to load and return a model object. + * + * @access private + * @param string The name of the view + * @param string The class prefix. Optional. + * @return mixed Model object or boolean false if failed + * @since 1.5 + */ + function &_createTable($name, $prefix = 'Table', $config = array()) + { + $result = null; + + // Clean the model name + $name = preg_replace('/[^A-Z0-9_]/i', '', $name); + $prefix = preg_replace('/[^A-Z0-9_]/i', '', $prefix); + + //Make sure we are returning a DBO object + if ( ! array_key_exists('dbo', $config)) { + $config['dbo'] =& $this->getDBO();; + } + + $instance =& JTable::getInstance($name, $prefix, $config); + return $instance; + } + + /** + * Create the filename for a resource + * + * @param string $type The resource type to create the filename for + * @param array $parts An associative array of filename information + * @return string The filename + * @since 1.5 + */ + protected static function _createFileName($type, $parts = array()) + { + $filename = ''; + + switch ($type) { + case 'model': + $filename = strtolower($parts['name']).'.php'; + break; + } + return $filename; + } +} diff --git a/vendor/joomla/libraries/joomla/application/helper.php b/vendor/joomla/libraries/joomla/application/helper.php index 5f715c9b2..f00a0ecfd 100644 --- a/vendor/joomla/libraries/joomla/application/helper.php +++ b/vendor/joomla/libraries/joomla/application/helper.php @@ -1,337 +1,303 @@ id = 0; - $obj->name = 'site'; - $obj->path = JPATH_SITE; - $clients[0] = clone($obj); - - // Administrator Client - $obj->id = 1; - $obj->name = 'administrator'; - $obj->path = JPATH_ADMINISTRATOR; - $clients[1] = clone($obj); - - // Installation Client - $obj->id = 2; - $obj->name = 'installation'; - $obj->path = JPATH_INSTALLATION; - $clients[2] = clone($obj); - - // XMLRPC Client - $obj->id = 3; - $obj->name = 'xmlrpc'; - $obj->path = JPATH_XMLRPC; - $clients[3] = clone($obj); - } - - //If no client id has been passed return the whole array - if(is_null($id)) { - return $clients; - } - - // Are we looking for client information by id or by name? - if (!$byName) - { - if (isset($clients[$id])){ - return $clients[$id]; - } - } - else - { - foreach ($clients as $client) - { - if ($client->name == strtolower($id)) { - return $client; - } - } - } - $null = null; - return $null; - } - - /** - * Get a path - * - * @access public - * @param string $varname - * @param string $user_option - * @return string The requested path - * @since 1.0 - */ - function getPath( $varname, $user_option=null ) - { - // check needed for handling of custom/new module xml file loading - $check = ( ( $varname == 'mod0_xml' ) || ( $varname == 'mod1_xml' ) ); - - if ( !$user_option && !$check ) { - $user_option = JRequest::getCmd('option'); - } else { - $user_option = JFilterInput::clean($user_option, 'path'); - } - - $result = null; - $name = substr( $user_option, 4 ); - - switch ($varname) { - case 'front': - $result = JApplicationHelper::_checkPath( DS.'components'.DS. $user_option .DS. $name .'.php', 0 ); - break; - - case 'html': - case 'front_html': - if ( !( $result = JApplicationHelper::_checkPath( DS.'templates'.DS. JApplication::getTemplate() .DS.'components'.DS. $name .'.html.php', 0 ) ) ) { - $result = JApplicationHelper::_checkPath( DS.'components'.DS. $user_option .DS. $name .'.html.php', 0 ); - } - break; - - case 'toolbar': - $result = JApplicationHelper::_checkPath( DS.'components'.DS. $user_option .DS.'toolbar.'. $name .'.php', -1 ); - break; - - case 'toolbar_html': - $result = JApplicationHelper::_checkPath( DS.'components'.DS. $user_option .DS.'toolbar.'. $name .'.html.php', -1 ); - break; - - case 'toolbar_default': - case 'toolbar_front': - $result = JApplicationHelper::_checkPath( DS.'includes'.DS.'HTML_toolbar.php', 0 ); - break; - - case 'admin': - $path = DS.'components'.DS. $user_option .DS.'admin.'. $name .'.php'; - $result = JApplicationHelper::_checkPath( $path, -1 ); - if ($result == null) { - $path = DS.'components'.DS. $user_option .DS. $name .'.php'; - $result = JApplicationHelper::_checkPath( $path, -1 ); - } - break; - - case 'admin_html': - $path = DS.'components'.DS. $user_option .DS.'admin.'. $name .'.html.php'; - $result = JApplicationHelper::_checkPath( $path, -1 ); - break; - - case 'admin_functions': - $path = DS.'components'.DS. $user_option .DS. $name .'.functions.php'; - $result = JApplicationHelper::_checkPath( $path, -1 ); - break; - - case 'class': - if ( !( $result = JApplicationHelper::_checkPath( DS.'components'.DS. $user_option .DS. $name .'.class.php' ) ) ) { - $result = JApplicationHelper::_checkPath( DS.'includes'.DS. $name .'.php' ); - } - break; - - case 'helper': - $path = DS.'components'.DS. $user_option .DS. $name .'.helper.php'; - $result = JApplicationHelper::_checkPath( $path ); - break; - - case 'com_xml': - $path = DS.'components'.DS. $user_option .DS. $name .'.xml'; - $result = JApplicationHelper::_checkPath( $path, 1 ); - break; - - case 'mod0_xml': - $path = DS.'modules'.DS. $user_option .DS. $user_option. '.xml'; - $result = JApplicationHelper::_checkPath( $path ); - break; - - case 'mod1_xml': - // admin modules - $path = DS.'modules'.DS. $user_option .DS. $user_option. '.xml'; - $result = JApplicationHelper::_checkPath( $path, -1 ); - break; - - case 'bot_xml': - // legacy value - case 'plg_xml': - // Site plugins - $path = DS.'plugins'.DS. $user_option .'.xml'; - $result = JApplicationHelper::_checkPath( $path, 0 ); - break; - - case 'menu_xml': - $path = DS.'components'.DS.'com_menus'.DS. $user_option .DS. $user_option .'.xml'; - $result = JApplicationHelper::_checkPath( $path, -1 ); - break; - } - - return $result; - } - - function parseXMLInstallFile($path) - { - // Read the file to see if it's a valid component XML file - $xml = & JFactory::getXMLParser('Simple'); - - if (!$xml->loadFile($path)) { - unset($xml); - return false; - } - - /* - * Check for a valid XML root tag. - * - * Should be 'install', but for backward compatability we will accept 'mosinstall'. - */ - if ( !is_object($xml->document) || ($xml->document->name() != 'install' && $xml->document->name() != 'mosinstall')) { - unset($xml); - return false; - } - - $data = array(); - $data['legacy'] = $xml->document->name() == 'mosinstall'; - - $element = & $xml->document->name[0]; - $data['name'] = $element ? $element->data() : ''; - $data['type'] = $element ? $xml->document->attributes("type") : ''; - - $element = & $xml->document->creationDate[0]; - $data['creationdate'] = $element ? $element->data() : JText::_('Unknown'); - - $element = & $xml->document->author[0]; - $data['author'] = $element ? $element->data() : JText::_('Unknown'); - - $element = & $xml->document->copyright[0]; - $data['copyright'] = $element ? $element->data() : ''; - - $element = & $xml->document->authorEmail[0]; - $data['authorEmail'] = $element ? $element->data() : ''; - - $element = & $xml->document->authorUrl[0]; - $data['authorUrl'] = $element ? $element->data() : ''; - - $element = & $xml->document->version[0]; - $data['version'] = $element ? $element->data() : ''; - - $element = & $xml->document->description[0]; - $data['description'] = $element ? $element->data() : ''; - - $element = & $xml->document->group[0]; - $data['group'] = $element ? $element->data() : ''; - - return $data; - } - - function parseXMLLangMetaFile($path) - { - // Read the file to see if it's a valid component XML file - $xml = & JFactory::getXMLParser('Simple'); - - if (!$xml->loadFile($path)) { - unset($xml); - return false; - } - - /* - * Check for a valid XML root tag. - * - * Should be 'langMetaData'. - */ - if ($xml->document->name() != 'metafile') { - unset($xml); - return false; - } - - $data = array(); - - $element = & $xml->document->name[0]; - $data['name'] = $element ? $element->data() : ''; - $data['type'] = $element ? $xml->document->attributes("type") : ''; - - $element = & $xml->document->creationDate[0]; - $data['creationdate'] = $element ? $element->data() : JText::_('Unknown'); - - $element = & $xml->document->author[0]; - - $data['author'] = $element ? $element->data() : JText::_('Unknown'); - - $element = & $xml->document->copyright[0]; - $data['copyright'] = $element ? $element->data() : ''; - - $element = & $xml->document->authorEmail[0]; - $data['authorEmail'] = $element ? $element->data() : ''; - - $element = & $xml->document->authorUrl[0]; - $data['authorUrl'] = $element ? $element->data() : ''; - - $element = & $xml->document->version[0]; - $data['version'] = $element ? $element->data() : ''; - - $element = & $xml->document->description[0]; - $data['description'] = $element ? $element->data() : ''; - - $element = & $xml->document->group[0]; - $data['group'] = $element ? $element->group() : ''; - return $data; - } - - /** - * Tries to find a file in the administrator or site areas - * - * @access private - * @param string $parth A file name - * @param integer $checkAdmin 0 to check site only, 1 to check site and admin, -1 to check admin only - * @since 1.5 - */ - function _checkPath( $path, $checkAdmin=1 ) - { - $file = JPATH_SITE . $path; - if ($checkAdmin > -1 && file_exists( $file )) { - return $file; - } else if ($checkAdmin != 0) { - $file = JPATH_ADMINISTRATOR . $path; - if (file_exists( $file )) { - return $file; - } - } - - return null; - } + /** + * Gets information on a specific client id. This method will be useful in + * future versions when we start mapping applications in the database. + * + * @param int $id A client identifier + * @param boolean $byName If True, find the client by it's name + * @return mixed Object describing the client or false if not known + * @since 1.5 + */ + public static function &getClientInfo($id = null, $byName = false) + { + static $clients; + + // Only create the array if it does not exist + if ( ! is_array($clients)) { + $obj = new stdClass(); + + // Site Client + $obj->id = 0; + $obj->name = 'site'; + $obj->path = JPATH_SITE; + $clients[0] = clone($obj); + + // Administrator Client + $obj->id = 1; + $obj->name = 'administrator'; + $obj->path = JPATH_ADMINISTRATOR; + $clients[1] = clone($obj); + + // Installation Client + $obj->id = 2; + $obj->name = 'installation'; + $obj->path = JPATH_INSTALLATION; + $clients[2] = clone($obj); + + // XMLRPC Client + $obj->id = 3; + $obj->name = 'xmlrpc'; + $obj->path = JPATH_XMLRPC; + $clients[3] = clone($obj); + } + + //If no client id has been passed return the whole array + if (is_null($id)) { + return $clients; + } + + // Are we looking for client information by id or by name? + if ( ! $byName) { + if (isset($clients[$id])){ + return $clients[$id]; + } + }else { + foreach ($clients as $client) { + if ($client->name == strtolower($id)) { + return $client; + } + } + } + $null = null; + return $null; + } + + /** + * Get a path + * + * @param string $varname + * @param string $user_option + * @return string The requested path + * @since 1.0 + */ + public static function getPath($varname, $user_option = null) + { + // check needed for handling of custom/new module xml file loading + $check = ($varname == 'mod0_xml' || $varname == 'mod1_xml'); + + if ( ! $user_option && ! $check) { + $user_option = JRequest::getCmd('option'); + } else { + $user_option = JFilterInput::getInstance()->clean($user_option, 'path'); + } + + $result = null; + $name = substr($user_option, 4); + + switch ($varname) { + case 'front': + $result = JApplicationHelper::_checkPath(DS.'components'.DS.$user_option.DS.$name.'.php', 0); + break; + case 'html': + case 'front_html': + if ( ! ($result = JApplicationHelper::_checkPath(DS.'templates'.DS.JApplication::getTemplate().DS.'components'.DS.$name.'.html.php', 0))) { + $result = JApplicationHelper::_checkPath(DS.'components'.DS.$user_option.DS.$name.'.html.php', 0); + } + break; + case 'toolbar': + $result = JApplicationHelper::_checkPath(DS.'components'.DS.$user_option .DS.'toolbar.'.$name.'.php', -1); + break; + case 'toolbar_html': + $result = JApplicationHelper::_checkPath(DS.'components'.DS.$user_option .DS.'toolbar.'.$name.'.html.php', -1); + break; + case 'toolbar_default': + case 'toolbar_front': + $result = JApplicationHelper::_checkPath(DS.'includes'.DS.'HTML_toolbar.php', 0 ); + break; + case 'admin': + $path = DS.'components'.DS.$user_option .DS.'admin.'.$name.'.php'; + $result = JApplicationHelper::_checkPath($path, -1); + if ($result == null) { + $path = DS.'components'.DS.$user_option.DS.$name.'.php'; + $result = JApplicationHelper::_checkPath($path, -1); + } + break; + case 'admin_html': + $path = DS.'components'.DS. $user_option.DS.'admin.'.$name.'.html.php'; + $result = JApplicationHelper::_checkPath($path, -1); + break; + case 'admin_functions': + $path = DS.'components'.DS. $user_option.DS.$name .'.functions.php'; + $result = JApplicationHelper::_checkPath($path, -1); + break; + case 'class': + if ( ! ($result = JApplicationHelper::_checkPath(DS.'components'.DS.$user_option.DS.$name .'.class.php'))) { + $result = JApplicationHelper::_checkPath(DS.'includes'.DS.$name.'.php'); + } + break; + case 'helper': + $path = DS.'components'.DS.$user_option.DS.$name.'.helper.php'; + $result = JApplicationHelper::_checkPath($path); + break; + case 'com_xml': + $path = DS.'components'.DS.$user_option.DS.$name.'.xml'; + $result = JApplicationHelper::_checkPath($path, 1); + break; + case 'mod0_xml': + $path = DS.'modules'.DS. $user_option.DS.$user_option.'.xml'; + $result = JApplicationHelper::_checkPath($path); + break; + case 'mod1_xml': + // admin modules + $path = DS.'modules'.DS.$user_option.DS.$user_option.'.xml'; + $result = JApplicationHelper::_checkPath($path, -1); + break; + case 'bot_xml': + // legacy value + case 'plg_xml': + // Site plugins + $path = DS.'plugins'.DS.$user_option.'.xml'; + $result = JApplicationHelper::_checkPath($path, 0); + break; + case 'menu_xml': + $path = DS.'components'.DS.'com_menus'.DS.$user_option.DS.$user_option.'.xml'; + $result = JApplicationHelper::_checkPath($path, -1); + break; + } + + return $result; + } + + public static function parseXMLInstallFile($path) + { + // Read the file to see if it's a valid component XML file + $xml =& JFactory::getXMLParser('Simple'); + + if ( ! $xml->loadFile($path)) { + unset($xml); + return false; + } + + /* + * Check for a valid XML root tag. + * + * Should be 'install', but for backward compatability we will accept 'mosinstall'. + */ + if ( ! is_object($xml->document) || ($xml->document->name() != 'install' && $xml->document->name() != 'mosinstall')) { + unset($xml); + return false; + } + + $data = array(); + $data['legacy'] = $xml->document->name() == 'mosinstall'; + + $element =& $xml->document->name[0]; + $data['name'] = $element ? $element->data() : ''; + $data['type'] = $element ? $xml->document->attributes("type") : ''; + + $element =& $xml->document->creationDate[0]; + $data['creationdate'] = $element ? $element->data() : JText::_('Unknown'); + + $element =& $xml->document->author[0]; + $data['author'] = $element ? $element->data() : JText::_('Unknown'); + + $element =& $xml->document->copyright[0]; + $data['copyright'] = $element ? $element->data() : ''; + + $element =& $xml->document->authorEmail[0]; + $data['authorEmail'] = $element ? $element->data() : ''; + + $element =& $xml->document->authorUrl[0]; + $data['authorUrl'] = $element ? $element->data() : ''; + + $element =& $xml->document->version[0]; + $data['version'] = $element ? $element->data() : ''; + + $element =& $xml->document->description[0]; + $data['description'] = $element ? $element->data() : ''; + + $element =& $xml->document->group[0]; + $data['group'] = $element ? $element->data() : ''; + + return $data; + } + + public static function parseXMLLangMetaFile($path) + { + // Read the file to see if it's a valid component XML file + $xml =& JFactory::getXMLParser('Simple'); + + if ( ! $xml->loadFile($path)) { + unset($xml); + return false; + } + + /* + * Check for a valid XML root tag. + * + * Should be 'langMetaData'. + */ + if ($xml->document->name() != 'metafile') { + unset($xml); + return false; + } + + $data = array(); + + $element =& $xml->document->name[0]; + $data['name'] = $element ? $element->data() : ''; + $data['type'] = $element ? $xml->document->attributes("type") : ''; + + $element =& $xml->document->creationDate[0]; + $data['creationdate'] = $element ? $element->data() : JText::_('Unknown'); + + $element =& $xml->document->author[0]; + + $data['author'] = $element ? $element->data() : JText::_('Unknown'); + + $element =& $xml->document->copyright[0]; + $data['copyright'] = $element ? $element->data() : ''; + + $element =& $xml->document->authorEmail[0]; + $data['authorEmail'] = $element ? $element->data() : ''; + + $element =& $xml->document->authorUrl[0]; + $data['authorUrl'] = $element ? $element->data() : ''; + + $element =& $xml->document->version[0]; + $data['version'] = $element ? $element->data() : ''; + + $element =& $xml->document->description[0]; + $data['description'] = $element ? $element->data() : ''; + + $element =& $xml->document->group[0]; + $data['group'] = $element ? $element->group() : ''; + return $data; + } + + /** + * Tries to find a file in the administrator or site areas + * + * @param string $parth A file name + * @param integer $checkAdmin 0 to check site only, 1 to check site and admin, -1 to check admin only + * @since 1.5 + */ + protected static function _checkPath($path, $checkAdmin = 1) + { + $file = JPATH_SITE . $path; + if ($checkAdmin > -1 && file_exists( $file )) { + return $file; + } elseif ($checkAdmin != 0) { + $file = JPATH_ADMINISTRATOR . $path; + if (file_exists( $file )) { + return $file; + } + } + + return null; + } } diff --git a/vendor/joomla/libraries/joomla/application/menu.php b/vendor/joomla/libraries/joomla/application/menu.php index ea42ea22d..6c7a6024c 100644 --- a/vendor/joomla/libraries/joomla/application/menu.php +++ b/vendor/joomla/libraries/joomla/application/menu.php @@ -1,287 +1,262 @@ load(); //load the menu items - - foreach ($this->_items as $k => $item) - { - if ($item->home) { - $this->_default = $item->id; - } - } - } - - /** - * Returns a reference to a JMenu object - * - * This method must be invoked as: - *
  $menu = &JSite::getMenu();
- * - * @access public - * @param string $client The name of the client - * @param array $options An associative array of options - * @return JMenu A menu object. - * @since 1.5 - */ - function &getInstance($client, $options = array()) - { - static $instances; - - if (!isset( $instances )) { - $instances = array(); - } - - if (empty($instances[$client])) - { - //Load the router object - $info =& JApplicationHelper::getClientInfo($client, true); - - $path = $info->path.DS.'includes'.DS.'menu.php'; - if(file_exists($path)) - { - require_once $path; - - // Create a JPathway object - $classname = 'JMenu'.ucfirst($client); - $instance = new $classname($options); - } - else - { - //$error = JError::raiseError( 500, 'Unable to load menu: '.$client); - $error = null; //Jinx : need to fix this - return $error; - } - - $instances[$client] = & $instance; - } - - return $instances[$client]; - } - - /** - * Get menu item by id - * - * @access public - * @param int The item id - * @return mixed The item object, or null if not found - */ - function &getItem($id) - { - $result = null; - if (isset($this->_items[$id])) { - $result = &$this->_items[$id]; - } - - return $result; - } - - /** - * Set the default item by id - * - * @param int The item id - * @access public - * @return True, if succesfull - */ - function setDefault($id) - { - if(isset($this->_items[$id])) { - $this->_default = $id; - return true; - } - - return false; - } - - /** - * Get menu item by id - * - * @access public - * - * @return object The item object - */ - function &getDefault() - { - $item =& $this->_items[$this->_default]; - return $item; - } - - /** - * Set the default item by id - * - * @param int The item id - * @access public - * @return If successfull the active item, otherwise null - */ - function &setActive($id) - { - if(isset($this->_items[$id])) - { - $this->_active = $id; - $result = &$this->_items[$id]; - return $result; - } - - $result = null; - return $result; - } - - /** - * Get menu item by id - * - * @access public - * - * @return object The item object - */ - function &getActive() - { - if ($this->_active) { - $item =& $this->_items[$this->_active]; - return $item; - } - - $result = null; - return $result; - } - - /** - * Gets menu items by attribute - * - * @access public - * @param string The field name - * @param string The value of the field - * @param boolean If true, only returns the first item found - * @return array - */ - function getItems($attribute, $value, $firstonly = false) - { - $items = null; - - foreach ($this->_items as $item) - { - if ( ! is_object($item) ) - continue; - - if ($item->$attribute == $value) - { - if($firstonly) { - return $item; - } - - $items[] = $item; - } - } - - return $items; - } - - /** - * Gets the parameter object for a certain menu item - * - * @access public - * @param int The item id - * @return object A JParameter object - */ - function &getParams($id) - { - $ini = ''; - if ($menu =& $this->getItem($id)) { - $ini = $menu->params; - } - $result = new JParameter( $ini ); - - return $result; - } - - /** - * Getter for the menu array - * - * @access public - * @return array - */ - function getMenu() { - return $this->_items; - } - - /** - * Method to check JMenu object authorization against an access control - * object and optionally an access extension object - * - * @access public - * @param integer $id The menu id - * @param integer $accessid The users access identifier - * @return boolean True if authorized - */ - function authorize($id, $accessid = 0) - { - $menu =& $this->getItem($id); - return ((isset($menu->access) ? $menu->access : 0) <= $accessid); - } - - /** - * Loads the menu items - * - * @abstract - * @access public - * @return array - */ - function load() - { - return array(); - } -} \ No newline at end of file + /** + * Array to hold the menu items + * + * @access private + * @param array + */ + var $_items = array (); + + /** + * Identifier of the default menu item + * + * @access private + * @param integer + */ + var $_default = 0; + + /** + * Identifier of the active menu item + * + * @access private + * @param integer + */ + var $_active = 0; + + + /** + * Class constructor + * + * @access public + * @return boolean True on success + */ + function __construct($options = array()) + { + $this->load(); //load the menu items + + foreach ($this->_items as $k => $item) { + if ($item->home) { + $this->_default = $item->id; + } + } + } + + /** + * Returns a reference to a JMenu object + * + * This method must be invoked as: + *
  $menu = &JSite::getMenu();
+ * + * @param string $client The name of the client + * @param array $options An associative array of options + * @return JMenu A menu object. + * @since 1.5 + */ + public static function &getInstance($client, $options = array()) + { + static $instances; + + if ( ! isset( $instances )) { + $instances = array(); + } + + if (empty($instances[$client])) { + //Load the router object + $info =& JApplicationHelper::getClientInfo($client, true); + $path = $info->path.DS.'includes'.DS.'menu.php'; + if( file_exists($path)) { + require_once $path; + + // Create a JPathway object + $classname = 'JMenu'.ucfirst($client); + $instance = new $classname($options); + } else { + //$error = JError::raiseError( 500, 'Unable to load menu: '.$client); + $error = null; //Jinx : need to fix this + return $error; + } + + $instances[$client] = & $instance; + } + + return $instances[$client]; + } + + /** + * Get menu item by id + * + * @access public + * @param int The item id + * @return mixed The item object, or null if not found + */ + function &getItem($id) + { + $result = null; + if (isset($this->_items[$id])) { + $result = &$this->_items[$id]; + } + + return $result; + } + + /** + * Set the default item by id + * + * @param int The item id + * @access public + * @return True, if succesfull + */ + function setDefault($id) + { + if (isset($this->_items[$id])) { + $this->_default = $id; + return true; + } + + return false; + } + + /** + * Get menu item by id + * + * @access public + * @return object The item object + */ + function &getDefault() + { + $item =& $this->_items[$this->_default]; + return $item; + } + + /** + * Set the default item by id + * + * @param int The item id + * @access public + * @return If successfull the active item, otherwise null + */ + function &setActive($id) + { + if (isset($this->_items[$id])) { + $this->_active = $id; + $result = &$this->_items[$id]; + return $result; + } + + $result = null; + return $result; + } + + /** + * Get menu item by id + * + * @access public + * @return object The item object + */ + function &getActive() { + if ($this->_active) { + $item =& $this->_items[$this->_active]; + return $item; + } + + $result = null; + return $result; + } + + /** + * Gets menu items by attribute + * + * @access public + * @param string The field name + * @param string The value of the field + * @param boolean If true, only returns the first item found + * @return array + */ + function getItems($attribute, $value, $firstonly = false) + { + $items = null; + + foreach ($this->_items as $item) { + if ( ! is_object($item)) + continue; + + if ($item->$attribute == $value) { + if($firstonly) { + return $item; + } + $items[] = $item; + } + } + + return $items; + } + + /** + * Gets the parameter object for a certain menu item + * + * @access public + * @param int The item id + * @return object A JParameter object + */ + function &getParams($id) + { + $ini = ''; + if ($menu =& $this->getItem($id)) { + $ini = $menu->params; + } + $result = new JParameter( $ini ); + + return $result; + } + + /** + * Getter for the menu array + * + * @access public + * @return array + */ + function getMenu() { + return $this->_items; + } + + /** + * Method to check JMenu object authorization against an access control + * object and optionally an access extension object + * + * @access public + * @param integer $id The menu id + * @param integer $accessid The users access identifier + * @return boolean True if authorized + */ + function authorize($id, $accessid = 0) + { + $menu =& $this->getItem($id); + return ((isset($menu->access) ? $menu->access : 0) <= $accessid); + } + + /** + * Loads the menu items + * + * @abstract + * @access public + * @return array + */ + function load() + { + return array(); + } +} diff --git a/vendor/joomla/libraries/joomla/cache/cache.php b/vendor/joomla/libraries/joomla/cache/cache.php index f0f153eb1..25949607f 100644 --- a/vendor/joomla/libraries/joomla/cache/cache.php +++ b/vendor/joomla/libraries/joomla/cache/cache.php @@ -1,17 +1,4 @@ _options =& $options; - - // Get the default group and caching - if(isset($options['language'])) { - $this->_options['language'] = $options['language']; - } else { - $options['language'] = 'en-GB'; - } - - if(isset($options['cachebase'])) { - $this->_options['cachebase'] = $options['cachebase']; - } else { - $this->_options['cachebase'] = JPATH_ROOT.DS.'cache'; - } - - if(isset($options['defaultgroup'])) { - $this->_options['defaultgroup'] = $options['defaultgroup']; - } else { - $this->_options['defaultgroup'] = 'default'; - } - - if(isset($options['caching'])) { - $this->_options['caching'] = $options['caching']; - } else { - $this->_options['caching'] = true; - } - - if( isset($options['storage'])) { - $this->_options['storage'] = $options['storage']; - } else { - $this->_options['storage'] = 'file'; - } - - //Fix to detect if template positions are enabled... - if(JRequest::getCMD('tpl',0)) { - $this->_options['caching'] = false; - } - } - - /** - * Returns a reference to a cache adapter object, always creating it - * - * @static - * @param string $type The cache object type to instantiate - * @return object A JCache object - * @since 1.5 - */ - function &getInstance($type = 'output', $options = array()) - { - $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type)); - - $class = 'JCache'.ucfirst($type); - - if(!class_exists($class)) - { - $path = dirname(__FILE__).DS.'handler'.DS.$type.'.php'; - - if (file_exists($path)) { - require_once($path); - } else { - JError::raiseError(500, 'Unable to load Cache Handler: '.$type); - } - } - - $instance = new $class($options); - - return $instance; - } - - /** - * Get the storage handlers - * - * @access public - * @return array An array of available storage handlers - */ - function getStores() - { - jimport('joomla.filesystem.folder'); - $handlers = JFolder::files(dirname(__FILE__).DS.'storage', '.php$'); - - $names = array(); - foreach($handlers as $handler) - { - $name = substr($handler, 0, strrpos($handler, '.')); - $class = 'JCacheStorage'.$name; - - if(!class_exists($class)) { - require_once(dirname(__FILE__).DS.'storage'.DS.$name.'.php'); - } - - if(call_user_func_array( array( trim($class), 'test' ), array())) { - $names[] = $name; - } - } - - return $names; - } - - /** - * Set caching enabled state - * - * @access public - * @param boolean $enabled True to enable caching - * @return void - * @since 1.5 - */ - function setCaching($enabled) - { - $this->_options['caching'] = $enabled; - } - - /** - * Set cache lifetime - * - * @access public - * @param int $lt Cache lifetime - * @return void - * @since 1.5 - */ - function setLifeTime($lt) - { - $this->_options['lifetime'] = $lt; - } - - /** - * Set cache validation - * - * @access public - * @return void - * @since 1.5 - */ - function setCacheValidation() - { - // Deprecated - } - - /** - * Get cached data by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group=null) - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler) && $this->_options['caching']) { - return $handler->get($id, $group, (isset($this->_options['checkTime']))? $this->_options['checkTime'] : true); - } - return false; - } - - /** - * Store the cached data by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param mixed $data The data to store - * @return boolean True if cache stored - * @since 1.5 - */ - function store($data, $id, $group=null) - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler and store the cached data - $handler =& $this->_getStorage(); - if (!JError::isError($handler) && $this->_options['caching']) { - return $handler->store($id, $group, $data); - } - return false; - } - - /** - * Remove a cached data entry by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group=null) - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler)) { - return $handler->remove($id, $group); - } - return false; - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group=null, $mode='group') - { - // Get the default group - $group = ($group) ? $group : $this->_options['defaultgroup']; - - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler)) { - return $handler->clean($group, $mode); - } - return false; - } - - /** - * Garbage collect expired cache data - * - * @access public - * @return boolean True on success, false otherwise. - * @since 1.5 - */ - function gc() - { - // Get the storage handler - $handler =& $this->_getStorage(); - if (!JError::isError($handler)) { - return $handler->gc(); - } - return false; - } - - /** - * Get the cache storage handler - * - * @access protected - * @return object A JCacheStorage object - * @since 1.5 - */ - function &_getStorage() - { - if (is_a($this->_handler, 'JCacheStorage')) { - return $this->_handler; - } - - $this->_handler =& JCacheStorage::getInstance($this->_options['storage'], $this->_options); - return $this->_handler; - } + /** + * Storage Handler + * + * @access private + * @var object + */ + var $_handler; + + /** + * Cache Options + * + * @access private + * @var array + */ + var $_options; + + /** + * Constructor + * + * @access protected + * @param array $options options + */ + function __construct($options) + { + $this->_options =& $options; + + // Get the default group and caching + if(isset($options['language'])) { + $this->_options['language'] = $options['language']; + } else { + $options['language'] = 'en-GB'; + } + + if(isset($options['cachebase'])) { + $this->_options['cachebase'] = $options['cachebase']; + } else { + $this->_options['cachebase'] = JPATH_ROOT.DS.'cache'; + } + + if(isset($options['defaultgroup'])) { + $this->_options['defaultgroup'] = $options['defaultgroup']; + } else { + $this->_options['defaultgroup'] = 'default'; + } + + if(isset($options['caching'])) { + $this->_options['caching'] = $options['caching']; + } else { + $this->_options['caching'] = true; + } + + if( isset($options['storage'])) { + $this->_options['storage'] = $options['storage']; + } else { + $this->_options['storage'] = 'file'; + } + + //Fix to detect if template positions are enabled... + if(JRequest::getCMD('tpl',0)) { + $this->_options['caching'] = false; + } + } + + /** + * Returns a reference to a cache adapter object, always creating it + * + * @param string $type The cache object type to instantiate + * @return object A JCache object + * @since 1.5 + */ + public static function &getInstance($type = 'output', $options = array()) + { + $type = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $type)); + $class = 'JCache'.ucfirst($type); + + if( ! class_exists($class)) { + $path = dirname(__FILE__).DS.'handler'.DS.$type.'.php'; + + if (file_exists($path)) { + require_once($path); + } else { + JError::raiseError(500, 'Unable to load Cache Handler: '.$type); + } + } + + $instance = new $class($options); + + return $instance; + } + + /** + * Get the storage handlers + * + * @access public + * @return array An array of available storage handlers + */ + public static function getStores() + { + jimport('joomla.filesystem.folder'); + $handlers = JFolder::files(dirname(__FILE__).DS.'storage', '.php$'); + + $names = array(); + foreach($handlers as $handler) { + $name = substr($handler, 0, strrpos($handler, '.')); + $class = 'JCacheStorage'.$name; + + if( ! class_exists($class)) { + require_once(dirname(__FILE__).DS.'storage'.DS.$name.'.php'); + } + + if(call_user_func_array( array( trim($class), 'test' ), array())) { + $names[] = $name; + } + } + + return $names; + } + + /** + * Set caching enabled state + * + * @access public + * @param boolean $enabled True to enable caching + * @return void + * @since 1.5 + */ + function setCaching($enabled) + { + $this->_options['caching'] = $enabled; + } + + /** + * Set cache lifetime + * + * @access public + * @param int $lt Cache lifetime + * @return void + * @since 1.5 + */ + function setLifeTime($lt) + { + $this->_options['lifetime'] = $lt; + } + + /** + * Set cache validation + * + * @access public + * @return void + * @since 1.5 + */ + function setCacheValidation() + { + // Deprecated + } + + /** + * Get cached data by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null) + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler) && $this->_options['caching']) { + return $handler->get($id, $group, (isset($this->_options['checkTime']))? $this->_options['checkTime'] : true); + } + return false; + } + + /** + * Store the cached data by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param mixed $data The data to store + * @return boolean True if cache stored + * @since 1.5 + */ + function store($data, $id, $group = null) + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler and store the cached data + $handler =& $this->_getStorage(); + if (!JError::isError($handler) && $this->_options['caching']) { + return $handler->store($id, $group, $data); + } + return false; + } + + /** + * Remove a cached data entry by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group=null) + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler)) { + return $handler->remove($id, $group); + } + return false; + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group = null, $mode = 'group') + { + // Get the default group + $group = $group ? $group : $this->_options['defaultgroup']; + + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler)) { + return $handler->clean($group, $mode); + } + return false; + } + + /** + * Garbage collect expired cache data + * + * @access public + * @return boolean True on success, false otherwise. + * @since 1.5 + */ + function gc() + { + // Get the storage handler + $handler =& $this->_getStorage(); + if ( ! JError::isError($handler)) { + return $handler->gc(); + } + return false; + } + + /** + * Get the cache storage handler + * + * @access protected + * @return object A JCacheStorage object + * @since 1.5 + */ + function &_getStorage() + { + if (is_a($this->_handler, 'JCacheStorage')) { + return $this->_handler; + } + + $this->_handler =& JCacheStorage::getInstance($this->_options['storage'], $this->_options); + return $this->_handler; + } } diff --git a/vendor/joomla/libraries/joomla/cache/handler/callback.php b/vendor/joomla/libraries/joomla/cache/handler/callback.php index 88f7dbe76..59a9bc318 100644 --- a/vendor/joomla/libraries/joomla/cache/handler/callback.php +++ b/vendor/joomla/libraries/joomla/cache/handler/callback.php @@ -1,133 +1,121 @@ [recommended] - * - Function name as a string eg. 'foo' for function foo() - * - Static method name as a string eg. 'MyClass::myMethod' for method myMethod() of class MyClass - * - * @access public - * @return mixed Result of the callback - * @since 1.5 - */ - function call() - { - // Get callback and arguments - $args = func_get_args(); - $callback = array_shift($args); - - return $this->get( $callback, $args ); - } - - /** - * Executes a cacheable callback if not found in cache else returns cached output and result - * - * @access public - * @param mixed Callback or string shorthand for a callback - * @param array Callback arguments - * @return mixed Result of the callback - * @since 1.5 - */ - function get( $callback, $args, $id=false ) - { - // Normalize callback - if (is_array( $callback ) || $callback instanceof Closure) { - // We have a standard php callback array -- do nothing - } elseif (strstr( $callback, '::' )) { - // This is shorthand for a static method callback classname::methodname - list( $class, $method ) = explode( '::', $callback ); - $callback = array( trim($class), trim($method) ); - } elseif (strstr( $callback, '->' )) { - /* - * This is a really not so smart way of doing this... we provide this for backward compatability but this - * WILL!!! disappear in a future version. If you are using this syntax change your code to use the standard - * PHP callback array syntax: - * - * We have to use some silly global notation to pull it off and this is very unreliable - */ - list( $object_123456789, $method ) = explode('->', $callback); - global $$object_123456789; - $callback = array( $$object_123456789, $method ); - } else { - // We have just a standard function -- do nothing - } - - if (!$id) { - // Generate an ID - $id = $this->_makeId($callback, $args); - } - - // Get the storage handler and get callback cache data by id and group - $data = parent::get($id); - if ($data !== false) { - $cached = unserialize( $data ); - $output = $cached['output']; - $result = $cached['result']; - } else { - ob_start(); - ob_implicit_flush( false ); - - $result = call_user_func_array($callback, $args); - $output = ob_get_contents(); - - ob_end_clean(); - - $cached = array(); - $cached['output'] = $output; - $cached['result'] = $result; - // Store the cache data - $this->store(serialize($cached), $id); - } - - echo $output; - return $result; - } + /** + * Executes a cacheable callback if not found in cache else returns cached output and result + * + * Since arguments to this function are read with func_get_args you can pass any number of arguments to this method + * as long as the first argument passed is the callback definition. + * + * The callback definition can be in several forms: + * - Standard PHP Callback array [recommended] + * - Function name as a string eg. 'foo' for function foo() + * - Static method name as a string eg. 'MyClass::myMethod' for method myMethod() of class MyClass + * + * @access public + * @return mixed Result of the callback + * @since 1.5 + */ + function call() + { + // Get callback and arguments + $args = func_get_args(); + $callback = array_shift($args); + + return $this->get( $callback, $args ); + } - /** - * Generate a callback cache id - * - * @access private - * @param callback $callback Callback to cache - * @param array $args Arguments to the callback method to cache - * @return string MD5 Hash : function cache id - * @since 1.5 - */ - function _makeId($callback, $args) - { - if(is_array($callback) && is_object($callback[0])) { - $vars = get_object_vars($callback[0]); - $vars[] = strtolower(get_class($callback[0])); - $callback[0] = $vars; - } - return md5(serialize(array($callback, $args))); - } + /** + * Executes a cacheable callback if not found in cache else returns cached output and result + * + * @access public + * @param mixed Callback or string shorthand for a callback + * @param array Callback arguments + * @return mixed Result of the callback + * @since 1.5 + */ + function get($callback, $args = null, $id = false) + { + // Normalize callback + if (is_array( $callback ) || $callback instanceof Closure) { + // We have a standard php callback array -- do nothing + } elseif (strstr( $callback, '::' )) { + // This is shorthand for a static method callback classname::methodname + list( $class, $method ) = explode( '::', $callback ); + $callback = array( trim($class), trim($method) ); + } elseif (strstr( $callback, '->' )) { + /* + * This is a really not so smart way of doing this... we provide this for backward compatability but this + * WILL!!! disappear in a future version. If you are using this syntax change your code to use the standard + * PHP callback array syntax: + * + * We have to use some silly global notation to pull it off and this is very unreliable + */ + list( $object_123456789, $method ) = explode('->', $callback); + global $$object_123456789; + $callback = array( $$object_123456789, $method ); + } else { + // We have just a standard function -- do nothing + } + + if ( ! $id) { + // Generate an ID + $id = $this->_makeId($callback, $args); + } + + // Get the storage handler and get callback cache data by id and group + $data = parent::get($id); + if ($data !== false) { + $cached = unserialize( $data ); + $output = $cached['output']; + $result = $cached['result']; + } else { + ob_start(); + ob_implicit_flush( false ); + + $result = call_user_func_array($callback, $args); + $output = ob_get_contents(); + + ob_end_clean(); + + $cached = array(); + $cached['output'] = $output; + $cached['result'] = $result; + // Store the cache data + $this->store(serialize($cached), $id); + } + + echo $output; + return $result; + } + + /** + * Generate a callback cache id + * + * @param callback $callback Callback to cache + * @param array $args Arguments to the callback method to cache + * @return string MD5 Hash : function cache id + * @since 1.5 + */ + protected function _makeId($callback, $args) + { + if(is_array($callback) && is_object($callback[0])) { + $vars = get_object_vars($callback[0]); + $vars[] = strtolower(get_class($callback[0])); + $callback[0] = $vars; + } + return md5(serialize(array($callback, $args))); + } } diff --git a/vendor/joomla/libraries/joomla/cache/handler/output.php b/vendor/joomla/libraries/joomla/cache/handler/output.php index ac7bb3c0a..b937e8279 100644 --- a/vendor/joomla/libraries/joomla/cache/handler/output.php +++ b/vendor/joomla/libraries/joomla/cache/handler/output.php @@ -1,77 +1,66 @@ get($id, $group); - if ($data !== false) { - echo $data; - return true; - } else { - // Nothing in cache... lets start the output buffer and start collecting data for next time. - ob_start(); - ob_implicit_flush( false ); - // Set id and group placeholders - $this->_id = $id; - $this->_group = $group; - return false; - } - } - - /** - * Stop the cache buffer and store the cached data - * - * @access public - * @return boolean True if cache stored - * @since 1.5 - */ - function end() - { - // Get data from output buffer and echo it - $data = ob_get_contents(); - ob_end_clean(); - echo $data; - - // Get id and group and reset them placeholders - $id = $this->_id; - $group = $this->_group; - $this->_id = null; - $this->_group = null; - - // Get the storage handler and store the cached data - $this->store($data, $id, $group); - } + /** + * Start the cache + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True if the cache is hit (false else) + * @since 1.5 + */ + function start($id, $group = null) + { + // If we have data in cache use that... + $data = $this->get($id, $group); + if ($data !== false) { + echo $data; + return true; + } else { + // Nothing in cache... lets start the output buffer and start collecting data for next time. + ob_start(); + ob_implicit_flush( false ); + // Set id and group placeholders + $this->_id = $id; + $this->_group = $group; + return false; + } + } + + /** + * Stop the cache buffer and store the cached data + * + * @access public + * @return boolean True if cache stored + * @since 1.5 + */ + function end() + { + // Get data from output buffer and echo it + $data = ob_get_contents(); + ob_end_clean(); + echo $data; + + // Get id and group and reset them placeholders + $id = $this->_id; + $group = $this->_group; + $this->_id = null; + $this->_group = null; + + // Get the storage handler and store the cached data + $this->store($data, $id, $group); + } } diff --git a/vendor/joomla/libraries/joomla/cache/handler/page.php b/vendor/joomla/libraries/joomla/cache/handler/page.php index 01d7f6e63..25f1f2b04 100644 --- a/vendor/joomla/libraries/joomla/cache/handler/page.php +++ b/vendor/joomla/libraries/joomla/cache/handler/page.php @@ -1,136 +1,124 @@ _makeId(); - } - - - // If the etag matches the page id ... sent a no change header and exit : utilize browser cache - if ( !headers_sent() && isset($_SERVER['HTTP_IF_NONE_MATCH']) ){ - $etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); - if( $etag == $id) { - $browserCache = isset($this->_options['browsercache']) ? $this->_options['browsercache'] : false; - if ($browserCache) { - $this->_noChange(); - } - } - } - - // We got a cache hit... set the etag header and echo the page data - $data = parent::get($id, $group); - if ($data !== false) { - $this->_setEtag($id); - return $data; - } - - // Set id and group placeholders - $this->_id = $id; - $this->_group = $group; - return false; - } - - /** - * Stop the cache buffer and store the cached data - * - * @access public - * @return boolean True if cache stored - * @since 1.5 - */ - function store() - { - // Get page data from JResponse body - $data = JResponse::getBody(); - - // Get id and group and reset them placeholders - $id = $this->_id; - $group = $this->_group; - $this->_id = null; - $this->_group = null; - - // Only attempt to store if page data exists - if ($data) { - return parent::store($data, $id, $group); - } - return false; - } - - /** - * Generate a page cache id - * @todo Discuss whether this should be coupled to a data hash or a request hash ... perhaps hashed with a serialized request - * - * @access private - * @return string MD5 Hash : page cache id - * @since 1.5 - */ - function _makeId() - { - return md5(JRequest::getURI()); - } - - /** - * There is no change in page data so send a not modified header and die gracefully - * - * @access private - * @return void - * @since 1.5 - */ - function _noChange() - { - global $mainframe; - - // Send not modified header and exit gracefully - header( 'HTTP/1.x 304 Not Modified', true ); - $mainframe->close(); - } - - /** - * Set the ETag header in the response - * - * @access private - * @return void - * @since 1.5 - */ - function _setEtag($etag) - { - JResponse::setHeader( 'ETag', $etag, true ); - } + /** + * Get the cached page data + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True if the cache is hit (false else) + * @since 1.5 + */ + function get($id = false, $group = 'page') + { + // Initialize variables + $data = false; + + // If an id is not given generate it from the request + if ($id == false) { + $id = $this->_makeId(); + } + + // If the etag matches the page id ... sent a no change header and exit : utilize browser cache + if ( ! headers_sent() && isset($_SERVER['HTTP_IF_NONE_MATCH']) ){ + $etag = stripslashes($_SERVER['HTTP_IF_NONE_MATCH']); + if( $etag == $id) { + $browserCache = isset($this->_options['browsercache']) ? $this->_options['browsercache'] : false; + if ($browserCache) { + $this->_noChange(); + } + } + } + + // We got a cache hit... set the etag header and echo the page data + $data = parent::get($id, $group); + if ($data !== false) { + $this->_setEtag($id); + return $data; + } + + // Set id and group placeholders + $this->_id = $id; + $this->_group = $group; + return false; + } + + /** + * Stop the cache buffer and store the cached data + * + * @access public + * @return boolean True if cache stored + * @since 1.5 + */ + function store() + { + // Get page data from JResponse body + $data = JResponse::getBody(); + + // Get id and group and reset them placeholders + $id = $this->_id; + $group = $this->_group; + $this->_id = null; + $this->_group = null; + + // Only attempt to store if page data exists + if ($data) { + return parent::store($data, $id, $group); + } + return false; + } + + /** + * Generate a page cache id + * @todo Discuss whether this should be coupled to a data hash or a request hash ... perhaps hashed with a serialized request + * + * @access private + * @return string MD5 Hash : page cache id + * @since 1.5 + */ + protected function _makeId() + { + return md5(JRequest::getURI()); + } + + /** + * There is no change in page data so send a not modified header and die gracefully + * + * @access private + * @return void + * @since 1.5 + */ + protected function _noChange() + { + global $mainframe; + + // Send not modified header and exit gracefully + header( 'HTTP/1.x 304 Not Modified', true ); + $mainframe->close(); + } + + /** + * Set the ETag header in the response + * + * @access private + * @return void + * @since 1.5 + */ + protected function _setEtag($etag) + { + JResponse::setHeader( 'ETag', $etag, true ); + } } diff --git a/vendor/joomla/libraries/joomla/cache/handler/view.php b/vendor/joomla/libraries/joomla/cache/handler/view.php index 9500b87aa..bbc9846a2 100644 --- a/vendor/joomla/libraries/joomla/cache/handler/view.php +++ b/vendor/joomla/libraries/joomla/cache/handler/view.php @@ -1,150 +1,130 @@ _makeId($view, $method); - } - - $data = parent::get($id); - if ($data !== false) { - $data = unserialize($data); - $document = &JFactory::getDocument(); - - // Get the document head out of the cache. - $document->setHeadData((isset($data['head'])) ? $data['head'] : array()); - - // If the pathway buffer is set in the cache data, get it. - if (isset($data['pathway']) && is_array($data['pathway'])) - { - // Push the pathway data into the pathway object. - $pathway = &$mainframe->getPathWay(); - $pathway->setPathway($data['pathway']); - } - - // If a module buffer is set in the cache data, get it. - if (isset($data['module']) && is_array($data['module'])) - { - // Iterate through the module positions and push them into the document buffer. - foreach ($data['module'] as $name => $contents) { - $document->setBuffer($contents, 'module', $name); - } - } - - // Get the document body out of the cache. - echo (isset($data['body'])) ? $data['body'] : null; - return true; - } - - /* - * No hit so we have to execute the view - */ - if (method_exists($view, $method)) - { - $document = &JFactory::getDocument(); - - // Get the modules buffer before component execution. - $buffer1 = $document->getBuffer(); - - // Make sure the module buffer is an array. - if (!isset($buffer1['module']) || !is_array($buffer1['module'])) { - $buffer1['module'] = array(); - } - - // Capture and echo output - ob_start(); - ob_implicit_flush( false ); - $view->$method(); - $data = ob_get_contents(); - ob_end_clean(); - echo $data; - - /* - * For a view we have a special case. We need to cache not only the output from the view, but the state - * of the document head after the view has been rendered. This will allow us to properly cache any attached - * scripts or stylesheets or links or any other modifications that the view has made to the document object - */ - $cached = array(); - - // View body data - $cached['body'] = $data; - - // Document head data - $cached['head'] = $document->getHeadData(); - - // Pathway data - $pathway = &$mainframe->getPathWay(); - $cached['pathway'] = $pathway->getPathway(); - - // Get the module buffer after component execution. - $buffer2 = $document->getBuffer(); - - // Make sure the module buffer is an array. - if (!isset($buffer2['module']) || !is_array($buffer2['module'])) { - $buffer2['module'] = array(); - } - - // Compare the second module buffer against the first buffer. - $cached['module'] = array_diff_assoc($buffer2['module'], $buffer1['module']); - - // Store the cache data - $this->store(serialize($cached), $id); - } - return false; - } - - /** - * Generate a view cache id - * - * @access private - * @param object $view The view object to cache output for - * @param string $method The method name to cache for the view object - * @return string MD5 Hash : view cache id - * @since 1.5 - */ - function _makeId(&$view, $method) - { - return md5(serialize(array(JRequest::getURI(), get_class($view), $method))); - } + /** + * Get the cached view data + * + * @access public + * @param object $view The view object to cache output for + * @param string $method The method name of the view method to cache output for + * @param string $group The cache data group + * @param string $id The cache data id + * @return boolean True if the cache is hit (false else) + * @since 1.5 + */ + function get(&$view, $method = null, $id = false) + { + global $mainframe; + + // Initialize variables + $data = false; + + // If an id is not given generate it from the request + if ($id == false) { + $id = $this->_makeId($view, $method); + } + + $data = parent::get($id); + if ($data !== false) { + $data = unserialize($data); + $document = &JFactory::getDocument(); + + // Get the document head out of the cache. + $document->setHeadData((isset($data['head'])) ? $data['head'] : array()); + + // If the pathway buffer is set in the cache data, get it. + if (isset($data['pathway']) && is_array($data['pathway'])) { + // Push the pathway data into the pathway object. + $pathway = &$mainframe->getPathWay(); + $pathway->setPathway($data['pathway']); + } + + // If a module buffer is set in the cache data, get it. + if (isset($data['module']) && is_array($data['module'])) { + // Iterate through the module positions and push them into the document buffer. + foreach ($data['module'] as $name => $contents) { + $document->setBuffer($contents, 'module', $name); + } + } + + // Get the document body out of the cache. + echo (isset($data['body'])) ? $data['body'] : null; + return true; + } + + /* + * No hit so we have to execute the view + */ + if (method_exists($view, $method)) { + $document = &JFactory::getDocument(); + // Get the modules buffer before component execution. + $buffer1 = $document->getBuffer(); + + // Make sure the module buffer is an array. + if (!isset($buffer1['module']) || !is_array($buffer1['module'])) { + $buffer1['module'] = array(); + } + + // Capture and echo output + ob_start(); + ob_implicit_flush( false ); + $view->$method(); + $data = ob_get_contents(); + ob_end_clean(); + echo $data; + + /* + * For a view we have a special case. We need to cache not only the output from the view, but the state + * of the document head after the view has been rendered. This will allow us to properly cache any attached + * scripts or stylesheets or links or any other modifications that the view has made to the document object + */ + $cached = array(); + // View body data + $cached['body'] = $data; + // Document head data + $cached['head'] = $document->getHeadData(); + // Pathway data + $pathway = &$mainframe->getPathWay(); + $cached['pathway'] = $pathway->getPathway(); + // Get the module buffer after component execution. + $buffer2 = $document->getBuffer(); + + // Make sure the module buffer is an array. + if (!isset($buffer2['module']) || !is_array($buffer2['module'])) { + $buffer2['module'] = array(); + } + + // Compare the second module buffer against the first buffer. + $cached['module'] = array_diff_assoc($buffer2['module'], $buffer1['module']); + + // Store the cache data + $this->store(serialize($cached), $id); + } + return false; + } + + /** + * Generate a view cache id + * + * @param object $view The view object to cache output for + * @param string $method The method name to cache for the view object + * @return string MD5 Hash : view cache id + * @since 1.5 + */ + protected function _makeId(&$view, $method) + { + return md5(serialize(array(JRequest::getURI(), get_class($view), $method))); + } } diff --git a/vendor/joomla/libraries/joomla/cache/storage.php b/vendor/joomla/libraries/joomla/cache/storage.php index bfa903c2c..0ea9751af 100644 --- a/vendor/joomla/libraries/joomla/cache/storage.php +++ b/vendor/joomla/libraries/joomla/cache/storage.php @@ -1,173 +1,158 @@ _application = (isset($options['application'])) ? $options['application'] : null; - $this->_language = (isset($options['language'])) ? $options['language'] : 'en-GB'; - $this->_locking = (isset($options['locking'])) ? $options['locking'] : true; - $this->_lifetime = (isset($options['lifetime'])) ? $options['lifetime'] : null; - $this->_now = (isset($options['now'])) ? $options['now'] : time(); - - // Set time threshold value. If the lifetime is not set, default to 60 (0 is BAD) - // _threshold is now available ONLY as a legacy (it's deprecated). It's no longer used in the core. - if (empty($this->_lifetime)) { - $this->_threshold = $this->_now - 60; - $this->_lifetime = 60; - } else { - $this->_threshold = $this->_now - $this->_lifetime; - } - } - - /** - * Returns a reference to a cache storage hanlder object, only creating it - * if it doesn't already exist. - * - * @static - * @param string $handler The cache storage handler to instantiate - * @return object A JCacheStorageHandler object - * @since 1.5 - */ - function &getInstance($handler = 'file', $options = array()) - { - static $now = null; - if(is_null($now)) { - $now = time(); - } - $options['now'] = $now; - //We can't cache this since options may change... - $handler = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $handler)); - $class = 'JCacheStorage'.ucfirst($handler); - if(!class_exists($class)) - { - $path = dirname(__FILE__).DS.'storage'.DS.$handler.'.php'; - if (file_exists($path) ) { - require_once($path); - } else { - return JError::raiseWarning(500, 'Unable to load Cache Storage: '.$handler); - } - } - $return = new $class($options); - return $return; - } - - /** - * Get cached data by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param boolean $checkTime True to verify cache time expiration threshold - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group, $checkTime) - { - return; - } - - /** - * Store the data to cache by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param string $data The data to store in cache - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function store($id, $group, $data) - { - return true; - } - - /** - * Remove a cached data entry by id and group - * - * @abstract - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group) - { - return true; - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @abstract - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group, $mode) - { - return true; - } - - /** - * Garbage collect expired cache data - * - * @abstract - * @access public - * @return boolean True on success, false otherwise. - */ - function gc() - { - return true; - } - - /** - * Test to see if the storage handler is available. - * - * @abstract - * @static - * @access public - * @return boolean True on success, false otherwise. - */ - function test() - { - return true; - } + /** + * Constructor + * + * @access protected + * @param array $options optional parameters + */ + function __construct( $options = array() ) + { + $this->_application = (isset($options['application'])) ? $options['application'] : null; + $this->_language = (isset($options['language'])) ? $options['language'] : 'en-GB'; + $this->_locking = (isset($options['locking'])) ? $options['locking'] : true; + $this->_lifetime = (isset($options['lifetime'])) ? $options['lifetime'] : null; + $this->_now = (isset($options['now'])) ? $options['now'] : time(); + + // Set time threshold value. If the lifetime is not set, default to 60 (0 is BAD) + // _threshold is now available ONLY as a legacy (it's deprecated). It's no longer used in the core. + if (empty($this->_lifetime)) { + $this->_threshold = $this->_now - 60; + $this->_lifetime = 60; + } else { + $this->_threshold = $this->_now - $this->_lifetime; + } + } + + /** + * Returns a reference to a cache storage hanlder object, only creating it + * if it doesn't already exist. + * + * @param string $handler The cache storage handler to instantiate + * @return object A JCacheStorageHandler object + * @since 1.5 + */ + public static function &getInstance($handler = 'file', $options = array()) + { + static $now = null; + if (is_null($now)) { + $now = time(); + } + $options['now'] = $now; + //We can't cache this since options may change... + $handler = strtolower(preg_replace('/[^A-Z0-9_\.-]/i', '', $handler)); + $class = 'JCacheStorage'.ucfirst($handler); + if( ! class_exists($class)) { + $path = dirname(__FILE__).DS.'storage'.DS.$handler.'.php'; + if (file_exists($path) ) { + require_once($path); + } else { + return JError::raiseWarning(500, 'Unable to load Cache Storage: '.$handler); + } + } + $return = new $class($options); + return $return; + } + + /** + * Get cached data by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param boolean $checkTime True to verify cache time expiration threshold + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null, $checkTime = null) + { + return; + } + + /** + * Store the data to cache by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param string $data The data to store in cache + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function store($id, $group, $data) + { + return true; + } + + /** + * Remove a cached data entry by id and group + * + * @abstract + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group) + { + return true; + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @abstract + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group, $mode) + { + return true; + } + + /** + * Garbage collect expired cache data + * + * @abstract + * @access public + * @return boolean True on success, false otherwise. + */ + function gc() + { + return true; + } + + /** + * Test to see if the storage handler is available. + * + * @abstract + * @return boolean True on success, false otherwise. + */ + public static function test() + { + return true; + } } diff --git a/vendor/joomla/libraries/joomla/cache/storage/apc.php b/vendor/joomla/libraries/joomla/cache/storage/apc.php index 58a60117c..d08f026a6 100644 --- a/vendor/joomla/libraries/joomla/cache/storage/apc.php +++ b/vendor/joomla/libraries/joomla/cache/storage/apc.php @@ -1,156 +1,142 @@ _hash = $config->getValue('config.secret'); - } - - /** - * Get cached data from APC by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param boolean $checkTime True to verify cache time expiration threshold - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group, $checkTime) - { - $cache_id = $this->_getCacheId($id, $group); - $this->_setExpire($cache_id); - return apc_fetch($cache_id); - } - - /** - * Store the data to APC by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param string $data The data to store in cache - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function store($id, $group, $data) - { - $cache_id = $this->_getCacheId($id, $group); - apc_store($cache_id.'_expire', time()); - return apc_store($cache_id, $data, $this->_lifetime); - } - - /** - * Remove a cached data entry by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group) - { - $cache_id = $this->_getCacheId($id, $group); - apc_delete($cache_id.'_expire'); - return apc_delete($cache_id); - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group, $mode) - { - return true; - } - - /** - * Test to see if the cache storage is available. - * - * @static - * @access public - * @return boolean True on success, false otherwise. - */ - function test() - { - return extension_loaded('apc'); - } - - /** - * Set expire time on each call since memcache sets it on cache creation. - * - * @access private - * - * @param string $key Cache key to expire. - * @param integer $lifetime Lifetime of the data in seconds. - */ - function _setExpire($key) - { - $lifetime = $this->_lifetime; - $expire = apc_fetch($key.'_expire'); - - // set prune period - if ($expire + $lifetime < time()) { - apc_delete($key); - apc_delete($key.'_expire'); - } else { - apc_store($key.'_expire', time()); - } - } - - /** - * Get a cache_id string from an id/group pair - * - * @access private - * @param string $id The cache data id - * @param string $group The cache data group - * @return string The cache_id string - * @since 1.5 - */ - function _getCacheId($id, $group) - { - $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); - return 'cache_'.$group.'-'.$name; - } + /** + * Constructor + * + * @access protected + * @param array $options optional parameters + */ + function __construct( $options = array() ) + { + parent::__construct($options); + + $config =& JFactory::getConfig(); + $this->_hash = $config->getValue('config.secret'); + } + + /** + * Get cached data from APC by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param boolean $checkTime True to verify cache time expiration threshold + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null, $checkTime = null) + { + $cache_id = $this->_getCacheId($id, $group); + $this->_setExpire($cache_id); + return apc_fetch($cache_id); + } + + /** + * Store the data to APC by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param string $data The data to store in cache + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function store($id, $group, $data) + { + $cache_id = $this->_getCacheId($id, $group); + apc_store($cache_id.'_expire', time()); + return apc_store($cache_id, $data, $this->_lifetime); + } + + /** + * Remove a cached data entry by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group) + { + $cache_id = $this->_getCacheId($id, $group); + apc_delete($cache_id.'_expire'); + return apc_delete($cache_id); + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group, $mode) + { + return true; + } + + /** + * Test to see if the cache storage is available. + * + * @return boolean True on success, false otherwise. + */ + public static function test() + { + return extension_loaded('apc'); + } + + /** + * Set expire time on each call since memcache sets it on cache creation. + * + * @access private + * @param string $key Cache key to expire. + * @param integer $lifetime Lifetime of the data in seconds. + */ + function _setExpire($key) + { + $lifetime = $this->_lifetime; + $expire = apc_fetch($key.'_expire'); + + // set prune period + if ($expire + $lifetime < time()) { + apc_delete($key); + apc_delete($key.'_expire'); + } else { + apc_store($key.'_expire', time()); + } + } + + /** + * Get a cache_id string from an id/group pair + * + * @access private + * @param string $id The cache data id + * @param string $group The cache data group + * @return string The cache_id string + * @since 1.5 + */ + function _getCacheId($id, $group) + { + $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); + return 'cache_'.$group.'-'.$name; + } } diff --git a/vendor/joomla/libraries/joomla/cache/storage/eaccelerator.php b/vendor/joomla/libraries/joomla/cache/storage/eaccelerator.php index 1335f01c9..5f594a57a 100644 --- a/vendor/joomla/libraries/joomla/cache/storage/eaccelerator.php +++ b/vendor/joomla/libraries/joomla/cache/storage/eaccelerator.php @@ -1,172 +1,157 @@ _hash = $config->getValue('config.secret'); - } - - /** - * Get cached data by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param boolean $checkTime True to verify cache time expiration threshold - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group, $checkTime) - { - $cache_id = $this->_getCacheId($id, $group); - $this->_setExpire($cache_id); - $cache_content = eaccelerator_get($cache_id); - if($cache_content === null) - { - return false; - } - return $cache_content; - } - - /** - * Store the data to by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param string $data The data to store in cache - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function store($id, $group, $data) - { - $cache_id = $this->_getCacheId($id, $group); - eaccelerator_put($cache_id.'_expire', time()); - return eaccelerator_put($cache_id, $data, $this->_lifetime); - } - - /** - * Remove a cached data entry by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group) - { - $cache_id = $this->_getCacheId($id, $group); - eaccelerator_rm($cache_id.'_expire'); - return eaccelerator_rm($cache_id); - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group, $mode) - { - return true; - } - - /** - * Garbage collect expired cache data - * - * @access public - * @return boolean True on success, false otherwise. - */ - function gc() - { - return eaccelerator_gc(); - } - - /** - * Test to see if the cache storage is available. - * - * @static - * @access public - * @return boolean True on success, false otherwise. - */ - function test() - { - return (extension_loaded('eaccelerator') && function_exists('eaccelerator_get')); - } - - /** - * Set expire time on each call since memcache sets it on cache creation. - * - * @access private - * - * @param string $key Cache key to expire. - * @param integer $lifetime Lifetime of the data in seconds. - */ - function _setExpire($key) - { - $lifetime = $this->_lifetime; - $expire = eaccelerator_get($key.'_expire'); - - // set prune period - if ($expire + $lifetime < time()) { - eaccelerator_rm($key); - eaccelerator_rm($key.'_expire'); - } else { - eaccelerator_put($key.'_expire', time()); - } - } - - /** - * Get a cache_id string from an id/group pair - * - * @access private - * @param string $id The cache data id - * @param string $group The cache data group - * @return string The cache_id string - * @since 1.5 - */ - function _getCacheId($id, $group) - { - $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); - return 'cache_'.$group.'-'.$name; - } + /** + * Constructor + * + * @access protected + * @param array $options optional parameters + */ + function __construct($options = array()) + { + parent::__construct($options); + + $config =& JFactory::getConfig(); + $this->_hash = $config->getValue('config.secret'); + } + + /** + * Get cached data by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param boolean $checkTime True to verify cache time expiration threshold + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null, $checkTime = null) + { + $cache_id = $this->_getCacheId($id, $group); + $this->_setExpire($cache_id); + $cache_content = eaccelerator_get($cache_id); + if ($cache_content === null) { + return false; + } + return $cache_content; + } + + /** + * Store the data to by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param string $data The data to store in cache + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function store($id, $group, $data) + { + $cache_id = $this->_getCacheId($id, $group); + eaccelerator_put($cache_id.'_expire', time()); + return eaccelerator_put($cache_id, $data, $this->_lifetime); + } + + /** + * Remove a cached data entry by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group) + { + $cache_id = $this->_getCacheId($id, $group); + eaccelerator_rm($cache_id.'_expire'); + return eaccelerator_rm($cache_id); + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group, $mode) + { + return true; + } + + /** + * Garbage collect expired cache data + * + * @access public + * @return boolean True on success, false otherwise. + */ + function gc() + { + return eaccelerator_gc(); + } + + /** + * Test to see if the cache storage is available. + * + * @return boolean True on success, false otherwise. + */ + public static function test() + { + return (extension_loaded('eaccelerator') && function_exists('eaccelerator_get')); + } + + /** + * Set expire time on each call since memcache sets it on cache creation. + * + * @access private + * @param string $key Cache key to expire. + * @param integer $lifetime Lifetime of the data in seconds. + */ + function _setExpire($key) + { + $lifetime = $this->_lifetime; + $expire = eaccelerator_get($key.'_expire'); + + // set prune period + if ($expire + $lifetime < time()) { + eaccelerator_rm($key); + eaccelerator_rm($key.'_expire'); + } else { + eaccelerator_put($key.'_expire', time()); + } + } + + /** + * Get a cache_id string from an id/group pair + * + * @access private + * @param string $id The cache data id + * @param string $group The cache data group + * @return string The cache_id string + * @since 1.5 + */ + function _getCacheId($id, $group) + { + $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); + return 'cache_'.$group.'-'.$name; + } } diff --git a/vendor/joomla/libraries/joomla/cache/storage/file.php b/vendor/joomla/libraries/joomla/cache/storage/file.php index 7bcc4806c..74965f419 100644 --- a/vendor/joomla/libraries/joomla/cache/storage/file.php +++ b/vendor/joomla/libraries/joomla/cache/storage/file.php @@ -1,264 +1,248 @@ _root = $options['cachebase']; - $this->_hash = $config->getValue('config.secret'); - } - - /** - * Get cached data from a file by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param boolean $checkTime True to verify cache time expiration threshold - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group, $checkTime) - { - $data = false; - - $path = $this->_getFilePath($id, $group); - $this->_setExpire($id, $group); - if (file_exists($path)) { - $data = file_get_contents($path); - if($data) { - // Remove the initial die() statement - $data = preg_replace('/^.*\n/', '', $data); - } - } - - return $data; - } - - /** - * Store the data to a file by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param string $data The data to store in cache - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function store($id, $group, $data) - { - $written = false; - $path = $this->_getFilePath($id, $group); - $expirePath = $path . '_expire'; - $die = ''."\n"; - - // Prepend a die string - - $data = $die.$data; - - $fp = @fopen($path, "wb"); - if ($fp) { - if ($this->_locking) { - @flock($fp, LOCK_EX); - } - $len = strlen($data); - @fwrite($fp, $data, $len); - if ($this->_locking) { - @flock($fp, LOCK_UN); - } - @fclose($fp); - $written = true; - } - // Data integrity check - if ($written && ($data == file_get_contents($path))) { - @file_put_contents($expirePath, ($this->_now + $this->_lifetime)); - return true; - } else { - return false; - } - } - - /** - * Remove a cached data file by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group) - { - $path = $this->_getFilePath($id, $group); - @unlink($path.'_expire'); - if (!@unlink($path)) { - return false; - } - return true; - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group, $mode) - { - jimport('joomla.filesystem.folder'); - - $return = true; - $folder = $group; - - if(trim($folder) == '') { - $mode = 'notgroup'; - } - - switch ($mode) - { - case 'notgroup': - $folders = JFolder::folders($this->_root); - for ($i=0,$n=count($folders);$i<$n;$i++) - { - if ($folders[$i] != $folder) { - $return |= JFolder::delete($this->_root.DS.$folders[$i]); - } - } - break; - case 'group': - default: - if (is_dir($this->_root.DS.$folder)) { - $return = JFolder::delete($this->_root.DS.$folder); - } - break; - } - return $return; - } - - /** - * Garbage collect expired cache data - * - * @access public - * @return boolean True on success, false otherwise. - */ - function gc() - { - jimport('joomla.filesystem.file'); - $result = true; - // files older than lifeTime get deleted from cache - $files = JFolder::files($this->_root, '_expire', true, true); - foreach($files As $file) { - $time = @file_get_contents($file); - if ($time < $this->_now) { - $result |= JFile::delete($file); - $result |= JFile::delete(str_replace('_expire', '', $file)); - } - } - return $result; - } - - /** - * Test to see if the cache storage is available. - * - * @static - * @access public - * @return boolean True on success, false otherwise. - */ - function test() - { - $config =& JFactory::getConfig(); - $root = $config->getValue('config.cache_path', JPATH_ROOT.DS.'cache'); - return is_writable($root); - } - - /** - * Check to make sure cache is still valid, if not, delete it. - * - * @access private - * - * @param string $id Cache key to expire. - * @param string $group The cache data group. - */ - function _setExpire($id, $group) - { - $path = $this->_getFilePath($id, $group); - - // set prune period - if(file_exists($path.'_expire')) { - $time = @file_get_contents($path.'_expire'); - if ($time < $this->_now || empty($time)) { - $this->remove($id, $group); - } - } elseif(file_exists($path)) { - //This means that for some reason there's no expire file, remove it - $this->remove($id, $group); - } - } - - /** - * Get a cache file path from an id/group pair - * - * @access private - * @param string $id The cache data id - * @param string $group The cache data group - * @return string The cache file path - * @since 1.5 - */ - function _getFilePath($id, $group) - { - $folder = $group; - $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language).'.php'; - $dir = $this->_root.DS.$folder; - - // If the folder doesn't exist try to create it - if (!is_dir($dir)) { - - // Make sure the index file is there - $indexFile = $dir . DS . 'index.html'; - @ mkdir($dir) && file_put_contents($indexFile, ''); - } - - // Make sure the folder exists - if (!is_dir($dir)) { - return false; - } - return $dir.DS.$name; - } + /** + * Constructor + * + * @access protected + * @param array $options optional parameters + */ + function __construct( $options = array() ) + { + parent::__construct($options); + + $config =& JFactory::getConfig(); + $this->_root = $options['cachebase']; + $this->_hash = $config->getValue('config.secret'); + } + + /** + * Get cached data from a file by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param boolean $checkTime True to verify cache time expiration threshold + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null, $checkTime = null) + { + $data = false; + + $path = $this->_getFilePath($id, $group); + $this->_setExpire($id, $group); + if (file_exists($path)) { + $data = file_get_contents($path); + if ($data) { + // Remove the initial die() statement + $data = preg_replace('/^.*\n/', '', $data); + } + } + + return $data; + } + + /** + * Store the data to a file by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param string $data The data to store in cache + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function store($id, $group, $data) + { + $written = false; + $path = $this->_getFilePath($id, $group); + $expirePath = $path . '_expire'; + $die = ''."\n"; + + // Prepend a die string + + $data = $die.$data; + + $fp = @fopen($path, "wb"); + if ($fp) { + if ($this->_locking) { + @flock($fp, LOCK_EX); + } + $len = strlen($data); + @fwrite($fp, $data, $len); + if ($this->_locking) { + @flock($fp, LOCK_UN); + } + @fclose($fp); + $written = true; + } + // Data integrity check + if ($written && ($data == file_get_contents($path))) { + @file_put_contents($expirePath, ($this->_now + $this->_lifetime)); + return true; + } else { + return false; + } + } + + /** + * Remove a cached data file by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group) + { + $path = $this->_getFilePath($id, $group); + @unlink($path.'_expire'); + if (!@unlink($path)) { + return false; + } + return true; + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group, $mode) + { + jimport('joomla.filesystem.folder'); + + $return = true; + $folder = $group; + + if (trim($folder) == '') { + $mode = 'notgroup'; + } + + switch ($mode) { + case 'notgroup': + $folders = JFolder::folders($this->_root); + for ($i=0,$n=count($folders);$i<$n;$i++) + { + if ($folders[$i] != $folder) { + $return |= JFolder::delete($this->_root.DS.$folders[$i]); + } + } + break; + case 'group': + default: + if (is_dir($this->_root.DS.$folder)) { + $return = JFolder::delete($this->_root.DS.$folder); + } + break; + } + return $return; + } + + /** + * Garbage collect expired cache data + * + * @access public + * @return boolean True on success, false otherwise. + */ + function gc() + { + jimport('joomla.filesystem.file'); + $result = true; + // files older than lifeTime get deleted from cache + $files = JFolder::files($this->_root, '_expire', true, true); + foreach($files As $file) { + $time = @file_get_contents($file); + if ($time < $this->_now) { + $result |= JFile::delete($file); + $result |= JFile::delete(str_replace('_expire', '', $file)); + } + } + return $result; + } + + /** + * Test to see if the cache storage is available. + * + * @return boolean True on success, false otherwise. + */ + public static function test() + { + $config =& JFactory::getConfig(); + $root = $config->getValue('config.cache_path', JPATH_ROOT.DS.'cache'); + return is_writable($root); + } + + /** + * Check to make sure cache is still valid, if not, delete it. + * + * @access private + * @param string $id Cache key to expire. + * @param string $group The cache data group. + */ + function _setExpire($id, $group) + { + $path = $this->_getFilePath($id, $group); + + // set prune period + if (file_exists($path.'_expire')) { + $time = @file_get_contents($path.'_expire'); + if ($time < $this->_now || empty($time)) { + $this->remove($id, $group); + } + } elseif(file_exists($path)) { + //This means that for some reason there's no expire file, remove it + $this->remove($id, $group); + } + } + + /** + * Get a cache file path from an id/group pair + * + * @access private + * @param string $id The cache data id + * @param string $group The cache data group + * @return string The cache file path + * @since 1.5 + */ + function _getFilePath($id, $group) + { + $folder = $group; + $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language).'.php'; + $dir = $this->_root.DS.$folder; + + // If the folder doesn't exist try to create it + if ( ! is_dir($dir)) { + // Make sure the index file is there + $indexFile = $dir . DS . 'index.html'; + @ mkdir($dir) && file_put_contents($indexFile, ''); + } + + // Make sure the folder exists + if (!is_dir($dir)) { + return false; + } + return $dir.DS.$name; + } } diff --git a/vendor/joomla/libraries/joomla/cache/storage/memcache.php b/vendor/joomla/libraries/joomla/cache/storage/memcache.php index c074d5711..e5cc6ac0d 100644 --- a/vendor/joomla/libraries/joomla/cache/storage/memcache.php +++ b/vendor/joomla/libraries/joomla/cache/storage/memcache.php @@ -1,215 +1,205 @@ test()) { - return JError::raiseError(404, "The memcache extension is not available"); - } - parent::__construct($options); - - $params =& JCacheStorageMemcache::getConfig(); - $this->_compress = (isset($params['compression'])) ? $params['compression'] : 0; - $this->_db =& JCacheStorageMemcache::getConnection(); - - // Get the site hash - $this->_hash = $params['hash']; - } - - /** - * return memcache connection object - * - * @static - * @access private - * @return object memcache connection object - */ - function &getConnection() { - static $db = null; - if(is_null($db)) { - $params =& JCacheStorageMemcache::getConfig(); - $persistent = (isset($params['persistent'])) ? $params['persistent'] : false; - // This will be an array of loveliness - $servers = (isset($params['servers'])) ? $params['servers'] : array(); - - // Create the memcache connection - $db = new Memcache; - foreach($servers AS $server) { - $db->addServer($server['host'], $server['port'], $persistent); - } - } - return $db; - } - - /** - * Return memcache related configuration - * - * @static - * @access private - * @return array options - */ - function &getConfig() { - static $params = null; - if(is_null($params)) { - $config =& JFactory::getConfig(); - $params = $config->getValue('config.memcache_settings'); - if (!is_array($params)) { - $params = unserialize(stripslashes($params)); - } - - if (!$params) { - $params = array(); - } - $params['hash'] = $config->getValue('config.secret'); - } - return $params; - } - - /** - * Get cached data from memcache by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param boolean $checkTime True to verify cache time expiration threshold - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group, $checkTime) - { - $cache_id = $this->_getCacheId($id, $group); - return $this->_db->get($cache_id); - } - - /** - * Store the data to memcache by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param string $data The data to store in cache - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function store($id, $group, $data) - { - $cache_id = $this->_getCacheId($id, $group); - return $this->_db->set($cache_id, $data, $this->_compress, $this->_lifetime); - } - - /** - * Remove a cached data entry by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group) - { - $cache_id = $this->_getCacheId($id, $group); - return $this->_db->delete($cache_id); - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group, $mode) - { - return true; - } - - /** - * Garbage collect expired cache data - * - * @access public - * @return boolean True on success, false otherwise. - */ - function gc() - { - return true; - } - - /** - * Test to see if the cache storage is available. - * - * @static - * @access public - * @return boolean True on success, false otherwise. - */ - function test() - { - return (extension_loaded('memcache') && class_exists('Memcache')); - } - - /** - * Get a cache_id string from an id/group pair - * - * @access private - * @param string $id The cache data id - * @param string $group The cache data group - * @return string The cache_id string - * @since 1.5 - */ - function _getCacheId($id, $group) - { - $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); - return 'cache_'.$group.'-'.$name; - } + /** + * Resource for the current memcached connection. + * + * @var resource + */ + var $_db; + + /** + * Use compression? + * + * @var int + */ + var $_compress = null; + + /** + * Use persistent connections + * + * @var boolean + */ + var $_persistent = false; + + /** + * Constructor + * + * @access protected + * @param array $options optional parameters + */ + function __construct( $options = array() ) + { + if ( ! self::test()) { + return JError::raiseError(404, "The memcache extension is not available"); + } + parent::__construct($options); + + $params =& JCacheStorageMemcache::getConfig(); + $this->_compress = (isset($params['compression'])) ? $params['compression'] : 0; + $this->_db =& JCacheStorageMemcache::getConnection(); + + // Get the site hash + $this->_hash = $params['hash']; + } + + /** + * return memcache connection object + * + * @return object memcache connection object + */ + protected static function &getConnection() + { + static $db = null; + if (is_null($db)) { + $params =& JCacheStorageMemcache::getConfig(); + $persistent = (isset($params['persistent'])) ? $params['persistent'] : false; + // This will be an array of loveliness + $servers = (isset($params['servers'])) ? $params['servers'] : array(); + + // Create the memcache connection + $db = new Memcache; + foreach($servers AS $server) { + $db->addServer($server['host'], $server['port'], $persistent); + } + } + return $db; + } + + /** + * Return memcache related configuration + * + * @return array options + */ + protected static function &getConfig() + { + static $params = null; + if (is_null($params)) { + $config =& JFactory::getConfig(); + $params = $config->getValue('config.memcache_settings'); + if (!is_array($params)) { + $params = unserialize(stripslashes($params)); + } + + if (!$params) { + $params = array(); + } + $params['hash'] = $config->getValue('config.secret'); + } + return $params; + } + + /** + * Get cached data from memcache by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param boolean $checkTime True to verify cache time expiration threshold + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null, $checkTime = null) + { + $cache_id = $this->_getCacheId($id, $group); + return $this->_db->get($cache_id); + } + + /** + * Store the data to memcache by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param string $data The data to store in cache + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function store($id, $group, $data) + { + $cache_id = $this->_getCacheId($id, $group); + return $this->_db->set($cache_id, $data, $this->_compress, $this->_lifetime); + } + + /** + * Remove a cached data entry by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group) + { + $cache_id = $this->_getCacheId($id, $group); + return $this->_db->delete($cache_id); + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group, $mode) + { + return true; + } + + /** + * Garbage collect expired cache data + * + * @access public + * @return boolean True on success, false otherwise. + */ + function gc() + { + return true; + } + + /** + * Test to see if the cache storage is available. + * + * @static + * @access public + * @return boolean True on success, false otherwise. + */ + public static function test() + { + return (extension_loaded('memcache') && class_exists('Memcache')); + } + + /** + * Get a cache_id string from an id/group pair + * + * @access private + * @param string $id The cache data id + * @param string $group The cache data group + * @return string The cache_id string + * @since 1.5 + */ + function _getCacheId($id, $group) + { + $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); + return 'cache_'.$group.'-'.$name; + } } diff --git a/vendor/joomla/libraries/joomla/cache/storage/xcache.php b/vendor/joomla/libraries/joomla/cache/storage/xcache.php index 7a317c7ee..2958e8f43 100644 --- a/vendor/joomla/libraries/joomla/cache/storage/xcache.php +++ b/vendor/joomla/libraries/joomla/cache/storage/xcache.php @@ -1,142 +1,129 @@ _hash = $config->getValue('config.secret'); - } - - /** - * Get cached data by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param boolean $checkTime True to verify cache time expiration threshold - * @return mixed Boolean false on failure or a cached data string - * @since 1.5 - */ - function get($id, $group, $checkTime) - { - $cache_id = $this->_getCacheId($id, $group); - - //check if id exists - if( !xcache_isset( $cache_id ) ){ - return false; - } - - return xcache_get($cache_id); - } - - /** - * Store the data by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @param string $data The data to store in cache - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function store($id, $group, $data) - { - $cache_id = $this->_getCacheId($id, $group); - return xcache_set($cache_id, $data, $this->_lifetime); - } - - /** - * Remove a cached data entry by id and group - * - * @access public - * @param string $id The cache data id - * @param string $group The cache data group - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function remove($id, $group) - { - $cache_id = $this->_getCacheId($id, $group); - - if( !xcache_isset( $cache_id ) ){ - return true; - } - - return xcache_unset($cache_id); - } - - /** - * Clean cache for a group given a mode. - * - * group mode : cleans all cache in the group - * notgroup mode : cleans all cache not in the group - * - * @access public - * @param string $group The cache data group - * @param string $mode The mode for cleaning cache [group|notgroup] - * @return boolean True on success, false otherwise - * @since 1.5 - */ - function clean($group, $mode) - { - return true; - } - - /** - * Test to see if the cache storage is available. - * - * @static - * @access public - * @return boolean True on success, false otherwise. - */ - function test() - { - return (extension_loaded('xcache')); - } + /** + * Constructor + * + * @access protected + * @param array $options optional parameters + */ + function __construct( $options = array() ) + { + parent::__construct($options); + + $config =& JFactory::getConfig(); + $this->_hash = $config->getValue('config.secret'); + } + + /** + * Get cached data by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param boolean $checkTime True to verify cache time expiration threshold + * @return mixed Boolean false on failure or a cached data string + * @since 1.5 + */ + function get($id, $group = null, $checkTime = null) + { + $cache_id = $this->_getCacheId($id, $group); + + //check if id exists + if( ! xcache_isset($cache_id)){ + return false; + } + + return xcache_get($cache_id); + } - /** - * Get a cache_id string from an id/group pair - * - * @access private - * @param string $id The cache data id - * @param string $group The cache data group - * @return string The cache_id string - * @since 1.5 - */ - function _getCacheId($id, $group) - { - $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); - return 'cache_'.$group.'-'.$name; - } + /** + * Store the data by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @param string $data The data to store in cache + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function store($id, $group, $data) + { + $cache_id = $this->_getCacheId($id, $group); + return xcache_set($cache_id, $data, $this->_lifetime); + } + + /** + * Remove a cached data entry by id and group + * + * @access public + * @param string $id The cache data id + * @param string $group The cache data group + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function remove($id, $group) + { + $cache_id = $this->_getCacheId($id, $group); + + if( ! xcache_isset($cache_id)){ + return true; + } + + return xcache_unset($cache_id); + } + + /** + * Clean cache for a group given a mode. + * + * group mode : cleans all cache in the group + * notgroup mode : cleans all cache not in the group + * + * @access public + * @param string $group The cache data group + * @param string $mode The mode for cleaning cache [group|notgroup] + * @return boolean True on success, false otherwise + * @since 1.5 + */ + function clean($group, $mode) + { + return true; + } + + /** + * Test to see if the cache storage is available. + * + * @return boolean True on success, false otherwise. + */ + public static function test() + { + return (extension_loaded('xcache')); + } + + /** + * Get a cache_id string from an id/group pair + * + * @access private + * @param string $id The cache data id + * @param string $group The cache data group + * @return string The cache_id string + * @since 1.5 + */ + function _getCacheId($id, $group) + { + $name = md5($this->_application.'-'.$id.'-'.$this->_hash.'-'.$this->_language); + return 'cache_'.$group.'-'.$name; + } } diff --git a/vendor/joomla/libraries/joomla/client/helper.php b/vendor/joomla/libraries/joomla/client/helper.php index 1168ac258..9e2b9aac4 100644 --- a/vendor/joomla/libraries/joomla/client/helper.php +++ b/vendor/joomla/libraries/joomla/client/helper.php @@ -1,241 +1,211 @@ $config->getValue('config.ftp_enable'), - 'host' => $config->getValue('config.ftp_host'), - 'port' => $config->getValue('config.ftp_port'), - 'user' => $config->getValue('config.ftp_user'), - 'pass' => $config->getValue('config.ftp_pass'), - 'root' => $config->getValue('config.ftp_root') - ); - break; - - default: - $options = array( - 'enabled' => false, - 'host' => '', - 'port' => '', - 'user' => '', - 'pass' => '', - 'root' => '' - ); - break; - } - - // If user and pass are not set in global config lets see if its in the session - if ($options['enabled'] == true && ($options['user'] == '' || $options['pass'] == '')) - { - $session =& JFactory::getSession(); - $options['user'] = $session->get($client.'.user', null, 'JClientHelper'); - $options['pass'] = $session->get($client.'.pass', null, 'JClientHelper'); - } - - // If user or pass are missing, disable this client - if ($options['user'] == '' || $options['pass'] == '') { - $options['enabled'] = false; - } - - // Save the credentials for later use - $credentials[$client] = $options; - } - - return $credentials[$client]; - } - - /** - * Method to set client login credentials - * - * @static - * @param string Client name, currently only 'ftp' is supported - * @param string Username - * @param string Password - * @return boolean True if the given login credentials have been set and are valid - * @since 1.5 - */ - function setCredentials($client, $user, $pass) - { - $return = false; - $client = strtolower($client); - - // Test if the given credentials are valid - switch ($client) - { - case 'ftp': - $config =& JFactory::getConfig(); - $options = array( - 'enabled' => $config->getValue('config.ftp_enable'), - 'host' => $config->getValue('config.ftp_host'), - 'port' => $config->getValue('config.ftp_port'), - ); - - if ($options['enabled']) - { - jimport('joomla.client.ftp'); - $ftp =& JFTP::getInstance($options['host'], $options['port']); - - // Test the conection and try to log in - if ($ftp->isConnected()) - { - if ($ftp->login($user, $pass)) { - $return = true; - } - $ftp->quit(); - } - } - break; - - default: - break; - } - - if ($return) { - // Save valid credentials to the session - $session =& JFactory::getSession(); - $session->set($client.'.user', $user, 'JClientHelper'); - $session->set($client.'.pass', $pass, 'JClientHelper'); - - // Force re-creation of the data saved within JClientHelper::getCredentials() - JClientHelper::getCredentials($client, true); - } - - return $return; - } - - /** - * Method to determine if client login credentials are present - * - * @static - * @param string Client name, currently only 'ftp' is supported - * @return boolean True if login credentials are available - * @since 1.5 - */ - function hasCredentials($client) - { - $return = false; - $client = strtolower($client); - - // Get (unmodified) credentials for this client - switch ($client) - { - case 'ftp': - $config =& JFactory::getConfig(); - $options = array( - 'enabled' => $config->getValue('config.ftp_enable'), - 'user' => $config->getValue('config.ftp_user'), - 'pass' => $config->getValue('config.ftp_pass') - ); - break; - - default: - $options = array( - 'enabled' => false, - 'user' => '', - 'pass' => '' - ); - break; - } - - if ($options['enabled'] == false) - { - // The client is disabled in global config, so let's pretend we are OK - $return = true; - } - else if ($options['user'] != '' && $options['pass'] != '') - { - // Login credentials are available in global config - $return = true; - } - else - { - // Check if login credentials are available in the session - $session =& JFactory::getSession(); - $user = $session->get($client.'.user', null, 'JClientHelper'); - $pass = $session->get($client.'.pass', null, 'JClientHelper'); - if ($user != '' && $pass != '') { - $return = true; - } - } - - return $return; - } - - /** - * Determine wether input fields for client settings need to be shown - * - * If valid credentials were passed along with the request, they are saved to the session. - * This functions returns an exeption if invalid credentials have been given or if the - * connection to the server failed for some other reason. - - * @static - * @return boolean|JExeption True, if FTP settings should be shown, or an exeption - * @since 1.5 - */ - function &setCredentialsFromRequest($client) - { - // Determine wether FTP credentials have been passed along with the current request - $user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW); - $pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW); - if ($user != '' && $pass != '') - { - // Add credentials to the session - if (JClientHelper::setCredentials($client, $user, $pass)) { - $return = false; - } else { - $return =& JError::raiseWarning('SOME_ERROR_CODE', 'JClientHelper::setCredentialsFromRequest failed'); - } - } - else - { - // Just determine if the FTP input fields need to be shown - $return = !JClientHelper::hasCredentials('ftp'); - } - - return $return; - } -} \ No newline at end of file + /** + * Method to return the array of client layer configuration options + * + * @param string Client name, currently only 'ftp' is supported + * @param boolean Forces re-creation of the login credentials. Set this to + * true if login credentials in the session storage have changed + * @return array Client layer configuration options, consisting of at least + * these fields: enabled, host, port, user, pass, root + * @since 1.5 + */ + public static function getCredentials($client, $force=false) + { + static $credentials = array(); + + $client = strtolower($client); + + if (!isset($credentials[$client]) || $force) { + // Initialize variables + $config =& JFactory::getConfig(); + + // Fetch the client layer configuration options for the specific client + switch ($client) { + case 'ftp': + $options = array( + 'enabled' => $config->getValue('config.ftp_enable'), + 'host' => $config->getValue('config.ftp_host'), + 'port' => $config->getValue('config.ftp_port'), + 'user' => $config->getValue('config.ftp_user'), + 'pass' => $config->getValue('config.ftp_pass'), + 'root' => $config->getValue('config.ftp_root') + ); + break; + default: + $options = array( + 'enabled' => false, + 'host' => '', + 'port' => '', + 'user' => '', + 'pass' => '', + 'root' => '' + ); + break; + } + + // If user and pass are not set in global config lets see if its in the session + if ($options['enabled'] == true && ($options['user'] == '' || $options['pass'] == '')) { + $session =& JFactory::getSession(); + $options['user'] = $session->get($client.'.user', null, 'JClientHelper'); + $options['pass'] = $session->get($client.'.pass', null, 'JClientHelper'); + } + + // If user or pass are missing, disable this client + if ($options['user'] == '' || $options['pass'] == '') { + $options['enabled'] = false; + } + + // Save the credentials for later use + $credentials[$client] = $options; + } + + return $credentials[$client]; + } + + /** + * Method to set client login credentials + * + * @param string Client name, currently only 'ftp' is supported + * @param string Username + * @param string Password + * @return boolean True if the given login credentials have been set and are valid + * @since 1.5 + */ + public static function setCredentials($client, $user, $pass) + { + $return = false; + $client = strtolower($client); + + // Test if the given credentials are valid + switch ($client) { + case 'ftp': + $config =& JFactory::getConfig(); + $options = array( + 'enabled' => $config->getValue('config.ftp_enable'), + 'host' => $config->getValue('config.ftp_host'), + 'port' => $config->getValue('config.ftp_port'), + ); + + if ($options['enabled']) { + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($options['host'], $options['port']); + + // Test the conection and try to log in + if ($ftp->isConnected()) + { + if ($ftp->login($user, $pass)) { + $return = true; + } + $ftp->quit(); + } + } + break; + default: + break; + } + + if ($return) { + // Save valid credentials to the session + $session =& JFactory::getSession(); + $session->set($client.'.user', $user, 'JClientHelper'); + $session->set($client.'.pass', $pass, 'JClientHelper'); + + // Force re-creation of the data saved within JClientHelper::getCredentials() + JClientHelper::getCredentials($client, true); + } + + return $return; + } + + /** + * Method to determine if client login credentials are present + * + * @param string Client name, currently only 'ftp' is supported + * @return boolean True if login credentials are available + * @since 1.5 + */ + public static function hasCredentials($client) + { + $return = false; + $client = strtolower($client); + + // Get (unmodified) credentials for this client + switch ($client) { + case 'ftp': + $config =& JFactory::getConfig(); + $options = array( + 'enabled' => $config->getValue('config.ftp_enable'), + 'user' => $config->getValue('config.ftp_user'), + 'pass' => $config->getValue('config.ftp_pass') + ); + break; + default: + $options = array( + 'enabled' => false, + 'user' => '', + 'pass' => '' + ); + break; + } + + if ($options['enabled'] == false) { + // The client is disabled in global config, so let's pretend we are OK + $return = true; + } elseif ($options['user'] != '' && $options['pass'] != '') { + // Login credentials are available in global config + $return = true; + } else { + // Check if login credentials are available in the session + $session =& JFactory::getSession(); + $user = $session->get($client.'.user', null, 'JClientHelper'); + $pass = $session->get($client.'.pass', null, 'JClientHelper'); + if ($user != '' && $pass != '') { + $return = true; + } + } + + return $return; + } + + /** + * Determine wether input fields for client settings need to be shown + * + * If valid credentials were passed along with the request, they are saved to the session. + * This functions returns an exeption if invalid credentials have been given or if the + * connection to the server failed for some other reason. + * + * @return boolean|JExeption True, if FTP settings should be shown, or an exeption + * @since 1.5 + */ + public static function &setCredentialsFromRequest($client) + { + // Determine wether FTP credentials have been passed along with the current request + $user = JRequest::getString('username', null, 'POST', JREQUEST_ALLOWRAW); + $pass = JRequest::getString('password', null, 'POST', JREQUEST_ALLOWRAW); + if ($user != '' && $pass != '') { + // Add credentials to the session + if (JClientHelper::setCredentials($client, $user, $pass)) { + $return = false; + } else { + $return =& JError::raiseWarning('SOME_ERROR_CODE', 'JClientHelper::setCredentialsFromRequest failed'); + } + } else{ + // Just determine if the FTP input fields need to be shown + $return = !JClientHelper::hasCredentials('ftp'); + } + + return $return; + } +} diff --git a/vendor/joomla/libraries/joomla/database/table.php b/vendor/joomla/libraries/joomla/database/table.php index a452018eb..4a848d90e 100644 --- a/vendor/joomla/libraries/joomla/database/table.php +++ b/vendor/joomla/libraries/joomla/database/table.php @@ -1,862 +1,780 @@ _tbl = $table; - $this->_tbl_key = $key; - $this->_db =& $db; - } - - /** - * Returns a reference to the a Table object, always creating it - * - * @param type $type The table type to instantiate - * @param string $prefix A prefix for the table class name. Optional. - * @param array $options Configuration array for model. Optional. - * @return database A database object - * @since 1.5 - */ - function &getInstance( $type, $prefix = 'JTable', $config = array() ) - { - $false = false; - - $type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type); - $tableClass = $prefix.ucfirst($type); - - if (!class_exists( $tableClass )) - { - jimport('joomla.filesystem.path'); - if($path = JPath::find(JTable::addIncludePath(), strtolower($type).'.php')) - { - require_once $path; - - if (!class_exists( $tableClass )) - { - JError::raiseWarning( 0, 'Table class ' . $tableClass . ' not found in file.' ); - return $false; - } - } - else - { - JError::raiseWarning( 0, 'Table ' . $type . ' not supported. File not found.' ); - return $false; - } - } - - //Make sure we are returning a DBO object - if (array_key_exists('dbo', $config)) { - $db =& $config['dbo']; - } else { - $db = & JFactory::getDBO(); - } - - $instance = new $tableClass($db); - //$instance->setDBO($db); - - return $instance; - } - - /** - * Get the internal database object - * - * @return object A JDatabase based object - */ - function &getDBO() - { - return $this->_db; - } - - /** - * Set the internal database object - * - * @param object $db A JDatabase based object - * @return void - */ - function setDBO(&$db) - { - $this->_db =& $db; - } - - /** - * Gets the internal table name for the object - * - * @return string - * @since 1.5 - */ - function getTableName() - { - return $this->_tbl; - } - - /** - * Gets the internal primary key name - * - * @return string - * @since 1.5 - */ - function getKeyName() - { - return $this->_tbl_key; - } - - /** - * Resets the default properties - * @return void - */ - function reset() - { - $k = $this->_tbl_key; - foreach ($this->getProperties() as $name => $value) - { - if($name != $k) - { - $this->$name = $value; - } - } - } - - /** - * Binds a named array/hash to this object - * - * Can be overloaded/supplemented by the child class - * - * @access public - * @param $from mixed An associative array or object - * @param $ignore mixed An array or space separated list of fields not to bind - * @return boolean - */ - function bind( $from, $ignore=array() ) - { - $fromArray = is_array( $from ); - $fromObject = is_object( $from ); - - if (!$fromArray && !$fromObject) - { - $this->setError( get_class( $this ).'::bind failed. Invalid from argument' ); - return false; - } - if (!is_array( $ignore )) { - $ignore = explode( ' ', $ignore ); - } - foreach ($this->getProperties() as $k => $v) - { - // internal attributes of an object are ignored - if (!in_array( $k, $ignore )) - { - if ($fromArray && isset( $from[$k] )) { - $this->$k = $from[$k]; - } else if ($fromObject && isset( $from->$k )) { - $this->$k = $from->$k; - } - } - } - return true; - } - - /** - * Loads a row from the database and binds the fields to the object properties - * - * @access public - * @param mixed Optional primary key. If not specifed, the value of current key is used - * @return boolean True if successful - */ - function load( $oid=null ) - { - $k = $this->_tbl_key; - - if ($oid !== null) { - $this->$k = $oid; - } - - $oid = $this->$k; - - if ($oid === null) { - return false; - } - $this->reset(); - - $db =& $this->getDBO(); - - $query = 'SELECT *' - . ' FROM '.$this->_tbl - . ' WHERE '.$this->_tbl_key.' = '.$db->Quote($oid); - $db->setQuery( $query ); - - if ($result = $db->loadAssoc( )) { - return $this->bind($result); - } - else - { - $this->setError( $db->getErrorMsg() ); - return false; - } - } - - /** - * Generic check method - * - * Can be overloaded/supplemented by the child class - * - * @access public - * @return boolean True if the object is ok - */ - function check() - { - return true; - } - - /** - * Inserts a new row if id is zero or updates an existing row in the database table - * - * Can be overloaded/supplemented by the child class - * - * @access public - * @param boolean If false, null object variables are not updated - * @return null|string null if successful otherwise returns and error message - */ - function store( $updateNulls=false ) - { - $k = $this->_tbl_key; - - if( $this->$k) - { - $ret = $this->_db->updateObject( $this->_tbl, $this, $this->_tbl_key, $updateNulls ); - } - else - { - $ret = $this->_db->insertObject( $this->_tbl, $this, $this->_tbl_key ); - } - if( !$ret ) - { - $this->setError(get_class( $this ).'::store failed - '.$this->_db->getErrorMsg()); - return false; - } - else - { - return true; - } - } - - /** - * Description - * - * @access public - * @param $dirn - * @param $where - */ - function move( $dirn, $where='' ) - { - if (!in_array( 'ordering', array_keys($this->getProperties()))) - { - $this->setError( get_class( $this ).' does not support ordering' ); - return false; - } - - $k = $this->_tbl_key; - - $sql = "SELECT $this->_tbl_key, ordering FROM $this->_tbl"; - - if ($dirn < 0) - { - $sql .= ' WHERE ordering < '.(int) $this->ordering; - $sql .= ($where ? ' AND '.$where : ''); - $sql .= ' ORDER BY ordering DESC'; - } - else if ($dirn > 0) - { - $sql .= ' WHERE ordering > '.(int) $this->ordering; - $sql .= ($where ? ' AND '. $where : ''); - $sql .= ' ORDER BY ordering'; - } - else - { - $sql .= ' WHERE ordering = '.(int) $this->ordering; - $sql .= ($where ? ' AND '.$where : ''); - $sql .= ' ORDER BY ordering'; - } - - $this->_db->setQuery( $sql, 0, 1 ); - - - $row = null; - $row = $this->_db->loadObject(); - if (isset($row)) - { - $query = 'UPDATE '. $this->_tbl - . ' SET ordering = '. (int) $row->ordering - . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k) - ; - $this->_db->setQuery( $query ); - - if (!$this->_db->query()) - { - $err = $this->_db->getErrorMsg(); - JError::raiseError( 500, $err ); - } - - $query = 'UPDATE '.$this->_tbl - . ' SET ordering = '.(int) $this->ordering - . ' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($row->$k) - ; - $this->_db->setQuery( $query ); - - if (!$this->_db->query()) - { - $err = $this->_db->getErrorMsg(); - JError::raiseError( 500, $err ); - } - - $this->ordering = $row->ordering; - } - else - { - $query = 'UPDATE '. $this->_tbl - . ' SET ordering = '.(int) $this->ordering - . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k) - ; - $this->_db->setQuery( $query ); - - if (!$this->_db->query()) - { - $err = $this->_db->getErrorMsg(); - JError::raiseError( 500, $err ); - } - } - return true; - } - - /** - * Returns the ordering value to place a new item last in its group - * - * @access public - * @param string query WHERE clause for selecting MAX(ordering). - */ - function getNextOrder ( $where='' ) - { - if (!in_array( 'ordering', array_keys($this->getProperties()) )) - { - $this->setError( get_class( $this ).' does not support ordering' ); - return false; - } - - $query = 'SELECT MAX(ordering)' . - ' FROM ' . $this->_tbl . - ($where ? ' WHERE '.$where : ''); - - $this->_db->setQuery( $query ); - $maxord = $this->_db->loadResult(); - - if ($this->_db->getErrorNum()) - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - return $maxord + 1; - } - - /** - * Compacts the ordering sequence of the selected records - * - * @access public - * @param string Additional where query to limit ordering to a particular subset of records - */ - function reorder( $where='' ) - { - $k = $this->_tbl_key; - - if (!in_array( 'ordering', array_keys($this->getProperties() ) )) - { - $this->setError( get_class( $this ).' does not support ordering'); - return false; - } - - if ($this->_tbl == '#__content_frontpage') - { - $order2 = ", content_id DESC"; - } - else - { - $order2 = ""; - } - - $query = 'SELECT '.$this->_tbl_key.', ordering' - . ' FROM '. $this->_tbl - . ' WHERE ordering >= 0' . ( $where ? ' AND '. $where : '' ) - . ' ORDER BY ordering'.$order2 - ; - $this->_db->setQuery( $query ); - if (!($orders = $this->_db->loadObjectList())) - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - // compact the ordering numbers - for ($i=0, $n=count( $orders ); $i < $n; $i++) - { - if ($orders[$i]->ordering >= 0) - { - if ($orders[$i]->ordering != $i+1) - { - $orders[$i]->ordering = $i+1; - $query = 'UPDATE '.$this->_tbl - . ' SET ordering = '. (int) $orders[$i]->ordering - . ' WHERE '. $k .' = '. $this->_db->Quote($orders[$i]->$k) - ; - $this->_db->setQuery( $query); - $this->_db->query(); - } - } - } - - return true; - } - - /** - * Generic check for whether dependancies exist for this object in the db schema - * - * can be overloaded/supplemented by the child class - * - * @access public - * @param string $msg Error message returned - * @param int Optional key index - * @param array Optional array to compiles standard joins: format [label=>'Label',name=>'table name',idfield=>'field',joinfield=>'field'] - * @return true|false - */ - function canDelete( $oid=null, $joins=null ) - { - $k = $this->_tbl_key; - if ($oid) { - $this->$k = intval( $oid ); - } - - if (is_array( $joins )) - { - $select = "$k"; - $join = ""; - foreach( $joins as $table ) - { - $select .= ', COUNT(DISTINCT '.$table['idfield'].') AS '.$table['idfield']; - $join .= ' LEFT JOIN '.$table['name'].' ON '.$table['joinfield'].' = '.$k; - } - - $query = 'SELECT '. $select - . ' FROM '. $this->_tbl - . $join - . ' WHERE '. $k .' = '. $this->_db->Quote($this->$k) - . ' GROUP BY '. $k - ; - $this->_db->setQuery( $query ); - - if (!$obj = $this->_db->loadObject()) - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - $msg = array(); - $i = 0; - foreach( $joins as $table ) - { - $k = $table['idfield'] . $i; - if ($obj->$k) - { - $msg[] = JText::_( $table['label'] ); - } - $i++; - } - - if (count( $msg )) - { - $this->setError("noDeleteRecord" . ": " . implode( ', ', $msg )); - return false; - } - else - { - return true; - } - } - - return true; - } - - /** - * Default delete method - * - * can be overloaded/supplemented by the child class - * - * @access public - * @return true if successful otherwise returns and error message - */ - function delete( $oid=null ) - { - //if (!$this->canDelete( $msg )) - //{ - // return $msg; - //} - - $k = $this->_tbl_key; - if ($oid) { - $this->$k = intval( $oid ); - } - - $query = 'DELETE FROM '.$this->_db->nameQuote( $this->_tbl ). - ' WHERE '.$this->_tbl_key.' = '. $this->_db->Quote($this->$k); - $this->_db->setQuery( $query ); - - if ($this->_db->query()) - { - return true; - } - else - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - } - - /** - * Checks out a row - * - * @access public - * @param integer The id of the user - * @param mixed The primary key value for the row - * @return boolean True if successful, or if checkout is not supported - */ - function checkout( $who, $oid = null ) - { - if (!in_array( 'checked_out', array_keys($this->getProperties()) )) { - return true; - } - - $k = $this->_tbl_key; - if ($oid !== null) { - $this->$k = $oid; - } - - $date =& JFactory::getDate(); - $time = $date->toMysql(); - - $query = 'UPDATE '.$this->_db->nameQuote( $this->_tbl ) . - ' SET checked_out = '.(int)$who.', checked_out_time = '.$this->_db->Quote($time) . - ' WHERE '.$this->_tbl_key.' = '. $this->_db->Quote($this->$k); - $this->_db->setQuery( $query ); - - $this->checked_out = $who; - $this->checked_out_time = $time; - - return $this->_db->query(); - } - - /** - * Checks in a row - * - * @access public - * @param mixed The primary key value for the row - * @return boolean True if successful, or if checkout is not supported - */ - function checkin( $oid=null ) - { - if (!( - in_array( 'checked_out', array_keys($this->getProperties()) ) || - in_array( 'checked_out_time', array_keys($this->getProperties()) ) - )) { - return true; - } - - $k = $this->_tbl_key; - - if ($oid !== null) { - $this->$k = $oid; - } - - if ($this->$k == NULL) { - return false; - } - - $query = 'UPDATE '.$this->_db->nameQuote( $this->_tbl ). - ' SET checked_out = 0, checked_out_time = '.$this->_db->Quote($this->_db->getNullDate()) . - ' WHERE '.$this->_tbl_key.' = '. $this->_db->Quote($this->$k); - $this->_db->setQuery( $query ); - - $this->checked_out = 0; - $this->checked_out_time = ''; - - return $this->_db->query(); - } - - /** - * Description - * - * @access public - * @param $oid - * @param $log - */ - function hit( $oid=null, $log=false ) - { - if (!in_array( 'hits', array_keys($this->getProperties()) )) { - return; - } - - $k = $this->_tbl_key; - - if ($oid !== null) { - $this->$k = intval( $oid ); - } - - $query = 'UPDATE '. $this->_tbl - . ' SET hits = ( hits + 1 )' - . ' WHERE '. $this->_tbl_key .'='. $this->_db->Quote($this->$k); - $this->_db->setQuery( $query ); - $this->_db->query(); - $this->hits++; - } - - /** - * Check if an item is checked out - * - * This function can be used as a static function too, when you do so you need to also provide the - * a value for the $against parameter. - * - * @static - * @access public - * @param integer $with The userid to preform the match with, if an item is checked out - * by this user the function will return false - * @param integer $against The userid to perform the match against when the function is used as - * a static function. - * @return boolean - */ - function isCheckedOut( $with = 0, $against = null) - { - if(isset($this) && is_a($this, 'JTable') && is_null($against)) { - $against = $this->get( 'checked_out' ); - } - - //item is not checked out, or being checked out by the same user - if (!$against || $against == $with) { - return false; - } - - $session =& JTable::getInstance('session'); - return $session->exists($against); - } - - /** - * Generic save function - * - * @access public - * @param array Source array for binding to class vars - * @param string Filter for the order updating - * @param mixed An array or space separated list of fields not to bind - * @returns TRUE if completely successful, FALSE if partially or not succesful. - */ - function save( $source, $order_filter='', $ignore='' ) - { - if (!$this->bind( $source, $ignore )) { - return false; - } - if (!$this->check()) { - return false; - } - if (!$this->store()) { - return false; - } - if (!$this->checkin()) { - return false; - } - if ($order_filter) - { - $filter_value = $this->$order_filter; - $this->reorder( $order_filter ? $this->_db->nameQuote( $order_filter ).' = '.$this->_db->Quote( $filter_value ) : '' ); - } - $this->setError(''); - return true; - } - - /** - * Generic Publish/Unpublish function - * - * @access public - * @param array An array of id numbers - * @param integer 0 if unpublishing, 1 if publishing - * @param integer The id of the user performnig the operation - * @since 1.0.4 - */ - function publish( $cid=null, $publish=1, $user_id=0 ) - { - JArrayHelper::toInteger( $cid ); - $user_id = (int) $user_id; - $publish = (int) $publish; - $k = $this->_tbl_key; - - if (count( $cid ) < 1) - { - if ($this->$k) { - $cid = array( $this->$k ); - } else { - $this->setError("No items selected."); - return false; - } - } - - $cids = $k . '=' . implode( ' OR ' . $k . '=', $cid ); - - $query = 'UPDATE '. $this->_tbl - . ' SET published = ' . (int) $publish - . ' WHERE ('.$cids.')' - ; - - $checkin = in_array( 'checked_out', array_keys($this->getProperties()) ); - if ($checkin) - { - $query .= ' AND (checked_out = 0 OR checked_out = '.(int) $user_id.')'; - } - - $this->_db->setQuery( $query ); - if (!$this->_db->query()) - { - $this->setError($this->_db->getErrorMsg()); - return false; - } - - if (count( $cid ) == 1 && $checkin) - { - if ($this->_db->getAffectedRows() == 1) { - $this->checkin( $cid[0] ); - if ($this->$k == $cid[0]) { - $this->published = $publish; - } - } - } - $this->setError(''); - return true; - } - - /** - * Export item list to xml - * - * @access public - * @param boolean Map foreign keys to text values - */ - function toXML( $mapKeysToText=false ) - { - $xml = ' $v) - { - if (is_array($v) or is_object($v) or $v === NULL) - { - continue; - } - if ($k[0] == '_') - { // internal field - continue; - } - $xml .= '<' . $k . '>'; - } - $xml .= ''; - - return $xml; - } - - /** - * Add a directory where JTable should search for table types. You may - * either pass a string or an array of directories. - * - * @access public - * @param string A path to search. - * @return array An array with directory elements - * @since 1.5 - */ - function addIncludePath( $path=null ) - { - static $paths; - - if (!isset($paths)) { - $paths = array( dirname( __FILE__ ).DS.'table' ); - } - - // just force path to array - settype($path, 'array'); - - if (!empty( $path ) && !in_array( $path, $paths )) - { - // loop through the path directories - foreach ($path as $dir) - { - // no surrounding spaces allowed! - $dir = trim($dir); - - // add to the top of the search dirs - // so that custom paths are searched before core paths - array_unshift($paths, $dir); - } - } - return $paths; - } + /** + * Name of the table in the db schema relating to child class + * + * @var string + * @access protected + */ + var $_tbl = ''; + + /** + * Name of the primary key field in the table + * + * @var string + * @access protected + */ + var $_tbl_key = ''; + + /** + * Database connector + * + * @var JDatabase + * @access protected + */ + var $_db = null; + + /** + * Object constructor to set table and key field + * + * Can be overloaded/supplemented by the child class + * + * @access protected + * @param string $table name of the table in the db schema relating to child class + * @param string $key name of the primary key field in the table + * @param object $db JDatabase object + */ + function __construct($table, $key, &$db) + { + $this->_tbl = $table; + $this->_tbl_key = $key; + $this->_db =& $db; + } + + /** + * Returns a reference to the a Table object, always creating it + * + * @param type $type The table type to instantiate + * @param string $prefix A prefix for the table class name. Optional. + * @param array $options Configuration array for model. Optional. + * @return database A database object + * @since 1.5 + */ + public static function &getInstance( $type, $prefix = 'JTable', $config = array() ) + { + $false = false; + $type = preg_replace('/[^A-Z0-9_\.-]/i', '', $type); + $tableClass = $prefix.ucfirst($type); + + if (! class_exists($tableClass)) { + jimport('joomla.filesystem.path'); + if (($path = JPath::find(JTable::addIncludePath(), strtolower($type).'.php'))) { + require_once $path; + + if ( ! class_exists($tableClass)) { + JError::raiseWarning(0, 'Table class '.$tableClass.' not found in file.'); + return $false; + } + } else { + JError::raiseWarning(0, 'Table '.$type.' not supported. File not found.'); + return $false; + } + } + + //Make sure we are returning a DBO object + if (array_key_exists('dbo', $config)) { + $db =& $config['dbo']; + } else { + $db =& JFactory::getDBO(); + } + + $instance = new $tableClass($db); + //$instance->setDBO($db); + + return $instance; + } + + /** + * Get the internal database object + * + * @return object A JDatabase based object + */ + function &getDBO() + { + return $this->_db; + } + + /** + * Set the internal database object + * + * @param object $db A JDatabase based object + * @return void + */ + function setDBO(&$db) + { + $this->_db =& $db; + } + + /** + * Gets the internal table name for the object + * + * @return string + * @since 1.5 + */ + function getTableName() + { + return $this->_tbl; + } + + /** + * Gets the internal primary key name + * + * @return string + * @since 1.5 + */ + function getKeyName() + { + return $this->_tbl_key; + } + + /** + * Resets the default properties + * @return void + */ + function reset() + { + $k = $this->_tbl_key; + foreach ($this->getProperties() as $name => $value) { + if ($name != $k) { + $this->$name = $value; + } + } + } + + /** + * Binds a named array/hash to this object + * + * Can be overloaded/supplemented by the child class + * + * @access public + * @param $from mixed An associative array or object + * @param $ignore mixed An array or space separated list of fields not to bind + * @return boolean + */ + function bind($from, $ignore=array()) + { + $fromArray = is_array( $from ); + $fromObject = is_object( $from ); + + if ( ! $fromArray && ! $fromObject) { + $this->setError(get_class($this).'::bind failed. Invalid from argument'); + return false; + } + if ( ! is_array($ignore)) { + $ignore = explode(' ', $ignore); + } + foreach ($this->getProperties() as $k => $v) { + // internal attributes of an object are ignored + if ( ! in_array($k, $ignore)) { + if ($fromArray && isset($from[$k])) { + $this->$k = $from[$k]; + } elseif ($fromObject && isset($from->$k)) { + $this->$k = $from->$k; + } + } + } + return true; + } + + /** + * Loads a row from the database and binds the fields to the object properties + * + * @access public + * @param mixed Optional primary key. If not specifed, the value of current key is used + * @return boolean True if successful + */ + function load($oid = null) + { + $k = $this->_tbl_key; + + if ($oid !== null) { + $this->$k = $oid; + } + + $oid = $this->$k; + + if ($oid === null) { + return false; + } + $this->reset(); + + $db =& $this->getDBO(); + + $query = 'SELECT *' + . ' FROM '.$this->_tbl + . ' WHERE '.$this->_tbl_key.' = '.$db->Quote($oid); + $db->setQuery( $query ); + + if ($result = $db->loadAssoc( )) { + return $this->bind($result); + } else { + $this->setError( $db->getErrorMsg() ); + return false; + } + } + + /** + * Generic check method + * + * Can be overloaded/supplemented by the child class + * + * @access public + * @return boolean True if the object is ok + */ + function check() + { + return true; + } + + /** + * Inserts a new row if id is zero or updates an existing row in the database table + * + * Can be overloaded/supplemented by the child class + * + * @access public + * @param boolean If false, null object variables are not updated + * @return null|string null if successful otherwise returns and error message + */ + function store($updateNulls = false) + { + $k = $this->_tbl_key; + + if ($this->$k) { + $ret = $this->_db->updateObject($this->_tbl, $this, $this->_tbl_key, $updateNulls); + } else { + $ret = $this->_db->insertObject($this->_tbl, $this, $this->_tbl_key); + } + if ( ! $ret) { + $this->setError(get_class( $this ).'::store failed - '.$this->_db->getErrorMsg()); + return false; + } else { + return true; + } + } + + /** + * Description + * + * @access public + * @param $dirn + * @param $where + */ + function move($dirn, $where = '') + { + if ( ! in_array('ordering', array_keys($this->getProperties()))) { + $this->setError( get_class( $this ).' does not support ordering' ); + return false; + } + + $k = $this->_tbl_key; + $sql = "SELECT $this->_tbl_key, ordering FROM $this->_tbl"; + + if ($dirn < 0) { + $sql .= ' WHERE ordering < '.(int) $this->ordering; + $sql .= ($where ? ' AND '.$where : ''); + $sql .= ' ORDER BY ordering DESC'; + } elseif ($dirn > 0) { + $sql .= ' WHERE ordering > '.(int) $this->ordering; + $sql .= ($where ? ' AND '. $where : ''); + $sql .= ' ORDER BY ordering'; + } else { + $sql .= ' WHERE ordering = '.(int) $this->ordering; + $sql .= ($where ? ' AND '.$where : ''); + $sql .= ' ORDER BY ordering'; + } + + $this->_db->setQuery( $sql, 0, 1 ); + + $row = null; + $row = $this->_db->loadObject(); + if (isset($row)) { + $query = 'UPDATE '. $this->_tbl + . ' SET ordering = '. (int) $row->ordering + . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k) + ; + $this->_db->setQuery( $query ); + + if ( ! $this->_db->query()) { + $err = $this->_db->getErrorMsg(); + JError::raiseError(500, $err); + } + + $query = 'UPDATE '.$this->_tbl + . ' SET ordering = '.(int) $this->ordering + . ' WHERE '.$this->_tbl_key.' = '.$this->_db->Quote($row->$k) + ; + $this->_db->setQuery($query); + + if ( ! $this->_db->query()) { + $err = $this->_db->getErrorMsg(); + JError::raiseError(500, $err); + } + $this->ordering = $row->ordering; + } else { + $query = 'UPDATE '. $this->_tbl + . ' SET ordering = '.(int) $this->ordering + . ' WHERE '. $this->_tbl_key .' = '. $this->_db->Quote($this->$k) + ; + $this->_db->setQuery( $query ); + + if ( ! $this->_db->query()) { + $err = $this->_db->getErrorMsg(); + JError::raiseError(500, $err); + } + } + return true; + } + + /** + * Returns the ordering value to place a new item last in its group + * + * @access public + * @param string query WHERE clause for selecting MAX(ordering). + */ + function getNextOrder($where = '') + { + if ( ! in_array('ordering', array_keys($this->getProperties()))) { + $this->setError(get_class($this).' does not support ordering'); + return false; + } + + $query = 'SELECT MAX(ordering)' . + ' FROM ' . $this->_tbl . + ($where ? ' WHERE '.$where : ''); + + $this->_db->setQuery( $query ); + $maxord = $this->_db->loadResult(); + + if ($this->_db->getErrorNum()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + return $maxord + 1; + } + + /** + * Compacts the ordering sequence of the selected records + * + * @access public + * @param string Additional where query to limit ordering to a particular subset of records + */ + function reorder($where = '') + { + $k = $this->_tbl_key; + + if ( ! in_array('ordering', array_keys($this->getProperties()))) { + $this->setError( get_class( $this ).' does not support ordering'); + return false; + } + + if ($this->_tbl == '#__content_frontpage') { + $order2 = ", content_id DESC"; + } else { + $order2 = ""; + } + + $query = 'SELECT '.$this->_tbl_key.', ordering' + . ' FROM '. $this->_tbl + . ' WHERE ordering >= 0' . ( $where ? ' AND '. $where : '' ) + . ' ORDER BY ordering'.$order2 + ; + $this->_db->setQuery( $query ); + if ( ! ($orders = $this->_db->loadObjectList())) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + // compact the ordering numbers + for ($i=0, $n=count($orders); $i < $n; $i++) { + if ($orders[$i]->ordering >= 0) { + if ($orders[$i]->ordering != $i + 1) { + $orders[$i]->ordering = $i + 1; + $query = 'UPDATE '.$this->_tbl + . ' SET ordering = '. (int) $orders[$i]->ordering + . ' WHERE '. $k .' = '. $this->_db->Quote($orders[$i]->$k) + ; + $this->_db->setQuery( $query); + $this->_db->query(); + } + } + } + + return true; + } + + /** + * Generic check for whether dependancies exist for this object in the db schema + * + * can be overloaded/supplemented by the child class + * + * @access public + * @param string $msg Error message returned + * @param int Optional key index + * @param array Optional array to compiles standard joins: format [label=>'Label',name=>'table name',idfield=>'field',joinfield=>'field'] + * @return true|false + */ + function canDelete($oid = null, $joins = null) { + $k = $this->_tbl_key; + if ($oid) { + $this->$k = intval( $oid ); + } + + if (is_array($joins)) { + $select = "$k"; + $join = ""; + foreach ($joins as $table) { + $select .= ', COUNT(DISTINCT '.$table['idfield'].') AS '.$table['idfield']; + $join .= ' LEFT JOIN '.$table['name'].' ON '.$table['joinfield'].' = '.$k; + } + + $query = 'SELECT '. $select + . ' FROM '. $this->_tbl + . $join + . ' WHERE '. $k .' = '. $this->_db->Quote($this->$k) + . ' GROUP BY '. $k + ; + $this->_db->setQuery($query); + + if ( ! ($obj = $this->_db->loadObject())) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + $msg = array(); + $i = 0; + foreach ($joins as $table) { + $k = $table['idfield'].$i; + if ($obj->$k) { + $msg[] = JText::_( $table['label'] ); + } + $i++; + } + + if (count($msg)) { + $this->setError("noDeleteRecord" . ": " . implode(', ', $msg)); + return false; + } else { + return true; + } + } + + return true; + } + + /** + * Default delete method + * + * can be overloaded/supplemented by the child class + * + * @access public + * @return true if successful otherwise returns and error message + */ + function delete($oid = null) + { + //if (!$this->canDelete($msg)) { + // return $msg; + //} + + $k = $this->_tbl_key; + if ($oid) { + $this->$k = intval( $oid ); + } + + $query = 'DELETE FROM '.$this->_db->nameQuote( $this->_tbl ). + ' WHERE '.$this->_tbl_key.' = '. $this->_db->Quote($this->$k); + $this->_db->setQuery( $query ); + + if ($this->_db->query()) { + return true; + } else { + $this->setError($this->_db->getErrorMsg()); + return false; + } + } + + /** + * Checks out a row + * + * @access public + * @param integer The id of the user + * @param mixed The primary key value for the row + * @return boolean True if successful, or if checkout is not supported + */ + function checkout($who, $oid = null) + { + if ( ! in_array('checked_out', array_keys($this->getProperties()) )) { + return true; + } + + $k = $this->_tbl_key; + if ($oid !== null) { + $this->$k = $oid; + } + + $date =& JFactory::getDate(); + $time = $date->toMysql(); + + $query = 'UPDATE '.$this->_db->nameQuote( $this->_tbl ) . + ' SET checked_out = '.(int)$who.', checked_out_time = '.$this->_db->Quote($time) . + ' WHERE '.$this->_tbl_key.' = '. $this->_db->Quote($this->$k); + $this->_db->setQuery( $query ); + + $this->checked_out = $who; + $this->checked_out_time = $time; + + return $this->_db->query(); + } + + /** + * Checks in a row + * + * @access public + * @param mixed The primary key value for the row + * @return boolean True if successful, or if checkout is not supported + */ + function checkin( $oid=null ) + { + if ( ! ( + in_array('checked_out', array_keys($this->getProperties())) || + in_array('checked_out_time', array_keys($this->getProperties())) + )) { + return true; + } + + $k = $this->_tbl_key; + + if ($oid !== null) { + $this->$k = $oid; + } + + if ($this->$k == NULL) { + return false; + } + + $query = 'UPDATE '.$this->_db->nameQuote($this->_tbl). + ' SET checked_out = 0, checked_out_time = '.$this->_db->Quote($this->_db->getNullDate()) . + ' WHERE '.$this->_tbl_key.' = '. $this->_db->Quote($this->$k); + $this->_db->setQuery( $query ); + + $this->checked_out = 0; + $this->checked_out_time = ''; + + return $this->_db->query(); + } + + /** + * Description + * + * @access public + * @param $oid + * @param $log + */ + function hit($oid = null, $log = false) + { + if ( ! in_array( 'hits', array_keys($this->getProperties()))) { + return; + } + + $k = $this->_tbl_key; + + if ($oid !== null) { + $this->$k = intval( $oid ); + } + + $query = 'UPDATE '. $this->_tbl + . ' SET hits = ( hits + 1 )' + . ' WHERE '. $this->_tbl_key .'='. $this->_db->Quote($this->$k); + $this->_db->setQuery( $query ); + $this->_db->query(); + $this->hits++; + } + + /** + * Check if an item is checked out + * + * This function can be used as a static function too, when you do so you need to also provide the + * a value for the $against parameter. + * + * @param integer $with The userid to preform the match with, if an item is checked out + * by this user the function will return false + * @param integer $against The userid to perform the match against when the function is used as + * a static function. + * @return boolean + */ + public static function isCheckedOut($with = 0, $against = null) + { + if (isset($this) && is_a($this, 'JTable') && is_null($against)) { + $against = $this->get( 'checked_out' ); + } + + //item is not checked out, or being checked out by the same user + if ( ! $against || $against == $with) { + return false; + } + + $session =& JTable::getInstance('session'); + return $session->exists($against); + } + + /** + * Generic save function + * + * @access public + * @param array Source array for binding to class vars + * @param string Filter for the order updating + * @param mixed An array or space separated list of fields not to bind + * @returns TRUE if completely successful, FALSE if partially or not succesful. + */ + function save($source, $order_filter = '', $ignore = '') + { + if ( ! $this->bind($source, $ignore)) { + return false; + } + if ( ! $this->check()) { + return false; + } + if ( ! $this->store()) { + return false; + } + if ( ! $this->checkin()) { + return false; + } + if ($order_filter) { + $filter_value = $this->$order_filter; + $this->reorder( $order_filter ? $this->_db->nameQuote($order_filter).' = '.$this->_db->Quote($filter_value) : '' ); + } + $this->setError(''); + return true; + } + + /** + * Generic Publish/Unpublish function + * + * @access public + * @param array An array of id numbers + * @param integer 0 if unpublishing, 1 if publishing + * @param integer The id of the user performnig the operation + * @since 1.0.4 + */ + function publish($cid = null, $publish = 1, $user_id = 0) + { + JArrayHelper::toInteger( $cid ); + $user_id = (int)$user_id; + $publish = (int)$publish; + $k = $this->_tbl_key; + + if (count( $cid ) < 1) { + if ($this->$k) { + $cid = array( $this->$k ); + } else { + $this->setError("No items selected."); + return false; + } + } + + $cids = $k.'='.implode(' OR '.$k.'=', $cid); + $query = 'UPDATE '. $this->_tbl + . ' SET published = ' . (int)$publish + . ' WHERE ('.$cids.')' + ; + + $checkin = in_array('checked_out', array_keys($this->getProperties())); + if ($checkin) { + $query .= ' AND (checked_out = 0 OR checked_out = '.(int) $user_id.')'; + } + + $this->_db->setQuery( $query ); + if (!$this->_db->query()) { + $this->setError($this->_db->getErrorMsg()); + return false; + } + + if (count($cid) == 1 && $checkin) { + if ($this->_db->getAffectedRows() == 1) { + $this->checkin( $cid[0] ); + if ($this->$k == $cid[0]) { + $this->published = $publish; + } + } + } + $this->setError(''); + return true; + } + + /** + * Export item list to xml + * + * @access public + * @param boolean Map foreign keys to text values + */ + function toXML($mapKeysToText = false) + { + $xml = ' $v) { + if (is_array($v) or is_object($v) or $v === NULL) { + continue; + } + if ($k[0] == '_') { + // internal field + continue; + } + $xml .= '<'.$k.'>'; + } + $xml .= ''; + + return $xml; + } + + /** + * Add a directory where JTable should search for table types. You may + * either pass a string or an array of directories. + * + * @param string A path to search. + * @return array An array with directory elements + * @since 1.5 + */ + public static function addIncludePath($path = null) + { + static $paths; + + if ( ! isset($paths)) { + $paths = array(dirname(__FILE__).DS.'table'); + } + + // just force path to array + settype($path, 'array'); + + if ( ! empty( $path ) && ! in_array($path, $paths)) { + // loop through the path directories + foreach ($path as $dir) { + // no surrounding spaces allowed! + $dir = trim($dir); + + // add to the top of the search dirs + // so that custom paths are searched before core paths + array_unshift($paths, $dir); + } + } + return $paths; + } } diff --git a/vendor/joomla/libraries/joomla/database/table/menutypes.php b/vendor/joomla/libraries/joomla/database/table/menutypes.php index e112acd43..c28827414 100644 --- a/vendor/joomla/libraries/joomla/database/table/menutypes.php +++ b/vendor/joomla/libraries/joomla/database/table/menutypes.php @@ -49,7 +49,7 @@ function __construct( &$db ) */ function check() { - $this->menutype = JFilterInput::clean($this->menutype, 'menutype'); + $this->menutype = JFilterInput::getInstance()->clean($this->menutype, 'menutype'); if (empty($this->menutype)) { $this->setError( "Cannot save: Empty menu type" ); return false; diff --git a/vendor/joomla/libraries/joomla/document/document.php b/vendor/joomla/libraries/joomla/document/document.php index 81c5d7543..f4026d080 100644 --- a/vendor/joomla/libraries/joomla/document/document.php +++ b/vendor/joomla/libraries/joomla/document/document.php @@ -251,11 +251,10 @@ function __construct( $options = array()) * This method must be invoked as: *
  $document = &JDocument::getInstance();
* - * @access public * @param type $type The document type to instantiate * @return object The document object. */ - function &getInstance($type = 'html', $attributes = array()) + public static function &getInstance($type = 'html', $attributes = array()) { static $instances; diff --git a/vendor/joomla/libraries/joomla/document/error/error.php b/vendor/joomla/libraries/joomla/document/error/error.php index a8dd8ad67..f04610a5b 100644 --- a/vendor/joomla/libraries/joomla/document/error/error.php +++ b/vendor/joomla/libraries/joomla/document/error/error.php @@ -86,7 +86,7 @@ function render( $cache = false, $params = array()) // check template $directory = isset($params['directory']) ? $params['directory'] : 'templates'; - $template = isset($params['template']) ? JFilterInput::clean($params['template'], 'cmd') : 'system'; + $template = isset($params['template']) ? JFilterInput::getInstance()->clean($params['template'], 'cmd') : 'system'; if ( !file_exists( $directory.DS.$template.DS.$file) ) { $template = 'system'; diff --git a/vendor/joomla/libraries/joomla/document/html/html.php b/vendor/joomla/libraries/joomla/document/html/html.php index 4ecf31f9f..98bf26e36 100644 --- a/vendor/joomla/libraries/joomla/document/html/html.php +++ b/vendor/joomla/libraries/joomla/document/html/html.php @@ -201,7 +201,7 @@ function getBuffer($type = null, $name = null, $attribs = array()) * @param string $name oke The name of the element to render * @param string $content The content to be set in the buffer */ - function setBuffer($contents, $type, $name = null) + function setBuffer($contents, $type = null, $name = null) { $this->_buffer[$type][$name] = $contents; } @@ -218,8 +218,8 @@ function render( $caching = false, $params = array()) { // check $directory = isset($params['directory']) ? $params['directory'] : 'templates'; - $template = JFilterInput::clean($params['template'], 'cmd'); - $file = JFilterInput::clean($params['file'], 'cmd'); + $template = JFilterInput::getInstance()->clean($params['template'], 'cmd'); + $file = JFilterInput::getInstance()->clean($params['file'], 'cmd'); if ( !file_exists( $directory.DS.$template.DS.$file) ) { $template = 'system'; diff --git a/vendor/joomla/libraries/joomla/environment/response.php b/vendor/joomla/libraries/joomla/environment/response.php index 6210c3ef9..7b7227824 100644 --- a/vendor/joomla/libraries/joomla/environment/response.php +++ b/vendor/joomla/libraries/joomla/environment/response.php @@ -1,17 +1,4 @@ cachable = false; $GLOBALS['_JRESPONSE']->headers = array(); -$GLOBALS['_JRESPONSE']->body = array(); +$GLOBALS['_JRESPONSE']->body = array(); /** * JResponse Class - * + * * This class serves to provide the Joomla Framework with a common interface to access * response variables. This includes header and body. - * - * @static - * @package Joomla.Framework - * @subpackage Environment - * @since 1.5 + * + * @package Joomla.Framework + * @subpackage Environment + * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * @since 1.5 */ class JResponse { - /** - * Set/get cachable state for the response - * - * If $allow is set, sets the cachable state of the response. Always returns current state - * - * @static - * @param boolean $allow - * @return boolean True of browser caching should be allowed - * @since 1.5 - */ - function allowCache($allow = null) - { - if (!is_null($allow)) { - $GLOBALS['_JRESPONSE']->cachable = (bool) $allow; - } - return $GLOBALS['_JRESPONSE']->cachable; - } - - /** - * Set a header - * - * If $replace is true, replaces any headers already defined with that - * $name. - * - * @access public - * @param string $name - * @param string $value - * @param boolean $replace - */ - function setHeader($name, $value, $replace = false) - { - $name = (string) $name; - $value = (string) $value; - - if ($replace) - { - foreach ($GLOBALS['_JRESPONSE']->headers as $key => $header) { - if ($name == $header['name']) { - unset($GLOBALS['_JRESPONSE']->headers[$key]); - } - } - } - - $GLOBALS['_JRESPONSE']->headers[] = array( - 'name' => $name, - 'value' => $value - ); - } - - /** - * Return array of headers; - * - * @access public - * @return array - */ - function getHeaders() { - return $GLOBALS['_JRESPONSE']->headers; - } - - /** - * Clear headers - * - * @access public - */ - function clearHeaders() { - $GLOBALS['_JRESPONSE']->headers = array(); - } - - /** - * Send all headers - * - * @access public - * @return void - */ - function sendHeaders() - { - if (!headers_sent()) - { - foreach ($GLOBALS['_JRESPONSE']->headers as $header) - { - if ('status' == strtolower($header['name'])) - { - // 'status' headers indicate an HTTP status, and need to be handled slightly differently - header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']); - } else { - header($header['name'] . ': ' . $header['value']); - } - } - } - } - - /** - * Set body content - * - * If body content already defined, this will replace it. - * - * @access public - * @param string $content - */ - function setBody($content) { - $GLOBALS['_JRESPONSE']->body = array((string) $content); - } - - /** - * Prepend content to the body content - * - * @access public - * @param string $content - */ - function prependBody($content) { - array_unshift($GLOBALS['_JRESPONSE']->body, (string) $content); - } - - /** - * Append content to the body content - * - * @access public - * @param string $content - */ - function appendBody($content) { - array_push($GLOBALS['_JRESPONSE']->body, (string) $content); - } - - /** - * Return the body content - * - * @access public - * @param boolean $toArray Whether or not to return the body content as an - * array of strings or as a single string; defaults to false - * @return string|array - */ - function getBody($toArray = false) - { - if ($toArray) { - return $GLOBALS['_JRESPONSE']->body; - } - - ob_start(); - foreach ($GLOBALS['_JRESPONSE']->body as $content) { - echo $content; - } - return ob_get_clean(); - } - - /** - * Sends all headers prior to returning the string - * - * @access public - * @param boolean $compress If true, compress the data - * @return string - */ - function toString($compress = false) - { - $data = JResponse::getBody(); - - // Don't compress something if the server is going todo it anyway. Waste of time. - if($compress && !ini_get('zlib.output_compression') && ini_get('output_handler')!='ob_gzhandler') { - $data = JResponse::_compress($data); - } - - if (JResponse::allowCache() === false) - { - JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true ); // Expires in the past - JResponse::setHeader( 'Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true ); // Always modified - JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate', true ); // Extra CYA - JResponse::setHeader( 'Cache-Control', 'post-check=0, pre-check=0', false ); // HTTP/1.1 - JResponse::setHeader( 'Pragma', 'no-cache' ); // HTTP 1.0 - } - - JResponse::sendHeaders(); - return $data; - } - - /** - * Compress the data - * - * Checks the accept encoding of the browser and compresses the data before - * sending it to the client. - * - * @access public - * @param string data - * @return string compressed data - */ - function _compress( $data ) - { - $encoding = JResponse::_clientEncoding(); - - if (!$encoding) - return $data; - - if (!extension_loaded('zlib') || ini_get('zlib.output_compression')) { - return $data; - } - - if (headers_sent()) - return $data; - - if (connection_status() !== 0) - return $data; - - - $level = 4; //ideal level - - /* - $size = strlen($data); - $crc = crc32($data); - - $gzdata = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; - $gzdata .= gzcompress($data, $level); - - $gzdata = substr($gzdata, 0, strlen($gzdata) - 4); - $gzdata .= pack("V",$crc) . pack("V", $size); - */ - - $gzdata = gzencode($data, $level); - - JResponse::setHeader('Content-Encoding', $encoding); - JResponse::setHeader('X-Content-Encoded-By', 'Joomla! 1.5'); - - return $gzdata; - } - - /** - * check, whether client supports compressed data - * - * @access private - * @return boolean - */ - function _clientEncoding() - { - if (!isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { - return false; - } - - $encoding = false; - - if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { - $encoding = 'gzip'; - } - - if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { - $encoding = 'x-gzip'; - } - - return $encoding; - } + /** + * Set/get cachable state for the response + * + * If $allow is set, sets the cachable state of the response. Always returns current state + * + * @param boolean $allow + * @return boolean True of browser caching should be allowed + * @since 1.5 + */ + public static function allowCache($allow = null) + { + if ( ! is_null($allow)) { + $GLOBALS['_JRESPONSE']->cachable = (bool) $allow; + } + return $GLOBALS['_JRESPONSE']->cachable; + } + + /** + * Set a header + * + * If $replace is true, replaces any headers already defined with that + * $name. + * + * @param string $name + * @param string $value + * @param boolean $replace + */ + public static function setHeader($name, $value, $replace = false) + { + $name = (string)$name; + $value = (string)$value; + + if ($replace) { + foreach ($GLOBALS['_JRESPONSE']->headers as $key => $header) { + if ($name == $header['name']) { + unset($GLOBALS['_JRESPONSE']->headers[$key]); + } + } + } + + $GLOBALS['_JRESPONSE']->headers[] = array( + 'name' => $name, + 'value' => $value + ); + } + + /** + * Return array of headers; + * + * @return array + */ + public static function getHeaders() + { + return $GLOBALS['_JRESPONSE']->headers; + } + + /** + * Clear headers + */ + public static function clearHeaders() + { + $GLOBALS['_JRESPONSE']->headers = array(); + } + + /** + * Send all headers + * + * @return void + */ + public static function sendHeaders() + { + if ( ! headers_sent()) { + foreach ($GLOBALS['_JRESPONSE']->headers as $header) { + if ('status' == strtolower($header['name'])) { + // 'status' headers indicate an HTTP status, and need to be handled slightly differently + header(ucfirst(strtolower($header['name'])) . ': ' . $header['value'], null, (int) $header['value']); + } else { + header($header['name'] . ': ' . $header['value']); + } + } + } + } + + /** + * Set body content + * + * If body content already defined, this will replace it. + * + * @param string $content + */ + public static function setBody($content) + { + $GLOBALS['_JRESPONSE']->body = array((string)$content); + } + + /** + * Prepend content to the body content + * + * @param string $content + */ + public static function prependBody($content) + { + array_unshift($GLOBALS['_JRESPONSE']->body, (string) $content); + } + + /** + * Append content to the body content + * + * @param string $content + */ + public static function appendBody($content) + { + array_push($GLOBALS['_JRESPONSE']->body, (string)$content); + } + + /** + * Return the body content + * + * @param boolean $toArray Whether or not to return the body content as an + * array of strings or as a single string; defaults to false + * @return string|array + */ + public static function getBody($toArray = false) + { + if ($toArray) { + return $GLOBALS['_JRESPONSE']->body; + } + + ob_start(); + foreach ($GLOBALS['_JRESPONSE']->body as $content) { + echo $content; + } + return ob_get_clean(); + } + + /** + * Sends all headers prior to returning the string + * + * @param boolean $compress If true, compress the data + * @return string + */ + public static function toString($compress = false) + { + $data = JResponse::getBody(); + + // Don't compress something if the server is going todo it anyway. Waste of time. + if ($compress && ! ini_get('zlib.output_compression') && ini_get('output_handler') != 'ob_gzhandler') { + $data = JResponse::_compress($data); + } + + if (JResponse::allowCache() === false) { + JResponse::setHeader( 'Expires', 'Mon, 1 Jan 2001 00:00:00 GMT', true ); // Expires in the past + JResponse::setHeader( 'Last-Modified', gmdate("D, d M Y H:i:s") . ' GMT', true ); // Always modified + JResponse::setHeader( 'Cache-Control', 'no-store, no-cache, must-revalidate', true ); // Extra CYA + JResponse::setHeader( 'Cache-Control', 'post-check=0, pre-check=0', false ); // HTTP/1.1 + JResponse::setHeader( 'Pragma', 'no-cache' ); // HTTP 1.0 + } + + JResponse::sendHeaders(); + return $data; + } + + /** + * Compress the data + * + * Checks the accept encoding of the browser and compresses the data before + * sending it to the client. + * + * @param string data + * @return string compressed data + */ + protected static function _compress($data) + { + $encoding = JResponse::_clientEncoding(); + + if ( ! $encoding) + return $data; + + if ( ! extension_loaded('zlib') || ini_get('zlib.output_compression')) { + return $data; + } + + if (headers_sent()) + return $data; + + if (connection_status() !== 0) + return $data; + + $level = 4; //ideal level + + /* + $size = strlen($data); + $crc = crc32($data); + + $gzdata = "\x1f\x8b\x08\x00\x00\x00\x00\x00"; + $gzdata .= gzcompress($data, $level); + + $gzdata = substr($gzdata, 0, strlen($gzdata) - 4); + $gzdata .= pack("V",$crc) . pack("V", $size); + */ + + $gzdata = gzencode($data, $level); + + JResponse::setHeader('Content-Encoding', $encoding); + JResponse::setHeader('X-Content-Encoded-By', 'Joomla! 1.5'); + + return $gzdata; + } + + /** + * check, whether client supports compressed data + * + * @return boolean + */ + protected static function _clientEncoding() + { + if ( ! isset($_SERVER['HTTP_ACCEPT_ENCODING'])) { + return false; + } + + $encoding = false; + + if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) { + $encoding = 'gzip'; + } + + if (false !== strpos($_SERVER['HTTP_ACCEPT_ENCODING'], 'x-gzip')) { + $encoding = 'x-gzip'; + } + + return $encoding; + } } diff --git a/vendor/joomla/libraries/joomla/environment/uri.php b/vendor/joomla/libraries/joomla/environment/uri.php index 86965de9f..535148dda 100644 --- a/vendor/joomla/libraries/joomla/environment/uri.php +++ b/vendor/joomla/libraries/joomla/environment/uri.php @@ -1,804 +1,775 @@ parse($uri); - } - } - - /** - * Returns a reference to a global JURI object, only creating it - * if it doesn't already exist. - * - * This method must be invoked as: - *
  $uri =& JURI::getInstance([$uri]);
- * - * @static - * @param string $uri The URI to parse. [optional: if null uses script URI] - * @return JURI The URI object. - * @since 1.5 - */ - function &getInstance($uri = 'SERVER') - { - static $instances = array(); - - if (!isset ($instances[$uri])) - { - // Are we obtaining the URI from the server? - if ($uri == 'SERVER') - { - // Determine if the request was over SSL (HTTPS) - if (isset($_SERVER['HTTPS']) && !empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) { - $https = 's://'; - } else { - $https = '://'; - } - - /* - * Since we are assigning the URI from the server variables, we first need - * to determine if we are running on apache or IIS. If PHP_SELF and REQUEST_URI - * are present, we will assume we are running on apache. - */ - if (!empty ($_SERVER['PHP_SELF']) && !empty ($_SERVER['REQUEST_URI'])) { - - /* - * To build the entire URI we need to prepend the protocol, and the http host - * to the URI string. - */ - $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; - - /* - * Since we do not have REQUEST_URI to work with, we will assume we are - * running on IIS and will therefore need to work some magic with the SCRIPT_NAME and - * QUERY_STRING environment variables. - */ - - if (strlen($_SERVER['QUERY_STRING']) && strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']) === false) { - $theURI .= '?'.$_SERVER['QUERY_STRING']; - } - - } - else - { - // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS - $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; - - // If the query string exists append it to the URI string - if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { - $theURI .= '?' . $_SERVER['QUERY_STRING']; - } - } - - // Now we need to clean what we got since we can't trust the server var - // Need to check that the URI is fully decoded in case of multiple-encoded attack vectors. - $halt = 0; - while (true) - { - $last = $theURI; - $theURI = urldecode($theURI); - - // Check whether the last decode is equal to the first. - if ($theURI == $last) { - // Break out of the while if the URI is stable. - break; - } - else if (++$halt > 10) { - // Runaway check. URI has been seriously compromised. - jexit(); - } - } - - $theURI = str_replace('"', '"',$theURI); - $theURI = str_replace('<', '<',$theURI); - $theURI = str_replace('>', '>',$theURI); - $theURI = preg_replace('/eval\((.*)\)/', '', $theURI); - $theURI = preg_replace('/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', $theURI); - } - else - { - // We were given a URI - $theURI = $uri; - } - - // Create the new JURI instance - $instances[$uri] = new JURI($theURI); - } - return $instances[$uri]; - } - - /** - * Returns the base URI for the request. - * - * @access public - * @static - * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. - * @return string The base URI string - * @since 1.5 - */ - function base($pathonly = false) - { - static $base; - - // Get the base request path - if (!isset($base)) - { - $config =& JFactory::getConfig(); - $live_site = $config->getValue('config.live_site'); - if(trim($live_site) != '') { - $uri =& JURI::getInstance($live_site); - $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); - $base['path'] = rtrim($uri->toString( array('path')), '/\\'); - if(str_replace('\\', '/', JPATH_BASE) == str_replace('\\', '/', JPATH_ADMINISTRATOR)) { - $base['path'] .= '/administrator'; - } - } else { - $uri =& JURI::getInstance(); - $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); - - if (strpos(php_sapi_name(), 'cgi') !== false && !empty($_SERVER['REQUEST_URI']) && - (!ini_get('cgi.fix_pathinfo') || version_compare(PHP_VERSION, '5.2.4', '<'))) { - // CGI on PHP pre-5.2.4 with cgi.fix_pathinfo = 0. - - // In pre-rev. 240885 of main_cgi.c, SCRIPT_NAME doesn't conform the PHP spec., - // therefore we use PHP_SELF instead. - $base['path'] = rtrim(dirname(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])), '/\\'); - } else { - // Since PHP 5.2.4 we can trust SCRIPT_NAME; it conforms the spec. - $base['path'] = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); - } - } - } - - return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path']; - } - - /** - * Returns the root URI for the request. - * - * @access public - * @static - * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. - * @return string The root URI string - * @since 1.5 - */ - function root($pathonly = false, $path = null) - { - static $root; - - // Get the scheme - if(!isset($root)) - { - $uri =& JURI::getInstance(JURI::base()); - $root['prefix'] = $uri->toString( array('scheme', 'host', 'port') ); - $root['path'] = rtrim($uri->toString( array('path') ), '/\\'); - } - - // Get the scheme - if(isset($path)) { - $root['path'] = $path; - } - - return $pathonly === false ? $root['prefix'].$root['path'].'/' : $root['path']; - } - - /** - * Returns the URL for the request, minus the query - * - * @access public - * @return string - * @since 1.5 - */ - function current() - { - static $current; - - // Get the current URL - if (!isset($current)) - { - $uri = & JURI::getInstance(); - $current = $uri->toString( array('scheme', 'host', 'port', 'path')); - } - - return $current; - } - - /** - * Parse a given URI and populate the class fields - * - * @access public - * @param string $uri The URI string to parse - * @return boolean True on success - * @since 1.5 - */ - function parse($uri) - { - //Initialize variables - $retval = false; - - // Set the original URI to fall back on - $this->_uri = $uri; - - /* - * Parse the URI and populate the object fields. If URI is parsed properly, - * set method return value to true. - */ - if ($_parts = $this->_parseURL($uri)) { - $retval = true; - } - - //We need to replace & with & for parse_str to work right... - if(isset ($_parts['query']) && strpos($_parts['query'], '&')) { - $_parts['query'] = str_replace('&', '&', $_parts['query']); - } - - $this->_scheme = isset ($_parts['scheme']) ? $_parts['scheme'] : null; - $this->_user = isset ($_parts['user']) ? $_parts['user'] : null; - $this->_pass = isset ($_parts['pass']) ? $_parts['pass'] : null; - $this->_host = isset ($_parts['host']) ? $_parts['host'] : null; - $this->_port = isset ($_parts['port']) ? $_parts['port'] : null; - $this->_path = isset ($_parts['path']) ? $_parts['path'] : null; - $this->_query = isset ($_parts['query'])? $_parts['query'] : null; - $this->_fragment = isset ($_parts['fragment']) ? $_parts['fragment'] : null; - - //parse the query - - if(isset ($_parts['query'])) parse_str($_parts['query'], $this->_vars); - return $retval; - } - - /** - * Returns full uri string - * - * @access public - * @param array $parts An array specifying the parts to render - * @return string The rendered URI string - * @since 1.5 - */ - function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) - { - $query = $this->getQuery(); //make sure the query is created - - $uri = ''; - $uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme.'://' : '') : ''; - $uri .= in_array('user', $parts) ? $this->_user : ''; - $uri .= in_array('pass', $parts) ? (!empty ($this->_pass) ? ':' : '') .$this->_pass. (!empty ($this->_user) ? '@' : '') : ''; - $uri .= in_array('host', $parts) ? $this->_host : ''; - $uri .= in_array('port', $parts) ? (!empty ($this->_port) ? ':' : '').$this->_port : ''; - $uri .= in_array('path', $parts) ? $this->_path : ''; - $uri .= in_array('query', $parts) ? (!empty ($query) ? '?'.$query : '') : ''; - $uri .= in_array('fragment', $parts)? (!empty ($this->_fragment) ? '#'.$this->_fragment : '') : ''; - - return $uri; - } - - /** - * Adds a query variable and value, replacing the value if it - * already exists and returning the old value. - * - * @access public - * @param string $name Name of the query variable to set - * @param string $value Value of the query variable - * @return string Previous value for the query variable - * @since 1.5 - */ - function setVar($name, $value) - { - $tmp = @$this->_vars[$name]; - $this->_vars[$name] = $value; - - //empty the query - $this->_query = null; - - return $tmp; - } - - /** - * Returns a query variable by name - * - * @access public - * @param string $name Name of the query variable to get - * @return array Query variables - * @since 1.5 - */ - function getVar($name = null, $default=null) - { - if(isset($this->_vars[$name])) { - return $this->_vars[$name]; - } - return $default; - } - - /** - * Removes an item from the query string variables if it exists - * - * @access public - * @param string $name Name of variable to remove - * @since 1.5 - */ - function delVar($name) - { - if (in_array($name, array_keys($this->_vars))) - { - unset ($this->_vars[$name]); - - //empty the query - $this->_query = null; - } - } - - /** - * Sets the query to a supplied string in format: - * foo=bar&x=y - * - * @access public - * @param mixed (array|string) $query The query string - * @since 1.5 - */ - function setQuery($query) - { - if(!is_array($query)) { - if(strpos($query, '&') !== false) - { - $query = str_replace('&','&',$query); - } - parse_str($query, $this->_vars); - } - - if(is_array($query)) { - $this->_vars = $query; - } - - //empty the query - $this->_query = null; - } - - /** - * Returns flat query string - * - * @access public - * @return string Query string - * @since 1.5 - */ - function getQuery($toArray = false) - { - if($toArray) { - return $this->_vars; - } - - //If the query is empty build it first - if(is_null($this->_query)) { - $this->_query = $this->buildQuery($this->_vars); - } - - return $this->_query; - } - - /** - * Build a query from a array (reverse of the PHP parse_str()) - * - * @access public - * @return string The resulting query string - * @since 1.5 - * @see parse_str() - */ - function buildQuery ($params, $akey = null) - { - if ( !is_array($params) || count($params) == 0 ) { - return false; - } - - $out = array(); - - //reset in case we are looping - if( !isset($akey) && !count($out) ) { - unset($out); - $out = array(); - } - - foreach ( $params as $key => $val ) - { - if ( is_array($val) ) { - $out[] = JURI::buildQuery($val,$key); - continue; - } - - $thekey = ( !$akey ) ? $key : $akey.'['.$key.']'; - $out[] = $thekey."=".urlencode($val); - } - - return implode("&",$out); - } - - /** - * Get URI scheme (protocol) - * ie. http, https, ftp, etc... - * - * @access public - * @return string The URI scheme - * @since 1.5 - */ - function getScheme() { - return $this->_scheme; - } - - /** - * Set URI scheme (protocol) - * ie. http, https, ftp, etc... - * - * @access public - * @param string $scheme The URI scheme - * @since 1.5 - */ - function setScheme($scheme) { - $this->_scheme = $scheme; - } - - /** - * Get URI username - * returns the username, or null if no username was specified - * - * @access public - * @return string The URI username - * @since 1.5 - */ - function getUser() { - return $this->_user; - } - - /** - * Set URI username - * - * @access public - * @param string $user The URI username - * @since 1.5 - */ - function setUser($user) { - $this->_user = $user; - } - - /** - * Get URI password - * returns the password, or null if no password was specified - * - * @access public - * @return string The URI password - * @since 1.5 - */ - function getPass() { - return $this->_pass; - } - - /** - * Set URI password - * - * @access public - * @param string $pass The URI password - * @since 1.5 - */ - function setPass($pass) { - $this->_pass = $pass; - } - - /** - * Get URI host - * returns the hostname/ip, or null if no hostname/ip was specified - * - * @access public - * @return string The URI host - * @since 1.5 - */ - function getHost() { - return $this->_host; - } - - /** - * Set URI host - * - * @access public - * @param string $host The URI host - * @since 1.5 - */ - function setHost($host) { - $this->_host = $host; - } - - /** - * Get URI port - * returns the port number, or null if no port was specified - * - * @access public - * @return int The URI port number - */ - function getPort() { - return (isset ($this->_port)) ? $this->_port : null; - } - - /** - * Set URI port - * - * @access public - * @param int $port The URI port number - * @since 1.5 - */ - function setPort($port) { - $this->_port = $port; - } - - /** - * Gets the URI path string - * - * @access public - * @return string The URI path string - * @since 1.5 - */ - function getPath() { - return $this->_path; - } - - /** - * Set the URI path string - * - * @access public - * @param string $path The URI path string - * @since 1.5 - */ - function setPath($path) { - $this->_path = $this->_cleanPath($path); - } - - /** - * Get the URI archor string - * everything after the "#" - * - * @access public - * @return string The URI anchor string - * @since 1.5 - */ - function getFragment() { - return $this->_fragment; - } - - /** - * Set the URI anchor string - * everything after the "#" - * - * @access public - * @param string $anchor The URI anchor string - * @since 1.5 - */ - function setFragment($anchor) { - $this->_fragment = $anchor; - } - - /** - * Checks whether the current URI is using HTTPS - * - * @access public - * @return boolean True if using SSL via HTTPS - * @since 1.5 - */ - function isSSL() { - return $this->getScheme() == 'https' ? true : false; - } - - /** - * Checks if the supplied URL is internal - * - * @access public - * @param string $url The URL to check - * @return boolean True if Internal - * @since 1.5 - */ - function isInternal($url) { - $uri =& JURI::getInstance($url); - $base = $uri->toString(array('scheme', 'host', 'port', 'path')); - $host = $uri->toString(array('scheme', 'host', 'port')); - if(stripos($base, JURI::base()) !== 0 && !empty($host)) { - return false; - } - return true; - } - - /** - * Resolves //, ../ and ./ from a path and returns - * the result. Eg: - * - * /foo/bar/../boo.php => /foo/boo.php - * /foo/bar/../../boo.php => /boo.php - * /foo/bar/.././/boo.php => /foo/boo.php - * - * @access private - * @param string $uri The URI path to clean - * @return string Cleaned and resolved URI path - * @since 1.5 - */ - function _cleanPath($path) - { - $path = explode('/', preg_replace('#(/+)#', '/', $path)); - - for ($i = 0; $i < count($path); $i ++) { - if ($path[$i] == '.') { - unset ($path[$i]); - $path = array_values($path); - $i --; - - } - elseif ($path[$i] == '..' AND ($i > 1 OR ($i == 1 AND $path[0] != ''))) { - unset ($path[$i]); - unset ($path[$i -1]); - $path = array_values($path); - $i -= 2; - - } - elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { - unset ($path[$i]); - $path = array_values($path); - $i --; - - } else { - continue; - } - } - - return implode('/', $path); - } - - /** - * Backwards compatibility function for parse_url function - * - * This function solves different bugs in PHP versions lower then - * 4.4, will be deprecated in future versions. - * - * @access private - * @return array Associative array containing the URL parts - * @since 1.5 - * @see parse_url() - */ - function _parseURL($uri) - { - $parts = array(); - if (version_compare( phpversion(), '4.4' ) < 0) - { - $regex = "<^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?>"; - $matches = array(); - preg_match($regex, $uri, $matches, PREG_OFFSET_CAPTURE); - - $authority = @$matches[4][0]; - if (strpos($authority, '@') !== false) { - $authority = explode('@', $authority); - @list($parts['user'], $parts['pass']) = explode(':', $authority[0]); - $authority = $authority[1]; - } - - if (strpos($authority, ':') !== false) { - $authority = explode(':', $authority); - $parts['host'] = $authority[0]; - $parts['port'] = $authority[1]; - } else { - $parts['host'] = $authority; - } - - $parts['scheme'] = @$matches[2][0]; - $parts['path'] = @$matches[5][0]; - $parts['query'] = @$matches[7][0]; - $parts['fragment'] = @$matches[9][0]; - } - else - { - $parts = @parse_url($uri); - } - return $parts; - } - - public function __toString() - { - return $this->toString(); - } - - + /** + * Original URI + * + * @var string + */ + var $_uri = null; + + /** + * Protocol + * + * @var string + */ + var $_scheme = null; + + /** + * Host + * + * @var string + */ + var $_host = null; + + /** + * Port + * + * @var integer + */ + var $_port = null; + + /** + * Username + * + * @var string + */ + var $_user = null; + + /** + * Password + * + * @var string + */ + var $_pass = null; + + /** + * Path + * + * @var string + */ + var $_path = null; + + /** + * Query + * + * @var string + */ + var $_query = null; + + /** + * Anchor + * + * @var string + */ + var $_fragment = null; + + /** + * Query variable hash + * + * @var array + */ + var $_vars = array (); + + /** + * Constructor. + * You can pass a URI string to the constructor to initialize a specific URI. + * + * @param string $uri The optional URI string + */ + function __construct($uri = null) + { + if ($uri !== null) { + $this->parse($uri); + } + } + + /** + * Returns a reference to a global JURI object, only creating it + * if it doesn't already exist. + * + * This method must be invoked as: + *
  $uri =& JURI::getInstance([$uri]);
+ * + * @param string $uri The URI to parse. [optional: if null uses script URI] + * @return JURI The URI object. + * @since 1.5 + */ + public static function &getInstance($uri = 'SERVER') + { + static $instances = array(); + + if ( ! isset($instances[$uri])) { + // Are we obtaining the URI from the server? + if ($uri == 'SERVER') { + // Determine if the request was over SSL (HTTPS) + if (isset($_SERVER['HTTPS']) && ! empty($_SERVER['HTTPS']) && (strtolower($_SERVER['HTTPS']) != 'off')) { + $https = 's://'; + } else { + $https = '://'; + } + + /* + * Since we are assigning the URI from the server variables, we first need + * to determine if we are running on apache or IIS. If PHP_SELF and REQUEST_URI + * are present, we will assume we are running on apache. + */ + if ( ! empty ($_SERVER['PHP_SELF']) && !empty ($_SERVER['REQUEST_URI'])) { + + /* + * To build the entire URI we need to prepend the protocol, and the http host + * to the URI string. + */ + $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; + + /* + * Since we do not have REQUEST_URI to work with, we will assume we are + * running on IIS and will therefore need to work some magic with the SCRIPT_NAME and + * QUERY_STRING environment variables. + */ + if (strlen($_SERVER['QUERY_STRING']) && strpos($_SERVER['REQUEST_URI'], $_SERVER['QUERY_STRING']) === false) { + $theURI .= '?'.$_SERVER['QUERY_STRING']; + } + } else { + // IIS uses the SCRIPT_NAME variable instead of a REQUEST_URI variable... thanks, MS + $theURI = 'http' . $https . $_SERVER['HTTP_HOST'] . $_SERVER['SCRIPT_NAME']; + + // If the query string exists append it to the URI string + if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) { + $theURI .= '?' . $_SERVER['QUERY_STRING']; + } + } + + // Now we need to clean what we got since we can't trust the server var + // Need to check that the URI is fully decoded in case of multiple-encoded attack vectors. + $halt = 0; + while (true) { + $last = $theURI; + $theURI = urldecode($theURI); + + // Check whether the last decode is equal to the first. + if ($theURI == $last) { + // Break out of the while if the URI is stable. + break; + } elseif (++$halt > 10) { + // Runaway check. URI has been seriously compromised. + jexit(); + } + } + + $theURI = str_replace('"', '"',$theURI); + $theURI = str_replace('<', '<',$theURI); + $theURI = str_replace('>', '>',$theURI); + $theURI = preg_replace('/eval\((.*)\)/', '', $theURI); + $theURI = preg_replace('/[\\\"\\\'][\\s]*javascript:(.*)[\\\"\\\']/', '""', $theURI); + } else { + // We were given a URI + $theURI = $uri; + } + + // Create the new JURI instance + $instances[$uri] = new JURI($theURI); + } + return $instances[$uri]; + } + + /** + * Returns the base URI for the request. + * + * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. + * @return string The base URI string + * @since 1.5 + */ + public static function base($pathonly = false) + { + static $base; + + // Get the base request path + if ( ! isset($base)) { + $config =& JFactory::getConfig(); + $live_site = $config->getValue('config.live_site'); + if(trim($live_site) != '') { + $uri =& JURI::getInstance($live_site); + $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); + $base['path'] = rtrim($uri->toString( array('path')), '/\\'); + if(str_replace('\\', '/', JPATH_BASE) == str_replace('\\', '/', JPATH_ADMINISTRATOR)) { + $base['path'] .= '/administrator'; + } + } else { + $uri =& JURI::getInstance(); + $base['prefix'] = $uri->toString( array('scheme', 'host', 'port')); + + if (strpos(php_sapi_name(), 'cgi') !== false && !empty($_SERVER['REQUEST_URI']) && + (!ini_get('cgi.fix_pathinfo') || version_compare(PHP_VERSION, '5.2.4', '<'))) { + // CGI on PHP pre-5.2.4 with cgi.fix_pathinfo = 0. + + // In pre-rev. 240885 of main_cgi.c, SCRIPT_NAME doesn't conform the PHP spec., + // therefore we use PHP_SELF instead. + $base['path'] = rtrim(dirname(str_replace(array('"', '<', '>', "'"), '', $_SERVER["PHP_SELF"])), '/\\'); + } else { + // Since PHP 5.2.4 we can trust SCRIPT_NAME; it conforms the spec. + $base['path'] = rtrim(dirname($_SERVER['SCRIPT_NAME']), '/\\'); + } + } + } + + return $pathonly === false ? $base['prefix'].$base['path'].'/' : $base['path']; + } + + /** + * Returns the root URI for the request. + * + * @param boolean $pathonly If false, prepend the scheme, host and port information. Default is false. + * @return string The root URI string + * @since 1.5 + */ + public static function root($pathonly = false, $path = null) + { + static $root; + + // Get the scheme + if( ! isset($root)) { + $uri =& JURI::getInstance(JURI::base()); + $root['prefix'] = $uri->toString( array('scheme', 'host', 'port') ); + $root['path'] = rtrim($uri->toString( array('path') ), '/\\'); + } + + // Get the scheme + if(isset($path)) { + $root['path'] = $path; + } + + return $pathonly === false ? $root['prefix'].$root['path'].'/' : $root['path']; + } + + /** + * Returns the URL for the request, minus the query + * + * @return string + * @since 1.5 + */ + public static function current() + { + static $current; + + // Get the current URL + if ( ! isset($current)) { + $uri =& JURI::getInstance(); + $current = $uri->toString(array('scheme', 'host', 'port', 'path')); + } + + return $current; + } + + /** + * Parse a given URI and populate the class fields + * + * @access public + * @param string $uri The URI string to parse + * @return boolean True on success + * @since 1.5 + */ + function parse($uri) + { + //Initialize variables + $retval = false; + + // Set the original URI to fall back on + $this->_uri = $uri; + + /* + * Parse the URI and populate the object fields. If URI is parsed properly, + * set method return value to true. + */ + if ($_parts = $this->_parseURL($uri)) { + $retval = true; + } + + //We need to replace & with & for parse_str to work right... + if(isset ($_parts['query']) && strpos($_parts['query'], '&')) { + $_parts['query'] = str_replace('&', '&', $_parts['query']); + } + + $this->_scheme = isset ($_parts['scheme']) ? $_parts['scheme'] : null; + $this->_user = isset ($_parts['user']) ? $_parts['user'] : null; + $this->_pass = isset ($_parts['pass']) ? $_parts['pass'] : null; + $this->_host = isset ($_parts['host']) ? $_parts['host'] : null; + $this->_port = isset ($_parts['port']) ? $_parts['port'] : null; + $this->_path = isset ($_parts['path']) ? $_parts['path'] : null; + $this->_query = isset ($_parts['query'])? $_parts['query'] : null; + $this->_fragment = isset ($_parts['fragment']) ? $_parts['fragment'] : null; + + //parse the query + if(isset ($_parts['query'])) parse_str($_parts['query'], $this->_vars); + return $retval; + } + + /** + * Returns full uri string + * + * @access public + * @param array $parts An array specifying the parts to render + * @return string The rendered URI string + * @since 1.5 + */ + function toString($parts = array('scheme', 'user', 'pass', 'host', 'port', 'path', 'query', 'fragment')) + { + $query = $this->getQuery(); //make sure the query is created + + $uri = ''; + $uri .= in_array('scheme', $parts) ? (!empty($this->_scheme) ? $this->_scheme.'://' : '') : ''; + $uri .= in_array('user', $parts) ? $this->_user : ''; + $uri .= in_array('pass', $parts) ? (!empty ($this->_pass) ? ':' : '') .$this->_pass. (!empty ($this->_user) ? '@' : '') : ''; + $uri .= in_array('host', $parts) ? $this->_host : ''; + $uri .= in_array('port', $parts) ? (!empty ($this->_port) ? ':' : '').$this->_port : ''; + $uri .= in_array('path', $parts) ? $this->_path : ''; + $uri .= in_array('query', $parts) ? (!empty ($query) ? '?'.$query : '') : ''; + $uri .= in_array('fragment', $parts)? (!empty ($this->_fragment) ? '#'.$this->_fragment : '') : ''; + + return $uri; + } + + /** + * Adds a query variable and value, replacing the value if it + * already exists and returning the old value. + * + * @access public + * @param string $name Name of the query variable to set + * @param string $value Value of the query variable + * @return string Previous value for the query variable + * @since 1.5 + */ + function setVar($name, $value) + { + $tmp = @$this->_vars[$name]; + $this->_vars[$name] = $value; + + //empty the query + $this->_query = null; + + return $tmp; + } + + /** + * Returns a query variable by name + * + * @access public + * @param string $name Name of the query variable to get + * @return array Query variables + * @since 1.5 + */ + function getVar($name = null, $default=null) + { + if(isset($this->_vars[$name])) { + return $this->_vars[$name]; + } + return $default; + } + + /** + * Removes an item from the query string variables if it exists + * + * @access public + * @param string $name Name of variable to remove + * @since 1.5 + */ + function delVar($name) + { + if (in_array($name, array_keys($this->_vars))) { + unset ($this->_vars[$name]); + + //empty the query + $this->_query = null; + } + } + + /** + * Sets the query to a supplied string in format: + * foo=bar&x=y + * + * @access public + * @param mixed (array|string) $query The query string + * @since 1.5 + */ + function setQuery($query) + { + if ( ! is_array($query)) { + if (strpos($query, '&') !== false) { + $query = str_replace('&','&',$query); + } + parse_str($query, $this->_vars); + } + + if (is_array($query)) { + $this->_vars = $query; + } + + //empty the query + $this->_query = null; + } + + /** + * Returns flat query string + * + * @access public + * @return string Query string + * @since 1.5 + */ + function getQuery($toArray = false) + { + if ($toArray) { + return $this->_vars; + } + + //If the query is empty build it first + if (is_null($this->_query)) { + $this->_query = $this->buildQuery($this->_vars); + } + + return $this->_query; + } + + /** + * Build a query from a array (reverse of the PHP parse_str()) + * + * @access public + * @return string The resulting query string + * @since 1.5 + * @see parse_str() + */ + function buildQuery ($params, $akey = null) + { + if ( ! is_array($params) || count($params) == 0) { + return false; + } + + $out = array(); + + //reset in case we are looping + if ( ! isset($akey) && !count($out)) { + unset($out); + $out = array(); + } + + foreach ($params as $key => $val) { + if (is_array($val)) { + $out[] = JURI::buildQuery($val,$key); + continue; + } + + $thekey = ( !$akey ) ? $key : $akey.'['.$key.']'; + $out[] = $thekey."=".urlencode($val); + } + + return implode("&",$out); + } + + /** + * Get URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @access public + * @return string The URI scheme + * @since 1.5 + */ + function getScheme() { + return $this->_scheme; + } + + /** + * Set URI scheme (protocol) + * ie. http, https, ftp, etc... + * + * @access public + * @param string $scheme The URI scheme + * @since 1.5 + */ + function setScheme($scheme) + { + $this->_scheme = $scheme; + } + + /** + * Get URI username + * returns the username, or null if no username was specified + * + * @access public + * @return string The URI username + * @since 1.5 + */ + function getUser() + { + return $this->_user; + } + + /** + * Set URI username + * + * @access public + * @param string $user The URI username + * @since 1.5 + */ + function setUser($user) + { + $this->_user = $user; + } + + /** + * Get URI password + * returns the password, or null if no password was specified + * + * @access public + * @return string The URI password + * @since 1.5 + */ + function getPass() + { + return $this->_pass; + } + + /** + * Set URI password + * + * @access public + * @param string $pass The URI password + * @since 1.5 + */ + function setPass($pass) + { + $this->_pass = $pass; + } + + /** + * Get URI host + * returns the hostname/ip, or null if no hostname/ip was specified + * + * @access public + * @return string The URI host + * @since 1.5 + */ + function getHost() + { + return $this->_host; + } + + /** + * Set URI host + * + * @access public + * @param string $host The URI host + * @since 1.5 + */ + function setHost($host) + { + $this->_host = $host; + } + + /** + * Get URI port + * returns the port number, or null if no port was specified + * + * @access public + * @return int The URI port number + */ + function getPort() + { + return $this->_port; + } + + /** + * Set URI port + * + * @access public + * @param int $port The URI port number + * @since 1.5 + */ + function setPort($port) + { + $this->_port = $port; + } + + /** + * Gets the URI path string + * + * @access public + * @return string The URI path string + * @since 1.5 + */ + function getPath() + { + return $this->_path; + } + + /** + * Set the URI path string + * + * @access public + * @param string $path The URI path string + * @since 1.5 + */ + function setPath($path) + { + $this->_path = $this->_cleanPath($path); + } + + /** + * Get the URI archor string + * everything after the "#" + * + * @access public + * @return string The URI anchor string + * @since 1.5 + */ + function getFragment() + { + return $this->_fragment; + } + + /** + * Set the URI anchor string + * everything after the "#" + * + * @access public + * @param string $anchor The URI anchor string + * @since 1.5 + */ + function setFragment($anchor) + { + $this->_fragment = $anchor; + } + + /** + * Checks whether the current URI is using HTTPS + * + * @access public + * @return boolean True if using SSL via HTTPS + * @since 1.5 + */ + function isSSL() + { + return $this->getScheme() == 'https' ? true : false; + } + + /** + * Checks if the supplied URL is internal + * + * @param string $url The URL to check + * @return boolean True if Internal + * @since 1.5 + */ + public static function isInternal($url) { + $uri =& JURI::getInstance($url); + $base = $uri->toString(array('scheme', 'host', 'port', 'path')); + $host = $uri->toString(array('scheme', 'host', 'port')); + if (stripos($base, JURI::base()) !== 0 && ! empty($host)) { + return false; + } + return true; + } + + /** + * Resolves //, ../ and ./ from a path and returns + * the result. Eg: + * + * /foo/bar/../boo.php => /foo/boo.php + * /foo/bar/../../boo.php => /boo.php + * /foo/bar/.././/boo.php => /foo/boo.php + * + * @access private + * @param string $uri The URI path to clean + * @return string Cleaned and resolved URI path + * @since 1.5 + */ + function _cleanPath($path) + { + $path = explode('/', preg_replace('#(/+)#', '/', $path)); + + for ($i = 0; $i < count($path); $i ++) { + if ($path[$i] == '.') { + unset ($path[$i]); + $path = array_values($path); + $i --; + } elseif ($path[$i] == '..' AND ($i > 1 OR ($i == 1 AND $path[0] != ''))) { + unset ($path[$i]); + unset ($path[$i -1]); + $path = array_values($path); + $i -= 2; + } elseif ($path[$i] == '..' AND $i == 1 AND $path[0] == '') { + unset ($path[$i]); + $path = array_values($path); + $i --; + } else { + continue; + } + } + + return implode('/', $path); + } + + /** + * Backwards compatibility function for parse_url function + * + * This function solves different bugs in PHP versions lower then + * 4.4, will be deprecated in future versions. + * + * @access private + * @return array Associative array containing the URL parts + * @since 1.5 + * @see parse_url() + */ + function _parseURL($uri) + { + $parts = array(); + if (version_compare( phpversion(), '4.4' ) < 0) { + $regex = "<^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\\?([^#]*))?(#(.*))?>"; + $matches = array(); + preg_match($regex, $uri, $matches, PREG_OFFSET_CAPTURE); + + $authority = @$matches[4][0]; + if (strpos($authority, '@') !== false) { + $authority = explode('@', $authority); + @list($parts['user'], $parts['pass']) = explode(':', $authority[0]); + $authority = $authority[1]; + } + + if (strpos($authority, ':') !== false) { + $authority = explode(':', $authority); + $parts['host'] = $authority[0]; + $parts['port'] = $authority[1]; + } else { + $parts['host'] = $authority; + } + + $parts['scheme'] = @$matches[2][0]; + $parts['path'] = @$matches[5][0]; + $parts['query'] = @$matches[7][0]; + $parts['fragment'] = @$matches[9][0]; + } else { + $parts = @parse_url($uri); + } + return $parts; + } + + public function __toString() + { + return $this->toString(); + } } diff --git a/vendor/joomla/libraries/joomla/error/error.php b/vendor/joomla/libraries/joomla/error/error.php index 5691d8efe..9d5167c8a 100644 --- a/vendor/joomla/libraries/joomla/error/error.php +++ b/vendor/joomla/libraries/joomla/error/error.php @@ -71,7 +71,7 @@ class JError * @return boolean True if argument is an exception, false otherwise. * @since 1.5 */ - static public function isError(& $object) + public static function isError(& $object) { if (!is_object($object)) { return false; @@ -88,7 +88,7 @@ static public function isError(& $object) * @return mixed Last exception object in the error stack or boolean false if none exist * @since 1.5 */ - static public function & getError($unset = false) + public static function & getError($unset = false) { if (!isset($GLOBALS['_JERROR_STACK'][0])) { $false = false; @@ -110,7 +110,7 @@ static public function & getError($unset = false) * @return array Chronological array of errors that have been stored during script execution * @since 1.5 */ - static public function & getErrors() + public static function & getErrors() { return $GLOBALS['_JERROR_STACK']; } @@ -128,7 +128,7 @@ static public function & getErrors() * * @see JException */ - static public function & raise($level, $code, $msg, $info = null, $backtrace = false) + public static function & raise($level, $code, $msg, $info = null, $backtrace = false) { jimport('joomla.error.exception'); @@ -166,7 +166,7 @@ static public function & raise($level, $code, $msg, $info = null, $backtrace = f * @return object $error The configured JError object * @since 1.5 */ - static public function & raiseError($code, $msg, $info = null) + public static function & raiseError($code, $msg, $info = null) { $reference = & JError::raise(E_ERROR, $code, $msg, $info, true); return $reference; @@ -182,7 +182,7 @@ static public function & raiseError($code, $msg, $info = null) * @return object $error The configured JError object * @since 1.5 */ - static public function & raiseWarning($code, $msg, $info = null) + public static function & raiseWarning($code, $msg, $info = null) { $reference = & JError::raise(E_WARNING, $code, $msg, $info); return $reference; @@ -198,7 +198,7 @@ static public function & raiseWarning($code, $msg, $info = null) * @return object $error The configured JError object * @since 1.5 */ - static public function & raiseNotice($code, $msg, $info = null) + public static function & raiseNotice($code, $msg, $info = null) { $reference = & JError::raise(E_NOTICE, $code, $msg, $info); return $reference; @@ -212,7 +212,7 @@ static public function & raiseNotice($code, $msg, $info = null) * @return array All error handling details * @since 1.5 */ - static public function getErrorHandling( $level ) + public static function getErrorHandling( $level ) { return $GLOBALS['_JERROR_HANDLERS'][$level]; } @@ -242,7 +242,7 @@ static public function getErrorHandling( $level ) * @return mixed True on success, or a JException object if failed. * @since 1.5 */ - static public function setErrorHandling($level, $mode, $options = null) + public static function setErrorHandling($level, $mode, $options = null) { $levels = $GLOBALS['_JERROR_LEVELS']; @@ -291,7 +291,7 @@ static public function setErrorHandling($level, $mode, $options = null) * @access public * @see set_error_handler */ - static public function attachHandler() + public static function attachHandler() { set_error_handler(array('JError', 'customErrorHandler')); } @@ -302,7 +302,7 @@ static public function attachHandler() * @access public * @see restore_error_handler */ - static public function detachHandler() + public static function detachHandler() { restore_error_handler(); } @@ -322,7 +322,7 @@ static public function detachHandler() * @return boolean True on success; false if the level already has been registered * @since 1.5 */ - static public function registerErrorLevel( $level, $name, $handler = 'ignore' ) + public static function registerErrorLevel( $level, $name, $handler = 'ignore' ) { if( isset($GLOBALS['_JERROR_LEVELS'][$level]) ) { return false; @@ -341,7 +341,7 @@ static public function registerErrorLevel( $level, $name, $handler = 'ignore' ) * @return mixed Human readable error level name or boolean false if it doesn't exist * @since 1.5 */ - static public function translateErrorLevel( $level ) + public static function translateErrorLevel( $level ) { if( isset($GLOBALS['_JERROR_LEVELS'][$level]) ) { return $GLOBALS['_JERROR_LEVELS'][$level]; @@ -361,7 +361,7 @@ static public function translateErrorLevel( $level ) * * @see raise() */ - static public function & handleIgnore(&$error, $options) + public static function & handleIgnore(&$error, $options) { return $error; } @@ -378,7 +378,7 @@ static public function & handleIgnore(&$error, $options) * * @see raise() */ - static public function & handleEcho(&$error, $options) + public static function & handleEcho(&$error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); @@ -408,7 +408,7 @@ static public function & handleEcho(&$error, $options) * * @see raise() */ - static public function & handleVerbose(& $error, $options) + public static function & handleVerbose(& $error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); $info = $error->get('info'); @@ -443,7 +443,7 @@ static public function & handleVerbose(& $error, $options) * * @see raise() */ - static public function & handleDie(& $error, $options) + public static function & handleDie(& $error, $options) { $level_human = JError::translateErrorLevel($error->get('level')); @@ -473,7 +473,7 @@ static public function & handleDie(& $error, $options) * * @see raise() */ - static public function & handleMessage(& $error, $options) + public static function & handleMessage(& $error, $options) { global $mainframe; $type = ($error->get('level') == E_NOTICE) ? 'notice' : 'error'; @@ -493,7 +493,7 @@ static public function & handleMessage(& $error, $options) * * @see raise() */ - static public function & handleLog(& $error, $options) + public static function & handleLog(& $error, $options) { static $log; @@ -525,7 +525,7 @@ static public function & handleLog(& $error, $options) * * @see raise() */ - static public function &handleCallback( &$error, $options ) + public static function &handleCallback( &$error, $options ) { $result = call_user_func( $options, $error ); return $result; @@ -539,7 +539,7 @@ static public function &handleCallback( &$error, $options ) * @return void * @since 1.5 */ - static public function customErrorPage(& $error) + public static function customErrorPage(& $error) { // Initialize variables jimport('joomla.document.document'); @@ -577,7 +577,7 @@ static public function customErrorPage(& $error) $app->close(0); } - static public function customErrorHandler($level, $msg) + public static function customErrorHandler($level, $msg) { JError::raise($level, '', $msg); } diff --git a/vendor/joomla/libraries/joomla/filesystem/file.php b/vendor/joomla/libraries/joomla/filesystem/file.php index 7de4531d9..925990d47 100644 --- a/vendor/joomla/libraries/joomla/filesystem/file.php +++ b/vendor/joomla/libraries/joomla/filesystem/file.php @@ -1,17 +1,4 @@ 0) { - return $chunks[$chunksCount]; - } - - return false; - } - - /** - * Strips the last extension off a file name - * - * @param string $file The file name - * @return string The file name without the extension - * @since 1.5 - */ - function stripExt($file) { - return preg_replace('#\.[^.]*$#', '', $file); - } - - /** - * Makes file name safe to use - * - * @param string $file The name of the file [not full path] - * @return string The sanitised string - * @since 1.5 - */ - function makeSafe($file) { - $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#'); - return preg_replace($regex, '', $file); - } - - /** - * Copies a file - * - * @param string $src The path to the source file - * @param string $dest The path to the destination file - * @param string $path An optional base path to prefix to the file names - * @return boolean True on success - * @since 1.5 - */ - function copy($src, $dest, $path = null) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - // Prepend a base path if it exists - if ($path) { - $src = JPath::clean($path.DS.$src); - $dest = JPath::clean($path.DS.$dest); - } - - //Check src path - if (!is_readable($src)) { - JError::raiseWarning(21, 'JFile::copy: ' . JText::_('Cannot find or read file') . ": '$src'"); - return false; - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - // If the parent folder doesn't exist we must create it - if (!file_exists(dirname($dest))) { - jimport('joomla.filesystem.folder'); - JFolder::create(dirname($dest)); - } - - //Translate the destination path for the FTP account - $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); - if (!$ftp->store($src, $dest)) { - // FTP connector throws an error - return false; - } - $ret = true; - } else { - if (!@ copy($src, $dest)) { - JError::raiseWarning(21, JText::_('Copy failed')); - return false; - } - $ret = true; - } - return $ret; - } - - /** - * Delete a file or array of files - * - * @param mixed $file The file name or an array of file names - * @return boolean True on success - * @since 1.5 - */ - function delete($file) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - if (is_array($file)) { - $files = $file; - } else { - $files[] = $file; - } - - // Do NOT use ftp if it is not enabled - if ($FTPOptions['enabled'] == 1) - { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - } - - foreach ($files as $file) - { - $file = JPath::clean($file); - - // Try making the file writeable first. If it's read-only, it can't be deleted - // on Windows, even if the parent folder is writeable - @chmod($file, 0777); - - // In case of restricted permissions we zap it one way or the other - // as long as the owner is either the webserver or the ftp - if (@unlink($file)) { - // Do nothing - } elseif ($FTPOptions['enabled'] == 1) { - $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); - if (!$ftp->delete($file)) { - // FTP connector throws an error - return false; - } - } else { - $filename = basename($file); - JError::raiseWarning('SOME_ERROR_CODE', JText::_('Delete failed') . ": '$filename'"); - return false; - } - } - - return true; - } - - /** - * Moves a file - * - * @param string $src The path to the source file - * @param string $dest The path to the destination file - * @param string $path An optional base path to prefix to the file names - * @return boolean True on success - * @since 1.5 - */ - function move($src, $dest, $path = '') - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - if ($path) { - $src = JPath::clean($path.DS.$src); - $dest = JPath::clean($path.DS.$dest); - } - - //Check src path - if (!is_readable($src) && !is_writable($src)) { - JError::raiseWarning(21, 'JFile::move: ' . JText::_('Cannot find, read or write file') . ": '$src'"); - return false; - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - //Translate path for the FTP account - $src = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $src), '/'); - $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); - - // Use FTP rename to simulate move - if (!$ftp->rename($src, $dest)) { - JError::raiseWarning(21, JText::_('Rename failed')); - return false; - } - } else { - if (!@ rename($src, $dest)) { - JError::raiseWarning(21, JText::_('Rename failed')); - return false; - } - } - return true; - } - - /** - * Read the contents of a file - * - * @param string $filename The full file path - * @param boolean $incpath Use include path - * @param int $amount Amount of file to read - * @param int $chunksize Size of chunks to read - * @param int $offset Offset of the file - * @return mixed Returns file contents or boolean False if failed - * @since 1.5 - */ - function read($filename, $incpath = false, $amount = 0, $chunksize = 8192, $offset = 0) - { - // Initialize variables - $data = null; - if($amount && $chunksize > $amount) { $chunksize = $amount; } - if (false === $fh = fopen($filename, 'rb', $incpath)) { - JError::raiseWarning(21, 'JFile::read: '.JText::_('Unable to open file') . ": '$filename'"); - return false; - } - clearstatcache(); - if($offset) fseek($fh, $offset); - if ($fsize = @ filesize($filename)) { - if($amount && $fsize > $amount) { - $data = fread($fh, $amount); - } else { - $data = fread($fh, $fsize); - } - } else { - $data = ''; - $x = 0; - // While its: - // 1: Not the end of the file AND - // 2a: No Max Amount set OR - // 2b: The length of the data is less than the max amount we want - while (!feof($fh) && (!$amount || strlen($data) < $amount)) { - $data .= fread($fh, $chunksize); - } - } - fclose($fh); - - return $data; - } - - /** - * Write contents to a file - * - * @param string $file The full file path - * @param string $buffer The buffer to write - * @return boolean True on success - * @since 1.5 - */ - function write($file, $buffer) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - - // If the destination directory doesn't exist we need to create it - if (!file_exists(dirname($file))) { - jimport('joomla.filesystem.folder'); - JFolder::create(dirname($file)); - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - // Translate path for the FTP account and use FTP write buffer to file - $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); - $ret = $ftp->write($file, $buffer); - } else { - $file = JPath::clean($file); - $ret = file_put_contents($file, $buffer); - } - return $ret; - } - - /** - * Moves an uploaded file to a destination folder - * - * @param string $src The name of the php (temporary) uploaded file - * @param string $dest The path (including filename) to move the uploaded file to - * @return boolean True on success - * @since 1.5 - */ - function upload($src, $dest) - { - // Initialize variables - jimport('joomla.client.helper'); - $FTPOptions = JClientHelper::getCredentials('ftp'); - $ret = false; - - // Ensure that the path is valid and clean - $dest = JPath::clean($dest); - - // Create the destination directory if it does not exist - $baseDir = dirname($dest); - if (!file_exists($baseDir)) { - jimport('joomla.filesystem.folder'); - JFolder::create($baseDir); - } - - if ($FTPOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); - - //Translate path for the FTP account - $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); - - // Copy the file to the destination directory - if (is_uploaded_file($src) && $ftp->store($src, $dest)) - { - $ret = true; - unlink($src); - } else { - JError::raiseWarning(21, JText::_('WARNFS_ERR02')); - } - } else { - if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors - if (JPath::setPermissions($dest)) { - $ret = true; - } else { - JError::raiseWarning(21, JText::_('WARNFS_ERR01')); - } - } else { - JError::raiseWarning(21, JText::_('WARNFS_ERR02')); - } - } - return $ret; - } - - /** - * Wrapper for the standard file_exists function - * - * @param string $file File path - * @return boolean True if path is a file - * @since 1.5 - */ - function exists($file) - { - return is_file(JPath::clean($file)); - } - - /** - * Returns the name, sans any path - * - * param string $file File path - * @return string filename - * @since 1.5 - */ - function getName($file) { - $slash = strrpos($file, DS); - if ($slash !== false) { - return substr($file, $slash + 1); - } else { - return $file; - } - } + /** + * Gets the extension of a file name + * + * @param string $file The file name + * @return string The file extension + * @since 1.5 + */ + public static function getExt($file) + { + $chunks = explode('.', $file); + $chunksCount = count($chunks) - 1; + + if ($chunksCount > 0) { + return $chunks[$chunksCount]; + } + + return false; + } + + /** + * Strips the last extension off a file name + * + * @param string $file The file name + * @return string The file name without the extension + * @since 1.5 + */ + public static function stripExt($file) + { + return preg_replace('#\.[^.]*$#', '', $file); + } + + /** + * Makes file name safe to use + * + * @param string $file The name of the file [not full path] + * @return string The sanitised string + * @since 1.5 + */ + public static function makeSafe($file) + { + $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#'); + return preg_replace($regex, '', $file); + } + + /** + * Copies a file + * + * @param string $src The path to the source file + * @param string $dest The path to the destination file + * @param string $path An optional base path to prefix to the file names + * @return boolean True on success + * @since 1.5 + */ + public static function copy($src, $dest, $path = null) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + // Prepend a base path if it exists + if ($path) { + $src = JPath::clean($path.DS.$src); + $dest = JPath::clean($path.DS.$dest); + } + + //Check src path + if ( ! is_readable($src)) { + JError::raiseWarning(21, 'JFile::copy: '.JText::_('Cannot find or read file').": '$src'"); + return false; + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + // If the parent folder doesn't exist we must create it + if ( ! file_exists(dirname($dest))) { + jimport('joomla.filesystem.folder'); + JFolder::create(dirname($dest)); + } + + //Translate the destination path for the FTP account + $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); + if (!$ftp->store($src, $dest)) { + // FTP connector throws an error + return false; + } + $ret = true; + } else { + if (! @copy($src, $dest)) { + JError::raiseWarning(21, JText::_('Copy failed')); + return false; + } + $ret = true; + } + return $ret; + } + + /** + * Delete a file or array of files + * + * @param mixed $file The file name or an array of file names + * @return boolean True on success + * @since 1.5 + */ + public static function delete($file) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + if (is_array($file)) { + $files = $file; + } else { + $files[] = $file; + } + + // Do NOT use ftp if it is not enabled + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = & JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + } + + foreach ($files as $file) { + $file = JPath::clean($file); + + // Try making the file writeable first. If it's read-only, it can't be deleted + // on Windows, even if the parent folder is writeable + @chmod($file, 0777); + + // In case of restricted permissions we zap it one way or the other + // as long as the owner is either the webserver or the ftp + if (@unlink($file)) { + // Do nothing + } elseif ($FTPOptions['enabled'] == 1) { + $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); + if (!$ftp->delete($file)) { + // FTP connector throws an error + return false; + } + } else { + $filename = basename($file); + JError::raiseWarning('SOME_ERROR_CODE', JText::_('Delete failed') . ": '$filename'"); + return false; + } + } + + return true; + } + + /** + * Moves a file + * + * @param string $src The path to the source file + * @param string $dest The path to the destination file + * @param string $path An optional base path to prefix to the file names + * @return boolean True on success + * @since 1.5 + */ + public static function move($src, $dest, $path = '') + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + if ($path) { + $src = JPath::clean($path.DS.$src); + $dest = JPath::clean($path.DS.$dest); + } + + //Check src path + if ( ! is_readable($src) && !is_writable($src)) { + JError::raiseWarning(21, 'JFile::move: '.JText::_('Cannot find, read or write file').": '$src'"); + return false; + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + //Translate path for the FTP account + $src = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $src), '/'); + $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); + + // Use FTP rename to simulate move + if (!$ftp->rename($src, $dest)) { + JError::raiseWarning(21, JText::_('Rename failed')); + return false; + } + } else { + if (!@ rename($src, $dest)) { + JError::raiseWarning(21, JText::_('Rename failed')); + return false; + } + } + return true; + } + + /** + * Read the contents of a file + * + * @param string $filename The full file path + * @param boolean $incpath Use include path + * @param int $amount Amount of file to read + * @param int $chunksize Size of chunks to read + * @param int $offset Offset of the file + * @return mixed Returns file contents or boolean False if failed + * @since 1.5 + */ + public static function read($filename, $incpath = false, $amount = 0, $chunksize = 8192, $offset = 0) + { + // Initialize variables + $data = null; + if($amount && $chunksize > $amount) { + $chunksize = $amount; + } + if (false === $fh = fopen($filename, 'rb', $incpath)) { + JError::raiseWarning(21, 'JFile::read: '.JText::_('Unable to open file') . ": '$filename'"); + return false; + } + clearstatcache(); + if ($offset) fseek($fh, $offset); + if ($fsize = @filesize($filename)) { + if($amount && $fsize > $amount) { + $data = fread($fh, $amount); + } else { + $data = fread($fh, $fsize); + } + } else { + $data = ''; + $x = 0; + // While its: + // 1: Not the end of the file AND + // 2a: No Max Amount set OR + // 2b: The length of the data is less than the max amount we want + while (!feof($fh) && (!$amount || strlen($data) < $amount)) { + $data .= fread($fh, $chunksize); + } + } + fclose($fh); + + return $data; + } + + /** + * Write contents to a file + * + * @param string $file The full file path + * @param string $buffer The buffer to write + * @return boolean True on success + * @since 1.5 + */ + public static function write($file, $buffer) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + + // If the destination directory doesn't exist we need to create it + if (!file_exists(dirname($file))) { + jimport('joomla.filesystem.folder'); + JFolder::create(dirname($file)); + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + // Translate path for the FTP account and use FTP write buffer to file + $file = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $file), '/'); + $ret = $ftp->write($file, $buffer); + } else { + $file = JPath::clean($file); + $ret = file_put_contents($file, $buffer); + } + return $ret; + } + + /** + * Moves an uploaded file to a destination folder + * + * @param string $src The name of the php (temporary) uploaded file + * @param string $dest The path (including filename) to move the uploaded file to + * @return boolean True on success + * @since 1.5 + */ + public static function upload($src, $dest) + { + // Initialize variables + jimport('joomla.client.helper'); + $FTPOptions = JClientHelper::getCredentials('ftp'); + $ret = false; + + // Ensure that the path is valid and clean + $dest = JPath::clean($dest); + + // Create the destination directory if it does not exist + $baseDir = dirname($dest); + if ( ! file_exists($baseDir)) { + jimport('joomla.filesystem.folder'); + JFolder::create($baseDir); + } + + if ($FTPOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp =& JFTP::getInstance($FTPOptions['host'], $FTPOptions['port'], null, $FTPOptions['user'], $FTPOptions['pass']); + + //Translate path for the FTP account + $dest = JPath::clean(str_replace(JPATH_ROOT, $FTPOptions['root'], $dest), '/'); + + // Copy the file to the destination directory + if (is_uploaded_file($src) && $ftp->store($src, $dest)) { + $ret = true; + unlink($src); + } else { + JError::raiseWarning(21, JText::_('WARNFS_ERR02')); + } + } else { + if (is_writeable($baseDir) && move_uploaded_file($src, $dest)) { // Short circuit to prevent file permission errors + if (JPath::setPermissions($dest)) { + $ret = true; + } else { + JError::raiseWarning(21, JText::_('WARNFS_ERR01')); + } + } else { + JError::raiseWarning(21, JText::_('WARNFS_ERR02')); + } + } + return $ret; + } + + /** + * Wrapper for the standard file_exists function + * + * @param string $file File path + * @return boolean True if path is a file + * @since 1.5 + */ + public static function exists($file) + { + return is_file(JPath::clean($file)); + } + + /** + * Returns the name, sans any path + * + * param string $file File path + * @return string filename + * @since 1.5 + */ + public static function getName($file) { + $slash = strrpos($file, DS); + if ($slash !== false) { + return substr($file, $slash + 1); + } else { + return $file; + } + } } diff --git a/vendor/joomla/libraries/joomla/filesystem/folder.php b/vendor/joomla/libraries/joomla/filesystem/folder.php index 9d7ebd39c..6e9d3dde2 100644 --- a/vendor/joomla/libraries/joomla/filesystem/folder.php +++ b/vendor/joomla/libraries/joomla/filesystem/folder.php @@ -1,17 +1,4 @@ store($sfid, $dfid)) { - return JError::raiseError(-1, JText::_('Copy failed')); - } - break; - } - } - } else { - if (!($dh = @opendir($src))) { - return JError::raiseError(-1, JText::_('Unable to open source folder')); - } - // Walk through the directory copying files and recursing into folders. - while (($file = readdir($dh)) !== false) { - $sfid = $src . DS . $file; - $dfid = $dest . DS . $file; - switch (filetype($sfid)) { - case 'dir': - if ($file != '.' && $file != '..') { - $ret = JFolder::copy($sfid, $dfid, null, $force); - if ($ret !== true) { - return $ret; - } - } - break; - - case 'file': - if (!@copy($sfid, $dfid)) { - return JError::raiseError(-1, JText::_('Copy failed')); - } - break; - } - } - } - return true; - } - - /** - * Create a folder -- and all necessary parent folders. - * - * @param string A path to create from the base path. - * @param int Directory permissions to set for folders created. - * @return boolean True if successful. - * @since 1.5 - */ - function create($path = '', $mode = 0755) - { - // Initialize variables - jimport('joomla.client.helper'); - $ftpOptions = JClientHelper::getCredentials('ftp'); - static $nested = 0; - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Check if parent dir exists - $parent = dirname($path); - if (!JFolder::exists($parent)) { - // Prevent infinite loops! - $nested++; - if (($nested > 20) || ($parent == $path)) { - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::create: ' . JText::_('Infinite loop detected') - ); - $nested--; - return false; - } - - // Create the parent directory - if (JFolder::create($parent, $mode) !== true) { - // JFolder::create throws an error - $nested--; - return false; - } - - // OK, parent directory has been created - $nested--; - } - - // Check if dir already exists - if (JFolder::exists($path)) { - return true; - } - - // Check for safe mode - if ($ftpOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = &JFTP::getInstance( - $ftpOptions['host'], $ftpOptions['port'], null, - $ftpOptions['user'], $ftpOptions['pass'] - ); - - // Translate path to FTP path - $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); - $ret = $ftp->mkdir($path); - $ftp->chmod($path, $mode); - } else { - // We need to get and explode the open_basedir paths - $obd = ini_get('open_basedir'); - - // If open_basedir is set we need to get the open_basedir that the path is in - if ($obd != null) - { - if (JPATH_ISWIN) { - $obdSeparator = ";"; - } else { - $obdSeparator = ":"; - } - // Create the array of open_basedir paths - $obdArray = explode($obdSeparator, $obd); - $inBaseDir = false; - // Iterate through open_basedir paths looking for a match - foreach ($obdArray as $test) { - $test = JPath::clean($test); - if (strpos($path, $test) === 0) { - $obdpath = $test; - $inBaseDir = true; - break; - } - } - if ($inBaseDir == false) { - // Return false for JFolder::create because the path to be created is not in open_basedir - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::create: ' . JText::_('Path not in open_basedir paths') - ); - return false; - } - } - - // First set umask - $origmask = @umask(0); - - // Create the path - if (!$ret = @mkdir($path, $mode)) { - @umask($origmask); - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::create: ' . JText::_('Could not create directory'), - 'Path: ' . $path - ); - return false; - } - - // Reset umask - @umask($origmask); - } - return $ret; - } - - /** - * Delete a folder. - * - * @param string The path to the folder to delete. - * @return boolean True on success. - * @since 1.5 - */ - function delete($path) - { - // Sanity check - if (!$path) { - // Bad programmer! Bad Bad programmer! - JError::raiseWarning(500, 'JFolder::delete: ' . JText::_('Attempt to delete base directory') ); - return false; - } - - // Initialize variables - jimport('joomla.client.helper'); - $ftpOptions = JClientHelper::getCredentials('ftp'); - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Is this really a folder? - if (!is_dir($path)) { - JError::raiseWarning(21, 'JFolder::delete: ' . JText::_('Path is not a folder'), 'Path: ' . $path); - return false; - } - - // Remove all the files in folder if they exist - $files = JFolder::files($path, '.', false, true, array()); - if (!empty($files)) { - jimport('joomla.filesystem.file'); - if (JFile::delete($files) !== true) { - // JFile::delete throws an error - return false; - } - } - - // Remove sub-folders of folder - $folders = JFolder::folders($path, '.', false, true, array()); - foreach ($folders as $folder) { - if (is_link($folder)) { - // Don't descend into linked directories, just delete the link. - jimport('joomla.filesystem.file'); - if (JFile::delete($folder) !== true) { - // JFile::delete throws an error - return false; - } - } elseif (JFolder::delete($folder) !== true) { - // JFolder::delete throws an error - return false; - } - } - - if ($ftpOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = &JFTP::getInstance( - $ftpOptions['host'], $ftpOptions['port'], null, - $ftpOptions['user'], $ftpOptions['pass'] - ); - } - - // In case of restricted permissions we zap it one way or the other - // as long as the owner is either the webserver or the ftp - if (@rmdir($path)) { - $ret = true; - } elseif ($ftpOptions['enabled'] == 1) { - // Translate path and delete - $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); - // FTP connector throws an error - $ret = $ftp->delete($path); - } else { - JError::raiseWarning( - 'SOME_ERROR_CODE', - 'JFolder::delete: ' . JText::_('Could not delete folder'), - 'Path: ' . $path - ); - $ret = false; - } - return $ret; - } - - /** - * Moves a folder. - * - * @param string The path to the source folder. - * @param string The path to the destination folder. - * @param string An optional base path to prefix to the file names. - * @return mixed Error message on false or boolean true on success. - * @since 1.5 - */ - function move($src, $dest, $path = '') - { - // Initialize variables - jimport('joomla.client.helper'); - $ftpOptions = JClientHelper::getCredentials('ftp'); - - if ($path) { - $src = JPath::clean($path . DS . $src); - $dest = JPath::clean($path . DS . $dest); - } - - if (!JFolder::exists($src) && !is_writable($src)) { - return JText::_('Cannot find source folder'); - } - if (JFolder::exists($dest)) { - return JText::_('Folder already exists'); - } - - if ($ftpOptions['enabled'] == 1) { - // Connect the FTP client - jimport('joomla.client.ftp'); - $ftp = &JFTP::getInstance( - $ftpOptions['host'], $ftpOptions['port'], null, - $ftpOptions['user'], $ftpOptions['pass'] - ); - - //Translate path for the FTP account - $src = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $src), '/'); - $dest = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dest), '/'); - - // Use FTP rename to simulate move - if (!$ftp->rename($src, $dest)) { - return JText::_('Rename failed'); - } - $ret = true; - } else { - if (!@rename($src, $dest)) { - return JText::_('Rename failed'); - } - $ret = true; - } - return $ret; - } - - /** - * Wrapper for the standard file_exists function - * - * @param string Folder name relative to installation dir - * @return boolean True if path is a folder - * @since 1.5 - */ - function exists($path) - { - return is_dir(JPath::clean($path)); - } - - /** - * Utility function to read the files in a folder. - * - * @param string The path of the folder to read. - * @param string A filter for file names. - * @param mixed True to recursively search into sub-folders, or an - * integer to specify the maximum depth. - * @param boolean True to return the full path to the file. - * @param array Array with names of files which should not be shown in - * the result. - * @return array Files in the given folder. - * @since 1.5 - */ - function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) - { - // Initialize variables - $arr = array(); - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Is the path a folder? - if (!is_dir($path)) { - JError::raiseWarning(21, 'JFolder::files: ' . JText::_('Path is not a folder'), 'Path: ' . $path); - return false; - } - - // read the source directory - $handle = opendir($path); - while (($file = readdir($handle)) !== false) - { - if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) { - $dir = $path . DS . $file; - $isDir = is_dir($dir); - if ($isDir) { - if ($recurse) { - if (is_integer($recurse)) { - $arr2 = JFolder::files($dir, $filter, $recurse - 1, $fullpath); - } else { - $arr2 = JFolder::files($dir, $filter, $recurse, $fullpath); - } - - $arr = array_merge($arr, $arr2); - } - } else { - if (preg_match("/$filter/", $file)) { - if ($fullpath) { - $arr[] = $path . DS . $file; - } else { - $arr[] = $file; - } - } - } - } - } - closedir($handle); - - asort($arr); - return $arr; - } - - /** - * Utility function to read the folders in a folder. - * - * @param string The path of the folder to read. - * @param string A filter for folder names. - * @param mixed True to recursively search into sub-folders, or an - * integer to specify the maximum depth. - * @param boolean True to return the full path to the folders. - * @param array Array with names of folders which should not be shown in - * the result. - * @return array Folders in the given folder. - * @since 1.5 - */ - function folders($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) - { - // Initialize variables - $arr = array(); - - // Check to make sure the path valid and clean - $path = JPath::clean($path); - - // Is the path a folder? - if (!is_dir($path)) { - JError::raiseWarning(21, 'JFolder::folder: ' . JText::_('Path is not a folder'), 'Path: ' . $path); - return false; - } - - // read the source directory - $handle = opendir($path); - while (($file = readdir($handle)) !== false) - { - if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) { - $dir = $path . DS . $file; - $isDir = is_dir($dir); - if ($isDir) { - // Removes filtered directories - if (preg_match("/$filter/", $file)) { - if ($fullpath) { - $arr[] = $dir; - } else { - $arr[] = $file; - } - } - if ($recurse) { - if (is_integer($recurse)) { - $arr2 = JFolder::folders($dir, $filter, $recurse - 1, $fullpath); - } else { - $arr2 = JFolder::folders($dir, $filter, $recurse, $fullpath); - } - - $arr = array_merge($arr, $arr2); - } - } - } - } - closedir($handle); - - asort($arr); - return $arr; - } - - /** - * Lists folder in format suitable for tree display. - * - * @access public - * @param string The path of the folder to read. - * @param string A filter for folder names. - * @param integer The maximum number of levels to recursively read, - * defaults to three. - * @param integer The current level, optional. - * @param integer Unique identifier of the parent folder, if any. - * @return array Folders in the given folder. - * @since 1.5 - */ - function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0) - { - $dirs = array (); - if ($level == 0) { - $GLOBALS['_JFolder_folder_tree_index'] = 0; - } - if ($level < $maxLevel) { - $folders = JFolder::folders($path, $filter); - // first path, index foldernames - foreach ($folders as $name) { - $id = ++$GLOBALS['_JFolder_folder_tree_index']; - $fullName = JPath::clean($path . DS . $name); - $dirs[] = array( - 'id' => $id, - 'parent' => $parent, - 'name' => $name, - 'fullname' => $fullName, - 'relname' => str_replace(JPATH_ROOT, '', $fullName) - ); - $dirs2 = JFolder::listFolderTree($fullName, $filter, $maxLevel, $level + 1, $id); - $dirs = array_merge($dirs, $dirs2); - } - } - return $dirs; - } - - /** - * Makes path name safe to use. - * - * @access public - * @param string The full path to sanitise. - * @return string The sanitised string. - * @since 1.5 - */ - function makeSafe($path) - { - $ds = (DS == '\\') ? '\\' . DS : DS; - $regex = array('#[^A-Za-z0-9:\_\-' . $ds . ' ]#'); - return preg_replace($regex, '', $path); - } - -} \ No newline at end of file + /** + * Copy a folder. + * + * @param string The path to the source folder. + * @param string The path to the destination folder. + * @param string An optional base path to prefix to the file names. + * @param boolean Optionally force folder/file overwrites. + * @return mixed JError object on failure or boolean True on success. + * @since 1.5 + */ + public static function copy($src, $dest, $path = '', $force = false) + { + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + + if ($path) { + $src = JPath::clean($path.DS.$src); + $dest = JPath::clean($path.DS.$dest); + } + + // Eliminate trailing directory separators, if any + $src = rtrim($src, DS); + $dest = rtrim($dest, DS); + + if ( ! JFolder::exists($src)) { + return JError::raiseError(-1, JText::_('Cannot find source folder')); + } + if (JFolder::exists($dest) && !$force) { + return JError::raiseError(-1, JText::_('Folder already exists')); + } + + // Make sure the destination exists + if ( ! JFolder::create($dest)) { + return JError::raiseError(-1, JText::_('Unable to create target folder')); + } + + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + + if ( ! ($dh = @opendir($src))) { + return JError::raiseError(-1, JText::_('Unable to open source folder')); + } + // Walk through the directory copying files and recursing into folders. + while (($file = readdir($dh)) !== false) { + $sfid = $src.DS.$file; + $dfid = $dest.DS.$file; + switch (filetype($sfid)) { + case 'dir': + if ($file != '.' && $file != '..') { + $ret = JFolder::copy($sfid, $dfid, null, $force); + if ($ret !== true) { + return $ret; + } + } + break; + case 'file': + // Translate path for the FTP account + $dfid = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dfid), '/'); + if (! $ftp->store($sfid, $dfid)) { + return JError::raiseError(-1, JText::_('Copy failed')); + } + break; + } + } + } else { + if ( ! ($dh = @opendir($src))) { + return JError::raiseError(-1, JText::_('Unable to open source folder')); + } + // Walk through the directory copying files and recursing into folders. + while (($file = readdir($dh)) !== false) { + $sfid = $src.DS.$file; + $dfid = $dest.DS.$file; + switch (filetype($sfid)) { + case 'dir': + if ($file != '.' && $file != '..') { + $ret = JFolder::copy($sfid, $dfid, null, $force); + if ($ret !== true) { + return $ret; + } + } + break; + case 'file': + if (!@copy($sfid, $dfid)) { + return JError::raiseError(-1, JText::_('Copy failed')); + } + break; + } + } + } + return true; + } + + /** + * Create a folder -- and all necessary parent folders. + * + * @param string A path to create from the base path. + * @param int Directory permissions to set for folders created. + * @return boolean True if successful. + * @since 1.5 + */ + public static function create($path = '', $mode = 0755) + { + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + static $nested = 0; + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Check if parent dir exists + $parent = dirname($path); + if ( ! JFolder::exists($parent)) { + // Prevent infinite loops! + $nested++; + if ($nested > 20 || $parent == $path) { + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::create: ' . JText::_('Infinite loop detected') + ); + $nested--; + return false; + } + + // Create the parent directory + if (JFolder::create($parent, $mode) !== true) { + // JFolder::create throws an error + $nested--; + return false; + } + + // OK, parent directory has been created + $nested--; + } + + // Check if dir already exists + if (JFolder::exists($path)) { + return true; + } + + // Check for safe mode + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + + // Translate path to FTP path + $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); + $ret = $ftp->mkdir($path); + $ftp->chmod($path, $mode); + } else { + // We need to get and explode the open_basedir paths + $obd = ini_get('open_basedir'); + + // If open_basedir is set we need to get the open_basedir that the path is in + if ($obd != null) { + if (JPATH_ISWIN) { + $obdSeparator = ";"; + } else { + $obdSeparator = ":"; + } + // Create the array of open_basedir paths + $obdArray = explode($obdSeparator, $obd); + $inBaseDir = false; + // Iterate through open_basedir paths looking for a match + foreach ($obdArray as $test) { + $test = JPath::clean($test); + if (strpos($path, $test) === 0) { + $obdpath = $test; + $inBaseDir = true; + break; + } + } + if ($inBaseDir == false) { + // Return false for JFolder::create because the path to be created is not in open_basedir + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::create: ' . JText::_('Path not in open_basedir paths') + ); + return false; + } + } + + // First set umask + $origmask = @umask(0); + + // Create the path + if ( ! ($ret = @mkdir($path, $mode))) { + @umask($origmask); + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::create: ' . JText::_('Could not create directory'), + 'Path: ' . $path + ); + return false; + } + + // Reset umask + @umask($origmask); + } + return $ret; + } + + /** + * Delete a folder. + * + * @param string The path to the folder to delete. + * @return boolean True on success. + * @since 1.5 + */ + public static function delete($path) + { + // Sanity check + if ( ! $path) { + // Bad programmer! Bad Bad programmer! + JError::raiseWarning(500, 'JFolder::delete: ' . JText::_('Attempt to delete base directory') ); + return false; + } + + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Is this really a folder? + if ( ! is_dir($path)) { + JError::raiseWarning(21, 'JFolder::delete: '.JText::_('Path is not a folder'), 'Path: '.$path); + return false; + } + + // Remove all the files in folder if they exist + $files = JFolder::files($path, '.', false, true, array()); + if ( ! empty($files)) { + jimport('joomla.filesystem.file'); + if (JFile::delete($files) !== true) { + // JFile::delete throws an error + return false; + } + } + + // Remove sub-folders of folder + $folders = JFolder::folders($path, '.', false, true, array()); + foreach ($folders as $folder) { + if (is_link($folder)) { + // Don't descend into linked directories, just delete the link. + jimport('joomla.filesystem.file'); + if (JFile::delete($folder) !== true) { + // JFile::delete throws an error + return false; + } + } elseif (JFolder::delete($folder) !== true) { + // JFolder::delete throws an error + return false; + } + } + + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + } + + // In case of restricted permissions we zap it one way or the other + // as long as the owner is either the webserver or the ftp + if (@rmdir($path)) { + $ret = true; + } elseif ($ftpOptions['enabled'] == 1) { + // Translate path and delete + $path = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $path), '/'); + // FTP connector throws an error + $ret = $ftp->delete($path); + } else { + JError::raiseWarning( + 'SOME_ERROR_CODE', + 'JFolder::delete: ' . JText::_('Could not delete folder'), + 'Path: ' . $path + ); + $ret = false; + } + return $ret; + } + + /** + * Moves a folder. + * + * @param string The path to the source folder. + * @param string The path to the destination folder. + * @param string An optional base path to prefix to the file names. + * @return mixed Error message on false or boolean true on success. + * @since 1.5 + */ + public static function move($src, $dest, $path = '') + { + // Initialize variables + jimport('joomla.client.helper'); + $ftpOptions = JClientHelper::getCredentials('ftp'); + + if ($path) { + $src = JPath::clean($path . DS . $src); + $dest = JPath::clean($path . DS . $dest); + } + + if (!JFolder::exists($src) && !is_writable($src)) { + return JText::_('Cannot find source folder'); + } + if (JFolder::exists($dest)) { + return JText::_('Folder already exists'); + } + + if ($ftpOptions['enabled'] == 1) { + // Connect the FTP client + jimport('joomla.client.ftp'); + $ftp = &JFTP::getInstance( + $ftpOptions['host'], $ftpOptions['port'], null, + $ftpOptions['user'], $ftpOptions['pass'] + ); + + //Translate path for the FTP account + $src = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $src), '/'); + $dest = JPath::clean(str_replace(JPATH_ROOT, $ftpOptions['root'], $dest), '/'); + + // Use FTP rename to simulate move + if (!$ftp->rename($src, $dest)) { + return JText::_('Rename failed'); + } + $ret = true; + } else { + if ( ! @rename($src, $dest)) { + return JText::_('Rename failed'); + } + $ret = true; + } + return $ret; + } + + /** + * Wrapper for the standard file_exists function + * + * @param string Folder name relative to installation dir + * @return boolean True if path is a folder + * @since 1.5 + */ + public static function exists($path) + { + return is_dir(JPath::clean($path)); + } + + /** + * Utility function to read the files in a folder. + * + * @param string The path of the folder to read. + * @param string A filter for file names. + * @param mixed True to recursively search into sub-folders, or an + * integer to specify the maximum depth. + * @param boolean True to return the full path to the file. + * @param array Array with names of files which should not be shown in + * the result. + * @return array Files in the given folder. + * @since 1.5 + */ + public static function files($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) + { + // Initialize variables + $arr = array(); + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Is the path a folder? + if ( ! is_dir($path)) { + JError::raiseWarning(21, 'JFolder::files: ' . JText::_('Path is not a folder'), 'Path: ' . $path); + return false; + } + + // read the source directory + $handle = opendir($path); + while (($file = readdir($handle)) !== false) { + if (($file != '.') && ($file != '..') && (!in_array($file, $exclude))) { + $dir = $path . DS . $file; + $isDir = is_dir($dir); + if ($isDir) { + if ($recurse) { + if (is_integer($recurse)) { + $arr2 = JFolder::files($dir, $filter, $recurse - 1, $fullpath); + } else { + $arr2 = JFolder::files($dir, $filter, $recurse, $fullpath); + } + + $arr = array_merge($arr, $arr2); + } + } else { + if (preg_match("/$filter/", $file)) { + if ($fullpath) { + $arr[] = $path . DS . $file; + } else { + $arr[] = $file; + } + } + } + } + } + closedir($handle); + + asort($arr); + return $arr; + } + + /** + * Utility function to read the folders in a folder. + * + * @param string The path of the folder to read. + * @param string A filter for folder names. + * @param mixed True to recursively search into sub-folders, or an + * integer to specify the maximum depth. + * @param boolean True to return the full path to the folders. + * @param array Array with names of folders which should not be shown in + * the result. + * @return array Folders in the given folder. + * @since 1.5 + */ + public static function folders($path, $filter = '.', $recurse = false, $fullpath = false, $exclude = array('.svn', 'CVS')) + { + // Initialize variables + $arr = array(); + + // Check to make sure the path valid and clean + $path = JPath::clean($path); + + // Is the path a folder? + if (!is_dir($path)) { + JError::raiseWarning(21, 'JFolder::folder: '.JText::_('Path is not a folder'), 'Path: '.$path); + return false; + } + + // read the source directory + $handle = opendir($path); + while (($file = readdir($handle)) !== false) { + if ($file != '.' && $file != '..' && ! in_array($file, $exclude)) { + $dir = $path.DS.$file; + $isDir = is_dir($dir); + if ($isDir) { + // Removes filtered directories + if (preg_match("/$filter/", $file)) { + if ($fullpath) { + $arr[] = $dir; + } else { + $arr[] = $file; + } + } + if ($recurse) { + if (is_integer($recurse)) { + $arr2 = JFolder::folders($dir, $filter, $recurse - 1, $fullpath); + } else { + $arr2 = JFolder::folders($dir, $filter, $recurse, $fullpath); + } + + $arr = array_merge($arr, $arr2); + } + } + } + } + closedir($handle); + + asort($arr); + return $arr; + } + + /** + * Lists folder in format suitable for tree display. + * + * @param string The path of the folder to read. + * @param string A filter for folder names. + * @param integer The maximum number of levels to recursively read, + * defaults to three. + * @param integer The current level, optional. + * @param integer Unique identifier of the parent folder, if any. + * @return array Folders in the given folder. + * @since 1.5 + */ + public static function listFolderTree($path, $filter, $maxLevel = 3, $level = 0, $parent = 0) + { + $dirs = array (); + if ($level == 0) { + $GLOBALS['_JFolder_folder_tree_index'] = 0; + } + if ($level < $maxLevel) { + $folders = JFolder::folders($path, $filter); + // first path, index foldernames + foreach ($folders as $name) { + $id = ++$GLOBALS['_JFolder_folder_tree_index']; + $fullName = JPath::clean($path . DS . $name); + $dirs[] = array( + 'id' => $id, + 'parent' => $parent, + 'name' => $name, + 'fullname' => $fullName, + 'relname' => str_replace(JPATH_ROOT, '', $fullName) + ); + $dirs2 = JFolder::listFolderTree($fullName, $filter, $maxLevel, $level + 1, $id); + $dirs = array_merge($dirs, $dirs2); + } + } + return $dirs; + } + + /** + * Makes path name safe to use. + * + * @param string The full path to sanitise. + * @return string The sanitised string. + * @since 1.5 + */ + public static function makeSafe($path) + { + $ds = (DS == '\\') ? '\\' . DS : DS; + $regex = array('#[^A-Za-z0-9:\_\-'.$ds.' ]#'); + return preg_replace($regex, '', $path); + } +} diff --git a/vendor/joomla/libraries/joomla/filesystem/path.php b/vendor/joomla/libraries/joomla/filesystem/path.php index 9dd70d168..839f243ff 100644 --- a/vendor/joomla/libraries/joomla/filesystem/path.php +++ b/vendor/joomla/libraries/joomla/filesystem/path.php @@ -1,16 +1,4 @@ * Original Contributors: Gianpaolo Racca, Ghislain Picard, Marco Wandschneider, Chris Tobin and Andrew Eddie. - * - * @package Joomla.Framework - * @subpackage Filter - * @since 1.5 + * + * @package Joomla.Framework + * @subpackage Filter + * @copyright Copyright (C) 2005 - 2010 Open Source Matters. All rights reserved. + * @license GNU/GPL, see LICENSE.php + * @since 1.5 */ class JFilterInput extends JObject { - var $tagsArray; // default = empty array - var $attrArray; // default = empty array - - var $tagsMethod; // default = 0 - var $attrMethod; // default = 0 - - var $xssAuto; // default = 1 - var $tagBlacklist = array ('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml'); - var $attrBlacklist = array ('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers - - /** - * Constructor for inputFilter class. Only first parameter is required. - * - * @access protected - * @param array $tagsArray list of user-defined tags - * @param array $attrArray list of user-defined attributes - * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 - * @param int $attrMethod WhiteList method = 0, BlackList method = 1 - * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 - * @since 1.5 - */ - function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) - { - // Make sure user defined arrays are in lowercase - $tagsArray = array_map('strtolower', (array) $tagsArray); - $attrArray = array_map('strtolower', (array) $attrArray); - - // Assign member variables - $this->tagsArray = $tagsArray; - $this->attrArray = $attrArray; - $this->tagsMethod = $tagsMethod; - $this->attrMethod = $attrMethod; - $this->xssAuto = $xssAuto; - } - - /** - * Returns a reference to an input filter object, only creating it if it doesn't already exist. - * - * This method must be invoked as: - *
  $filter = & JFilterInput::getInstance();
- * - * @static - * @param array $tagsArray list of user-defined tags - * @param array $attrArray list of user-defined attributes - * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 - * @param int $attrMethod WhiteList method = 0, BlackList method = 1 - * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 - * @return object The JFilterInput object. - * @since 1.5 - */ - static public function & getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) - { - static $instances; - - $sig = md5(serialize(array($tagsArray,$attrArray,$tagsMethod,$attrMethod,$xssAuto))); - - if (!isset ($instances)) { - $instances = array(); - } - - if (empty ($instances[$sig])) { - $instances[$sig] = new JFilterInput($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto); - } - - return $instances[$sig]; - } - - /** - * Method to be called by another php script. Processes for XSS and - * specified bad code. - * - * @access public - * @param mixed $source Input string/array-of-string to be 'cleaned' - * @param string $type Return type for the variable (INT, FLOAT, BOOLEAN, WORD, ALNUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) - * @return mixed 'Cleaned' version of input parameter - * @since 1.5 - * @static - */ - public function clean($source, $type='string') - { - // Handle the type constraint - switch (strtoupper($type)) - { - case 'INT' : - case 'INTEGER' : - // Only use the first integer value - preg_match('/-?[0-9]+/', (string) $source, $matches); - $result = @ (int) $matches[0]; - break; - - case 'FLOAT' : - case 'DOUBLE' : - // Only use the first floating point value - preg_match('/-?[0-9]+(\.[0-9]+)?/', (string) $source, $matches); - $result = @ (float) $matches[0]; - break; - - case 'BOOL' : - case 'BOOLEAN' : - $result = (bool) $source; - break; - - case 'WORD' : - $result = (string) preg_replace( '/[^A-Z_]/i', '', $source ); - break; - - case 'ALNUM' : - $result = (string) preg_replace( '/[^A-Z0-9]/i', '', $source ); - break; - - case 'CMD' : - $result = (string) preg_replace( '/[^A-Z0-9_\.-]/i', '', $source ); - $result = ltrim($result, '.'); - break; - - case 'BASE64' : - $result = (string) preg_replace( '/[^A-Z0-9\/+=]/i', '', $source ); - break; - - case 'STRING' : - // Check for static usage and assign $filter the proper variable - if(isset($this) && is_a( $this, 'JFilterInput' )) { - $filter =& $this; - } else { - $filter =& JFilterInput::getInstance(); - } - $result = (string) $filter->_remove($filter->_decode((string) $source)); - break; - - case 'ARRAY' : - $result = (array) $source; - break; - - case 'PATH' : - $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/'; - preg_match($pattern, (string) $source, $matches); - $result = @ (string) $matches[0]; - break; - - case 'USERNAME' : - $result = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $source ); - break; - - case 'MENUTYPE': - $result = str_replace('-', ' ', $source); - $lang = &JFactory::getLanguage(); - $result = $lang->transliterate($result); - $result = (string) preg_replace( - array('/\s+/','/[^A-Za-z0-9\-\_ ]/'), array('-',''), $result - ); - $result = trim($result); - break; - - - default : - // Check for static usage and assign $filter the proper variable - if(is_object($this) && get_class($this) == 'JFilterInput') { - $filter =& $this; - } else { - $filter =& JFilterInput::getInstance(); - } - // Are we dealing with an array? - if (is_array($source)) { - foreach ($source as $key => $value) - { - // filter element for XSS and other 'bad' code etc. - if (is_string($value)) { - $source[$key] = $filter->_remove($filter->_decode($value)); - } - } - $result = $source; - } else { - // Or a string? - if (is_string($source) && !empty ($source)) { - // filter source for XSS and other 'bad' code etc. - $result = $filter->_remove($filter->_decode($source)); - } else { - // Not an array or string.. return the passed parameter - $result = $source; - } - } - break; - } - return $result; - } - - /** - * Function to determine if contents of an attribute is safe - * - * @static - * @param array $attrSubSet A 2 element array for attributes name,value - * @return boolean True if bad code is detected - * @since 1.5 - */ - function checkAttribute($attrSubSet) - { - $attrSubSet[0] = strtolower($attrSubSet[0]); - $attrSubSet[1] = strtolower($attrSubSet[1]); - return (((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style') || (strpos($attrSubSet[1], 'javascript:') !== false) || (strpos($attrSubSet[1], 'behaviour:') !== false) || (strpos($attrSubSet[1], 'vbscript:') !== false) || (strpos($attrSubSet[1], 'mocha:') !== false) || (strpos($attrSubSet[1], 'livescript:') !== false)); - } - - /** - * Internal method to iteratively remove all unwanted tags and attributes - * - * @access protected - * @param string $source Input string to be 'cleaned' - * @return string 'Cleaned' version of input parameter - * @since 1.5 - */ - function _remove($source) - { - $loopCounter = 0; - - // Iteration provides nested tag protection - while ($source != $this->_cleanTags($source)) - { - $source = $this->_cleanTags($source); - $loopCounter ++; - } - return $source; - } - - /** - * Internal method to strip a string of certain tags - * - * @access protected - * @param string $source Input string to be 'cleaned' - * @return string 'Cleaned' version of input parameter - * @since 1.5 - */ - function _cleanTags($source) - { - /* - * In the beginning we don't really have a tag, so everything is - * postTag - */ - $preTag = null; - $postTag = $source; - $currentSpace = false; - $attr = ''; // moffats: setting to null due to issues in migration system - undefined variable errors - - // Is there a tag? If so it will certainly start with a '<' - $tagOpen_start = strpos($source, '<'); - - while ($tagOpen_start !== false) - { - // Get some information about the tag we are processing - $preTag .= substr($postTag, 0, $tagOpen_start); - $postTag = substr($postTag, $tagOpen_start); - $fromTagOpen = substr($postTag, 1); - $tagOpen_end = strpos($fromTagOpen, '>'); - - // Let's catch any non-terminated tags and skip over them - if ($tagOpen_end === false) { - $postTag = substr($postTag, $tagOpen_start +1); - $tagOpen_start = strpos($postTag, '<'); - continue; - } - - // Do we have a nested tag? - $tagOpen_nested = strpos($fromTagOpen, '<'); - $tagOpen_nested_end = strpos(substr($postTag, $tagOpen_end), '>'); - if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) { - $preTag .= substr($postTag, 0, ($tagOpen_nested +1)); - $postTag = substr($postTag, ($tagOpen_nested +1)); - $tagOpen_start = strpos($postTag, '<'); - continue; - } - - // Lets get some information about our tag and setup attribute pairs - $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start +1); - $currentTag = substr($fromTagOpen, 0, $tagOpen_end); - $tagLength = strlen($currentTag); - $tagLeft = $currentTag; - $attrSet = array (); - $currentSpace = strpos($tagLeft, ' '); - - // Are we an open tag or a close tag? - if (substr($currentTag, 0, 1) == '/') { - // Close Tag - $isCloseTag = true; - list ($tagName) = explode(' ', $currentTag); - $tagName = substr($tagName, 1); - } else { - // Open Tag - $isCloseTag = false; - list ($tagName) = explode(' ', $currentTag); - } - - /* - * Exclude all "non-regular" tagnames - * OR no tagname - * OR remove if xssauto is on and tag is blacklisted - */ - if ((!preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || (!$tagName) || ((in_array(strtolower($tagName), $this->tagBlacklist)) && ($this->xssAuto))) { - $postTag = substr($postTag, ($tagLength +2)); - $tagOpen_start = strpos($postTag, '<'); - // Strip tag - continue; - } - - /* - * Time to grab any attributes from the tag... need this section in - * case attributes have spaces in the values. - */ - while ($currentSpace !== false) - { - $attr = ''; - $fromSpace = substr($tagLeft, ($currentSpace +1)); - $nextSpace = strpos($fromSpace, ' '); - $openQuotes = strpos($fromSpace, '"'); - $closeQuotes = strpos(substr($fromSpace, ($openQuotes +1)), '"') + $openQuotes +1; - - // Do we have an attribute to process? [check for equal sign] - if (strpos($fromSpace, '=') !== false) { - /* - * If the attribute value is wrapped in quotes we need to - * grab the substring from the closing quote, otherwise grab - * till the next space - */ - if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes +1)), '"') !== false)) { - $attr = substr($fromSpace, 0, ($closeQuotes +1)); - } else { - $attr = substr($fromSpace, 0, $nextSpace); - } - } else { - /* - * No more equal signs so add any extra text in the tag into - * the attribute array [eg. checked] - */ - if ($fromSpace != '/') { - $attr = substr($fromSpace, 0, $nextSpace); - } - } - - // Last Attribute Pair - if (!$attr && $fromSpace != '/') { - $attr = $fromSpace; - } - - // Add attribute pair to the attribute array - $attrSet[] = $attr; - - // Move search point and continue iteration - $tagLeft = substr($fromSpace, strlen($attr)); - $currentSpace = strpos($tagLeft, ' '); - } - - // Is our tag in the user input array? - $tagFound = in_array(strtolower($tagName), $this->tagsArray); - - // If the tag is allowed lets append it to the output string - if ((!$tagFound && $this->tagsMethod) || ($tagFound && !$this->tagsMethod)) { - - // Reconstruct tag with allowed attributes - if (!$isCloseTag) { - // Open or Single tag - $attrSet = $this->_cleanAttributes($attrSet); - $preTag .= '<'.$tagName; - for ($i = 0; $i < count($attrSet); $i ++) - { - $preTag .= ' '.$attrSet[$i]; - } - - // Reformat single tags to XHTML - if (strpos($fromTagOpen, ''; - } else { - $preTag .= ' />'; - } - } else { - // Closing Tag - $preTag .= ''; - } - } - - // Find next tag's start and continue iteration - $postTag = substr($postTag, ($tagLength +2)); - $tagOpen_start = strpos($postTag, '<'); - } - - // Append any code after the end of tags and return - if ($postTag != '<') { - $preTag .= $postTag; - } - return $preTag; - } - - /** - * Internal method to strip a tag of certain attributes - * - * @access protected - * @param array $attrSet Array of attribute pairs to filter - * @return array Filtered array of attribute pairs - * @since 1.5 - */ - function _cleanAttributes($attrSet) - { - // Initialize variables - $newSet = array(); - - // Iterate through attribute pairs - for ($i = 0; $i < count($attrSet); $i ++) - { - // Skip blank spaces - if (!$attrSet[$i]) { - continue; - } - - // Split into name/value pairs - $attrSubSet = explode('=', trim($attrSet[$i]), 2); - list ($attrSubSet[0]) = explode(' ', $attrSubSet[0]); - - /* - * Remove all "non-regular" attribute names - * AND blacklisted attributes - */ - if ((!preg_match('/[a-z]*$/i', $attrSubSet[0])) || (($this->xssAuto) && ((in_array(strtolower($attrSubSet[0]), $this->attrBlacklist)) || (substr($attrSubSet[0], 0, 2) == 'on')))) { - continue; - } - - // XSS attribute value filtering - if ($attrSubSet[1]) { - // strips unicode, hex, etc - $attrSubSet[1] = str_replace('&#', '', $attrSubSet[1]); - // strip normal newline within attr value - $attrSubSet[1] = preg_replace('/[\n\r]/', '', $attrSubSet[1]); - // strip double quotes - $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); - // convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value) - if ((substr($attrSubSet[1], 0, 1) == "'") && (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'")) { - $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2)); - } - // strip slashes - $attrSubSet[1] = stripslashes($attrSubSet[1]); - } - - // Autostrip script tags - if (JFilterInput::checkAttribute($attrSubSet)) { - continue; - } - - // Is our attribute in the user input array? - $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray); - - // If the tag is allowed lets keep it - if ((!$attrFound && $this->attrMethod) || ($attrFound && !$this->attrMethod)) { - - // Does the attribute have a value? - if ($attrSubSet[1]) { - $newSet[] = $attrSubSet[0].'="'.$attrSubSet[1].'"'; - } elseif ($attrSubSet[1] == "0") { - /* - * Special Case - * Is the value 0? - */ - $newSet[] = $attrSubSet[0].'="0"'; - } else { - $newSet[] = $attrSubSet[0].'="'.$attrSubSet[0].'"'; - } - } - } - return $newSet; - } - - /** - * Try to convert to plaintext - * - * @access protected - * @param string $source - * @return string Plaintext string - * @since 1.5 - */ - function _decode($source) - { - // entity decode - $trans_tbl = get_html_translation_table(HTML_ENTITIES); - foreach($trans_tbl as $k => $v) { - $ttr[$v] = utf8_encode($k); - } - $source = strtr($source, $ttr); - - // convert decimal - $source = preg_replace_callback('/&#(\d+);/m', function($m){return utf8_encode(chr($m[1]));}, $source); - - // convert hex - $source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source); - - return $source; - } + var $tagsArray; // default = empty array + var $attrArray; // default = empty array + + var $tagsMethod; // default = 0 + var $attrMethod; // default = 0 + + var $xssAuto; // default = 1 + var $tagBlacklist = array ('applet', 'body', 'bgsound', 'base', 'basefont', 'embed', 'frame', 'frameset', 'head', 'html', 'id', 'iframe', 'ilayer', 'layer', 'link', 'meta', 'name', 'object', 'script', 'style', 'title', 'xml'); + var $attrBlacklist = array ('action', 'background', 'codebase', 'dynsrc', 'lowsrc'); // also will strip ALL event handlers + + /** + * Constructor for inputFilter class. Only first parameter is required. + * + * @access protected + * @param array $tagsArray list of user-defined tags + * @param array $attrArray list of user-defined attributes + * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 + * @param int $attrMethod WhiteList method = 0, BlackList method = 1 + * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 + * @since 1.5 + */ + function __construct($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) + { + // Make sure user defined arrays are in lowercase + $tagsArray = array_map('strtolower', (array) $tagsArray); + $attrArray = array_map('strtolower', (array) $attrArray); + + // Assign member variables + $this->tagsArray = $tagsArray; + $this->attrArray = $attrArray; + $this->tagsMethod = $tagsMethod; + $this->attrMethod = $attrMethod; + $this->xssAuto = $xssAuto; + } + + /** + * Returns a reference to an input filter object, only creating it if it doesn't already exist. + * + * This method must be invoked as: + *
  $filter = & JFilterInput::getInstance();
+ * + * @static + * @param array $tagsArray list of user-defined tags + * @param array $attrArray list of user-defined attributes + * @param int $tagsMethod WhiteList method = 0, BlackList method = 1 + * @param int $attrMethod WhiteList method = 0, BlackList method = 1 + * @param int $xssAuto Only auto clean essentials = 0, Allow clean blacklisted tags/attr = 1 + * @return object The JFilterInput object. + * @since 1.5 + */ + public static function &getInstance($tagsArray = array(), $attrArray = array(), $tagsMethod = 0, $attrMethod = 0, $xssAuto = 1) + { + static $instances; + + $sig = md5(serialize(array($tagsArray,$attrArray,$tagsMethod,$attrMethod,$xssAuto))); + + if ( ! isset($instances)) { + $instances = array(); + } + + if (empty($instances[$sig])) { + $instances[$sig] = new JFilterInput($tagsArray, $attrArray, $tagsMethod, $attrMethod, $xssAuto); + } + + return $instances[$sig]; + } + + /** + * Method to be called by another php script. Processes for XSS and + * specified bad code. + * + * @access public + * @param mixed $source Input string/array-of-string to be 'cleaned' + * @param string $type Return type for the variable (INT, FLOAT, BOOLEAN, WORD, ALNUM, CMD, BASE64, STRING, ARRAY, PATH, NONE) + * @return mixed 'Cleaned' version of input parameter + * @since 1.5 + * @static + */ + public function clean($source, $type = 'string') + { + // Handle the type constraint + switch (strtoupper($type)) + { + case 'INT': + case 'INTEGER': + // Only use the first integer value + preg_match('/-?[0-9]+/', (string) $source, $matches); + $result = @ (int)$matches[0]; + break; + case 'FLOAT': + case 'DOUBLE': + // Only use the first floating point value + preg_match('/-?[0-9]+(\.[0-9]+)?/', (string) $source, $matches); + $result = @ (float)$matches[0]; + break; + case 'BOOL': + case 'BOOLEAN': + $result = (bool)$source; + break; + case 'WORD': + $result = (string)preg_replace( '/[^A-Z_]/i', '', $source ); + break; + case 'ALNUM': + $result = (string)preg_replace( '/[^A-Z0-9]/i', '', $source ); + break; + case 'CMD' : + $result = (string)preg_replace( '/[^A-Z0-9_\.-]/i', '', $source ); + $result = ltrim($result, '.'); + break; + case 'BASE64': + $result = (string)preg_replace( '/[^A-Z0-9\/+=]/i', '', $source ); + break; + case 'STRING': + // Check for static usage and assign $filter the proper variable + if(isset($this) && is_a( $this, 'JFilterInput' )) { + $filter =& $this; + } else { + $filter =& JFilterInput::getInstance(); + } + $result = (string)$filter->_remove($filter->_decode((string) $source)); + break; + case 'ARRAY': + $result = (array)$source; + break; + case 'PATH': + $pattern = '/^[A-Za-z0-9_-]+[A-Za-z0-9_\.-]*([\\\\\/][A-Za-z0-9_-]+[A-Za-z0-9_\.-]*)*$/'; + preg_match($pattern, (string) $source, $matches); + $result = @ (string) $matches[0]; + break; + case 'USERNAME': + $result = (string) preg_replace( '/[\x00-\x1F\x7F<>"\'%&]/', '', $source ); + break; + case 'MENUTYPE': + $result = str_replace('-', ' ', $source); + $lang = &JFactory::getLanguage(); + $result = $lang->transliterate($result); + $result = (string) preg_replace( + array('/\s+/','/[^A-Za-z0-9\-\_ ]/'), array('-',''), $result + ); + $result = trim($result); + break; + default: + // Check for static usage and assign $filter the proper variable + if(is_object($this) && get_class($this) == 'JFilterInput') { + $filter =& $this; + } else { + $filter =& JFilterInput::getInstance(); + } + // Are we dealing with an array? + if (is_array($source)) { + foreach ($source as $key => $value) + { + // filter element for XSS and other 'bad' code etc. + if (is_string($value)) { + $source[$key] = $filter->_remove($filter->_decode($value)); + } + } + $result = $source; + } else { + // Or a string? + if (is_string($source) && !empty ($source)) { + // filter source for XSS and other 'bad' code etc. + $result = $filter->_remove($filter->_decode($source)); + } else { + // Not an array or string.. return the passed parameter + $result = $source; + } + } + break; + } + return $result; + } + + /** + * Function to determine if contents of an attribute is safe + * + * @param array $attrSubSet A 2 element array for attributes name,value + * @return boolean True if bad code is detected + * @since 1.5 + */ + public static function checkAttribute($attrSubSet) + { + $attrSubSet[0] = strtolower($attrSubSet[0]); + $attrSubSet[1] = strtolower($attrSubSet[1]); + return (((strpos($attrSubSet[1], 'expression') !== false) && ($attrSubSet[0]) == 'style') || (strpos($attrSubSet[1], 'javascript:') !== false) || (strpos($attrSubSet[1], 'behaviour:') !== false) || (strpos($attrSubSet[1], 'vbscript:') !== false) || (strpos($attrSubSet[1], 'mocha:') !== false) || (strpos($attrSubSet[1], 'livescript:') !== false)); + } + + /** + * Internal method to iteratively remove all unwanted tags and attributes + * + * @param string $source Input string to be 'cleaned' + * @return string 'Cleaned' version of input parameter + * @since 1.5 + */ + protected function _remove($source) + { + $loopCounter = 0; + + // Iteration provides nested tag protection + while ($source != $this->_cleanTags($source)) + { + $source = $this->_cleanTags($source); + $loopCounter ++; + } + return $source; + } + + /** + * Internal method to strip a string of certain tags + * + * @param string $source Input string to be 'cleaned' + * @return string 'Cleaned' version of input parameter + * @since 1.5 + */ + protected function _cleanTags($source) + { + /* + * In the beginning we don't really have a tag, so everything is + * postTag + */ + $preTag = null; + $postTag = $source; + $currentSpace = false; + $attr = ''; // moffats: setting to null due to issues in migration system - undefined variable errors + + // Is there a tag? If so it will certainly start with a '<' + $tagOpen_start = strpos($source, '<'); + + while ($tagOpen_start !== false) { + // Get some information about the tag we are processing + $preTag .= substr($postTag, 0, $tagOpen_start); + $postTag = substr($postTag, $tagOpen_start); + $fromTagOpen = substr($postTag, 1); + $tagOpen_end = strpos($fromTagOpen, '>'); + + // Let's catch any non-terminated tags and skip over them + if ($tagOpen_end === false) { + $postTag = substr($postTag, $tagOpen_start +1); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Do we have a nested tag? + $tagOpen_nested = strpos($fromTagOpen, '<'); + $tagOpen_nested_end = strpos(substr($postTag, $tagOpen_end), '>'); + if (($tagOpen_nested !== false) && ($tagOpen_nested < $tagOpen_end)) { + $preTag .= substr($postTag, 0, ($tagOpen_nested +1)); + $postTag = substr($postTag, ($tagOpen_nested +1)); + $tagOpen_start = strpos($postTag, '<'); + continue; + } + + // Lets get some information about our tag and setup attribute pairs + $tagOpen_nested = (strpos($fromTagOpen, '<') + $tagOpen_start +1); + $currentTag = substr($fromTagOpen, 0, $tagOpen_end); + $tagLength = strlen($currentTag); + $tagLeft = $currentTag; + $attrSet = array (); + $currentSpace = strpos($tagLeft, ' '); + + // Are we an open tag or a close tag? + if (substr($currentTag, 0, 1) == '/') { + // Close Tag + $isCloseTag = true; + list($tagName) = explode(' ', $currentTag); + $tagName = substr($tagName, 1); + } else { + // Open Tag + $isCloseTag = false; + list($tagName) = explode(' ', $currentTag); + } + + /* + * Exclude all "non-regular" tagnames + * OR no tagname + * OR remove if xssauto is on and tag is blacklisted + */ + if (( ! preg_match("/^[a-z][a-z0-9]*$/i", $tagName)) || ! $tagName || (in_array(strtolower($tagName), $this->tagBlacklist) && $this->xssAuto)) { + $postTag = substr($postTag, ($tagLength +2)); + $tagOpen_start = strpos($postTag, '<'); + // Strip tag + continue; + } + + /* + * Time to grab any attributes from the tag... need this section in + * case attributes have spaces in the values. + */ + while ($currentSpace !== false) { + $attr = ''; + $fromSpace = substr($tagLeft, ($currentSpace +1)); + $nextSpace = strpos($fromSpace, ' '); + $openQuotes = strpos($fromSpace, '"'); + $closeQuotes = strpos(substr($fromSpace, ($openQuotes +1)), '"') + $openQuotes +1; + + // Do we have an attribute to process? [check for equal sign] + if (strpos($fromSpace, '=') !== false) { + /* + * If the attribute value is wrapped in quotes we need to + * grab the substring from the closing quote, otherwise grab + * till the next space + */ + if (($openQuotes !== false) && (strpos(substr($fromSpace, ($openQuotes +1)), '"') !== false)) { + $attr = substr($fromSpace, 0, ($closeQuotes +1)); + } else { + $attr = substr($fromSpace, 0, $nextSpace); + } + } else { + /* + * No more equal signs so add any extra text in the tag into + * the attribute array [eg. checked] + */ + if ($fromSpace != '/') { + $attr = substr($fromSpace, 0, $nextSpace); + } + } + + // Last Attribute Pair + if ( ! $attr && $fromSpace != '/') { + $attr = $fromSpace; + } + + // Add attribute pair to the attribute array + $attrSet[] = $attr; + + // Move search point and continue iteration + $tagLeft = substr($fromSpace, strlen($attr)); + $currentSpace = strpos($tagLeft, ' '); + } + + // Is our tag in the user input array? + $tagFound = in_array(strtolower($tagName), $this->tagsArray); + + // If the tag is allowed lets append it to the output string + if (( ! $tagFound && $this->tagsMethod) || ($tagFound && ! $this->tagsMethod)) { + + // Reconstruct tag with allowed attributes + if (!$isCloseTag) { + // Open or Single tag + $attrSet = $this->_cleanAttributes($attrSet); + $preTag .= '<'.$tagName; + for ($i = 0; $i < count($attrSet); $i ++) { + $preTag .= ' '.$attrSet[$i]; + } + + // Reformat single tags to XHTML + if (strpos($fromTagOpen, ''; + } else { + $preTag .= ' />'; + } + } else { + // Closing Tag + $preTag .= ''; + } + } + + // Find next tag's start and continue iteration + $postTag = substr($postTag, ($tagLength +2)); + $tagOpen_start = strpos($postTag, '<'); + } + + // Append any code after the end of tags and return + if ($postTag != '<') { + $preTag .= $postTag; + } + return $preTag; + } + + /** + * Internal method to strip a tag of certain attributes + * + * @param array $attrSet Array of attribute pairs to filter + * @return array Filtered array of attribute pairs + * @since 1.5 + */ + protected function _cleanAttributes($attrSet) + { + // Initialize variables + $newSet = array(); + + // Iterate through attribute pairs + for ($i = 0; $i < count($attrSet); $i ++) { + // Skip blank spaces + if (!$attrSet[$i]) { + continue; + } + + // Split into name/value pairs + $attrSubSet = explode('=', trim($attrSet[$i]), 2); + list ($attrSubSet[0]) = explode(' ', $attrSubSet[0]); + + /* + * Remove all "non-regular" attribute names + * AND blacklisted attributes + */ + if ( ! preg_match('/[a-z]*$/i', $attrSubSet[0]) || ($this->xssAuto && (in_array(strtolower($attrSubSet[0]), $this->attrBlacklist) || substr($attrSubSet[0], 0, 2) == 'on'))) { + continue; + } + + // XSS attribute value filtering + if ($attrSubSet[1]) { + // strips unicode, hex, etc + $attrSubSet[1] = str_replace('&#', '', $attrSubSet[1]); + // strip normal newline within attr value + $attrSubSet[1] = preg_replace('/[\n\r]/', '', $attrSubSet[1]); + // strip double quotes + $attrSubSet[1] = str_replace('"', '', $attrSubSet[1]); + // convert single quotes from either side to doubles (Single quotes shouldn't be used to pad attr value) + if ((substr($attrSubSet[1], 0, 1) == "'") && (substr($attrSubSet[1], (strlen($attrSubSet[1]) - 1), 1) == "'")) { + $attrSubSet[1] = substr($attrSubSet[1], 1, (strlen($attrSubSet[1]) - 2)); + } + // strip slashes + $attrSubSet[1] = stripslashes($attrSubSet[1]); + } + + // Autostrip script tags + if (JFilterInput::checkAttribute($attrSubSet)) { + continue; + } + + // Is our attribute in the user input array? + $attrFound = in_array(strtolower($attrSubSet[0]), $this->attrArray); + + // If the tag is allowed lets keep it + if (( ! $attrFound && $this->attrMethod) || ($attrFound && ! $this->attrMethod)) { + + // Does the attribute have a value? + if ($attrSubSet[1]) { + $newSet[] = $attrSubSet[0].'="'.$attrSubSet[1].'"'; + } elseif ($attrSubSet[1] == "0") { + /* + * Special Case + * Is the value 0? + */ + $newSet[] = $attrSubSet[0].'="0"'; + } else { + $newSet[] = $attrSubSet[0].'="'.$attrSubSet[0].'"'; + } + } + } + return $newSet; + } + + /** + * Try to convert to plaintext + * + * @param string $source + * @return string Plaintext string + * @since 1.5 + */ + protected function _decode($source) + { + // entity decode + $trans_tbl = get_html_translation_table(HTML_ENTITIES); + foreach($trans_tbl as $k => $v) { + $ttr[$v] = utf8_encode($k); + } + $source = strtr($source, $ttr); + + // convert decimal + $source = preg_replace_callback('/&#(\d+);/m', function($m){return utf8_encode(chr($m[1]));}, $source); + + // convert hex + $source = preg_replace_callback('/&#x([a-f0-9]+);/mi', function($m){return utf8_encode(chr('0x'.$m[1]));}, $source); + + return $source; + } } - diff --git a/vendor/joomla/libraries/joomla/filter/filteroutput.php b/vendor/joomla/libraries/joomla/filter/filteroutput.php index c43684e68..b6d7fd17f 100644 --- a/vendor/joomla/libraries/joomla/filter/filteroutput.php +++ b/vendor/joomla/libraries/joomla/filter/filteroutput.php @@ -1,148 +1,131 @@ $v) - { - if (is_array( $v ) || is_object( $v ) || $v == NULL || substr( $k, 1, 1 ) == '_' ) { - continue; - } - - if (is_string( $exclude_keys ) && $k == $exclude_keys) { - continue; - } else if (is_array( $exclude_keys ) && in_array( $k, $exclude_keys )) { - continue; - } - - $mixed->$k = htmlspecialchars( $v, $quote_style, 'UTF-8' ); - } - } - } - - /** - * This method processes a string and replaces all instances of & with & in links only - * - * @static - * @param string $input String to process - * @return string Processed string - * @since 1.5 - */ - function linkXHTMLSafe($input) - { - $regex = 'href="([^"]*(&(amp;){0})[^"]*)*?"'; - return preg_replace_callback( "#$regex#i", array('JFilterOutput', '_ampReplaceCallback'), $input ); - } - - /** - * This method processes a string and replaces all accented UTF-8 characters by unaccented - * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased. - * - * @static - * @param string $input String to process - * @return string Processed string - * @since 1.5 - */ - function stringURLSafe($string) - { - //remove any '-' from the string they will be used as concatonater - $str = str_replace('-', ' ', $string); - - $lang =& JFactory::getLanguage(); - $str = $lang->transliterate($str); - - // remove any duplicate whitespace, and ensure all characters are alphanumeric - $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); - - // lowercase and trim - $str = trim(strtolower($str)); - return $str; - } - - /** - * Replaces & with & for xhtml compliance - * - * @todo There must be a better way??? - * - * @static - * @since 1.5 - */ - function ampReplace( $text ) - { - $text = str_replace( '&&', '*--*', $text ); - $text = str_replace( '&#', '*-*', $text ); - $text = str_replace( '&', '&', $text ); - $text = preg_replace( '|&(?![\w]+;)|', '&', $text ); - $text = str_replace( '*-*', '&#', $text ); - $text = str_replace( '*--*', '&&', $text ); - - return $text; - } - - /** - * Callback method for replacing & with & in a string - * - * @static - * @param string $m String to process - * @return string Replaced string - * @since 1.5 - */ - function _ampReplaceCallback( $m ) - { - $rx = '&(?!amp;)'; - return preg_replace( '#'.$rx.'#', '&', $m[0] ); - } - - /** - * Cleans text of all formating and scripting code - */ - function cleanText ( &$text ) - { - $text = preg_replace( "']*>.*?'si", '', $text ); - $text = preg_replace( '/]*>([^<]+)<\/a>/is', '\2 (\1)', $text ); - $text = preg_replace( '//', '', $text ); - $text = preg_replace( '/{.+?}/', '', $text ); - $text = preg_replace( '/ /', ' ', $text ); - $text = preg_replace( '/&/', ' ', $text ); - $text = preg_replace( '/"/', ' ', $text ); - $text = strip_tags( $text ); - $text = htmlspecialchars( $text ); - return $text; - } + /** + * Makes an object safe to display in forms + * + * Object parameters that are non-string, array, object or start with underscore + * will be converted + * + * @param object An object to be parsed + * @param int The optional quote style for the htmlspecialchars function + * @param string|array An optional single field name or array of field names not + * to be parsed (eg, for a textarea) + * @since 1.5 + */ + public static function objectHTMLSafe(&$mixed, $quote_style=ENT_QUOTES, $exclude_keys = '') + { + if (is_object($mixed)) { + foreach (get_object_vars($mixed) as $k => $v) { + if (is_array($v) || is_object($v) || $v == NULL || substr($k, 1, 1) == '_' ) { + continue; + } + + if (is_string($exclude_keys) && $k == $exclude_keys) { + continue; + } else if (is_array($exclude_keys) && in_array($k, $exclude_keys)) { + continue; + } + + $mixed->$k = htmlspecialchars($v, $quote_style, 'UTF-8'); + } + } + } + + /** + * This method processes a string and replaces all instances of & with & in links only + * + * @param string $input String to process + * @return string Processed string + * @since 1.5 + */ + public static function linkXHTMLSafe($input) + { + $regex = 'href="([^"]*(&(amp;){0})[^"]*)*?"'; + return preg_replace_callback( "#$regex#i", array('JFilterOutput', '_ampReplaceCallback'), $input ); + } + + /** + * This method processes a string and replaces all accented UTF-8 characters by unaccented + * ASCII-7 "equivalents", whitespaces are replaced by hyphens and the string is lowercased. + * + * @param string $input String to process + * @return string Processed string + * @since 1.5 + */ + public static function stringURLSafe($string) + { + //remove any '-' from the string they will be used as concatonater + $str = str_replace('-', ' ', $string); + + $lang =& JFactory::getLanguage(); + $str = $lang->transliterate($str); + + // remove any duplicate whitespace, and ensure all characters are alphanumeric + $str = preg_replace(array('/\s+/','/[^A-Za-z0-9\-]/'), array('-',''), $str); + + // lowercase and trim + $str = trim(strtolower($str)); + return $str; + } + + /** + * Replaces & with & for xhtml compliance + * + * @todo There must be a better way??? + * + * @since 1.5 + */ + public static function ampReplace($text) + { + $text = str_replace('&&', '*--*', $text); + $text = str_replace('&#', '*-*', $text); + $text = str_replace('&', '&', $text); + $text = preg_replace('|&(?![\w]+;)|', '&', $text); + $text = str_replace('*-*', '&#', $text); + $text = str_replace('*--*', '&&', $text); + + return $text; + } + + /** + * Callback method for replacing & with & in a string + * + * @param string $m String to process + * @return string Replaced string + * @since 1.5 + */ + public static function _ampReplaceCallback($m) + { + $rx = '&(?!amp;)'; + return preg_replace( '#'.$rx.'#', '&', $m[0] ); + } + + /** + * Cleans text of all formating and scripting code + */ + public static function cleanText(&$text) + { + $text = preg_replace("']*>.*?'si", '', $text); + $text = preg_replace('/]*>([^<]+)<\/a>/is', '\2 (\1)', $text); + $text = preg_replace('//', '', $text); + $text = preg_replace('/{.+?}/', '', $text); + $text = preg_replace('/ /', ' ', $text); + $text = preg_replace('/&/', ' ', $text); + $text = preg_replace('/"/', ' ', $text); + $text = strip_tags($text); + $text = htmlspecialchars($text); + return $text; + } } diff --git a/vendor/joomla/libraries/joomla/html/editor.php b/vendor/joomla/libraries/joomla/html/editor.php index 9495eef35..5a42b08c7 100644 --- a/vendor/joomla/libraries/joomla/html/editor.php +++ b/vendor/joomla/libraries/joomla/html/editor.php @@ -1,17 +1,4 @@ '', 'end' => ''); - - /** - * constructor - * - * @access protected - * @param string The editor name - */ - function __construct($editor = 'none') - { - $this->_name = $editor; - } - - /** - * Returns a reference to a global Editor object, only creating it - * if it doesn't already exist. - * - * This method must be invoked as: - *
  $editor = &JEditor::getInstance([$editor);
- * - * @access public - * @param string $editor The editor to use. - * @return JEditor The Editor object. - */ - function &getInstance($editor = 'none') - { - static $instances; - $editor = 'none'; - if (!isset ($instances)) { - $instances = array (); - } - - $signature = serialize($editor); - - if (empty ($instances[$signature])) { - $instances[$signature] = new JEditor($editor); - } - - return $instances[$signature]; - } - - /** - * Initialize the editor - */ - function initialise() - { - //check if editor is already loaded - if(is_null(($this->_editor))) { - return; - } - - $args['event'] = 'onInit'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - //$return .= $result; - $return = $result; - } - } - - $document =& JFactory::getDocument(); - $document->addCustomTag($return); - } - - /** - * Present a text area - * - * @param string The control name - * @param string The contents of the text area - * @param string The width of the text area (px or %) - * @param string The height of the text area (px or %) - * @param int The number of columns for the textarea - * @param int The number of rows for the textarea - * @param boolean True and the editor buttons will be displayed - * @param array Associative array of editor parameters - */ - function display($name, $html, $width, $height, $col, $row, $buttons = true, $params = array()) - { - $this->_loadEditor($params); - - //check if editor is already loaded - if(is_null(($this->_editor))) { - return; - } - - // Backwards compatibility. Width and height should be passed without a semicolon from now on. - // If editor plugins need a unit like "px" for CSS styling, they need to take care of that - $width = str_replace( ';', '', $width ); - $height = str_replace( ';', '', $height ); - - // Initialize variables - $return = null; - - $args['name'] = $name; - $args['content'] = $html; - $args['width'] = $width; - $args['height'] = $height; - $args['col'] = $col; - $args['row'] = $row; - $args['buttons'] = $buttons; - $args['event'] = 'onDisplay'; - - $results[] = $this->_editor->update($args); - - foreach ($results as $result) - { - if (trim($result)) { - $return .= $result; - } - } - return $this->_tagForSEF['start'] . $return . $this->_tagForSEF['end']; - } - - /** - * Save the editor content - * - * @param string The name of the editor control - */ - function save( $editor ) - { - $this->_loadEditor(); - - //check if editor is already loaded - if(is_null(($this->_editor))) { - return; - } - - $args[] = $editor; - $args['event'] = 'onSave'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - $return .= $result; - } - } - return $return; - } - - /** - * Get the editor contents - * - * @param string The name of the editor control - */ - function getContent( $editor ) - { - $this->_loadEditor(); - - $args['name'] = $editor; - $args['event'] = 'onGetContent'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - $return .= $result; - } - } - return $return; - } - - /** - * Set the editor contents - * - * @param string The name of the editor control - * @param string The contents of the text area - */ - function setContent( $editor, $html ) - { - $this->_loadEditor(); - - $args['name'] = $editor; - $args['html'] = $html; - $args['event'] = 'onSetContent'; - - $return = ''; - $results[] = $this->_editor->update($args); - foreach ($results as $result) { - if (trim($result)) { - $return .= $result; - } - } - return $return; - } - - /** - * Get the editor buttons - * - * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are displayed, if array defines a list of buttons not to show. - * @access public - * @since 1.5 - */ - function getButtons($editor, $buttons = true) - { - $result = array(); - - if(is_bool($buttons) && !$buttons) { - return $result; - } - - // Get plugins - $plugins = JPluginHelper::getPlugin('editors-xtd'); - - foreach($plugins as $plugin) - { - if(is_array($buttons) && in_array($plugin->name, $buttons)) { - continue; - } - - $isLoaded = JPluginHelper::importPlugin('editors-xtd', $plugin->name, false); - - $className = 'plgButton'.$plugin->name; - if(class_exists($className)) { - $plugin = new $className($this, (array)$plugin); - } - - // Try to authenticate -- only add to array if authentication is successful - $resultTest = $plugin->onDisplay($editor); - if ($resultTest) $result[] = $resultTest; - } - - return $result; - } - - /** - * Load the editor - * - * @access private - * @param array Associative array of editor config paramaters - * @since 1.5 - */ - function _loadEditor($config = array()) - { - //check if editor is already loaded - if(!is_null(($this->_editor))) { - return; - } - - jimport('joomla.filesystem.file'); - - // Build the path to the needed editor plugin - $name = JFilterInput::clean($this->_name, 'cmd'); - $path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php'; - - if ( ! JFile::exists($path) ) - { - $message = JText::_('Cannot load the editor'); - JError::raiseWarning( 500, $message ); - return false; - } - - // Require plugin file - require_once $path; - - // Get the plugin - $plugin =& JPluginHelper::getPlugin('editors', $this->_name); - if ( $plugin ) { - $params = new JParameter($plugin->params); - $params->loadArray($config); - $plugin->params = $params; - } - // Build editor plugin classname - $name = 'plgEditor'.$this->_name; - if($this->_editor = new $name ($this, (array)$plugin)) - { - // load plugin parameters - $this->initialise(); - JPluginHelper::importPlugin('editors-xtd'); - } - } -} \ No newline at end of file + /** + * Editor Plugin object + * + * @var object + */ + var $_editor = null; + + /** + * Editor Plugin name + * + * @var string + */ + var $_name = null; + + /** + * Editor start and end tag + * Used to tell SEF plugin not to process editor contents + * + * @var array + */ + var $_tagForSEF = array('start' => '', 'end' => ''); + + /** + * constructor + * + * @access protected + * @param string The editor name + */ + function __construct($editor = 'none') + { + $this->_name = $editor; + } + + /** + * Returns a reference to a global Editor object, only creating it + * if it doesn't already exist. + * + * This method must be invoked as: + *
  $editor = &JEditor::getInstance([$editor);
+ * + * @param string $editor The editor to use. + * @return JEditor The Editor object. + */ + public static function &getInstance($editor = 'none') + { + static $instances; + + $editor = 'none'; + if ( ! isset($instances)) { + $instances = array (); + } + + $signature = serialize($editor); + if (empty ($instances[$signature])) { + $instances[$signature] = new JEditor($editor); + } + + return $instances[$signature]; + } + + /** + * Initialize the editor + */ + function initialise() + { + //check if editor is already loaded + if(is_null(($this->_editor))) { + return; + } + + $args['event'] = 'onInit'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + //$return .= $result; + $return = $result; + } + } + + $document =& JFactory::getDocument(); + $document->addCustomTag($return); + } + + /** + * Present a text area + * + * @param string The control name + * @param string The contents of the text area + * @param string The width of the text area (px or %) + * @param string The height of the text area (px or %) + * @param int The number of columns for the textarea + * @param int The number of rows for the textarea + * @param boolean True and the editor buttons will be displayed + * @param array Associative array of editor parameters + */ + function display($name, $html, $width, $height, $col, $row, $buttons = true, $params = array()) + { + $this->_loadEditor($params); + + //check if editor is already loaded + if (is_null(($this->_editor))) { + return; + } + + // Backwards compatibility. Width and height should be passed without a semicolon from now on. + // If editor plugins need a unit like "px" for CSS styling, they need to take care of that + $width = str_replace( ';', '', $width ); + $height = str_replace( ';', '', $height ); + + // Initialize variables + $return = null; + + $args['name'] = $name; + $args['content'] = $html; + $args['width'] = $width; + $args['height'] = $height; + $args['col'] = $col; + $args['row'] = $row; + $args['buttons'] = $buttons; + $args['event'] = 'onDisplay'; + + $results[] = $this->_editor->update($args); + + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $this->_tagForSEF['start'] . $return . $this->_tagForSEF['end']; + } + + /** + * Save the editor content + * + * @param string The name of the editor control + */ + function save( $editor ) + { + $this->_loadEditor(); + + //check if editor is already loaded + if (is_null(($this->_editor))) { + return; + } + + $args[] = $editor; + $args['event'] = 'onSave'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $return; + } + + /** + * Get the editor contents + * + * @param string The name of the editor control + */ + function getContent( $editor ) + { + $this->_loadEditor(); + + $args['name'] = $editor; + $args['event'] = 'onGetContent'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $return; + } + + /** + * Set the editor contents + * + * @param string The name of the editor control + * @param string The contents of the text area + */ + function setContent( $editor, $html ) + { + $this->_loadEditor(); + + $args['name'] = $editor; + $args['html'] = $html; + $args['event'] = 'onSetContent'; + + $return = ''; + $results[] = $this->_editor->update($args); + foreach ($results as $result) { + if (trim($result)) { + $return .= $result; + } + } + return $return; + } + + /** + * Get the editor buttons + * + * @param mixed $buttons Can be boolean or array, if boolean defines if the buttons are displayed, if array defines a list of buttons not to show. + * @access public + * @since 1.5 + */ + function getButtons($editor, $buttons = true) + { + $result = array(); + + if (is_bool($buttons) && !$buttons) { + return $result; + } + + // Get plugins + $plugins = JPluginHelper::getPlugin('editors-xtd'); + + foreach($plugins as $plugin) { + if (is_array($buttons) && in_array($plugin->name, $buttons)) { + continue; + } + + $isLoaded = JPluginHelper::importPlugin('editors-xtd', $plugin->name, false); + $className = 'plgButton'.$plugin->name; + if (class_exists($className)) { + $plugin = new $className($this, (array)$plugin); + } + + // Try to authenticate -- only add to array if authentication is successful + $resultTest = $plugin->onDisplay($editor); + if ($resultTest) $result[] = $resultTest; + } + + return $result; + } + + /** + * Load the editor + * + * @param array Associative array of editor config paramaters + * @since 1.5 + */ + protected function _loadEditor($config = array()) + { + //check if editor is already loaded + if(!is_null(($this->_editor))) { + return; + } + + jimport('joomla.filesystem.file'); + + // Build the path to the needed editor plugin + $name = JFilterInput::getInstance()->clean($this->_name, 'cmd'); + $path = JPATH_SITE.DS.'plugins'.DS.'editors'.DS.$name.'.php'; + + if ( ! JFile::exists($path)) { + $message = JText::_('Cannot load the editor'); + JError::raiseWarning( 500, $message ); + return false; + } + + // Require plugin file + require_once $path; + + // Get the plugin + $plugin =& JPluginHelper::getPlugin('editors', $this->_name); + if ($plugin) { + $params = new JParameter($plugin->params); + $params->loadArray($config); + $plugin->params = $params; + } + // Build editor plugin classname + $name = 'plgEditor'.$this->_name; + if ($this->_editor = new $name ($this, (array)$plugin)) { + // load plugin parameters + $this->initialise(); + JPluginHelper::importPlugin('editors-xtd'); + } + } +} diff --git a/vendor/joomla/libraries/joomla/html/html.php b/vendor/joomla/libraries/joomla/html/html.php index 82f8f7cf8..8fc037917 100644 --- a/vendor/joomla/libraries/joomla/html/html.php +++ b/vendor/joomla/libraries/joomla/html/html.php @@ -1,332 +1,304 @@ $v) { - $args[] = &$temp[$k]; - } - return call_user_func_array( array( $className, $func ), $args ); - } - else - { - JError::raiseWarning( 0, $className.'::'.$func.' not supported.' ); - return false; - } - } - - /** - * Write a element - * - * @access public - * @param string The relative URL to use for the href attribute - * @param string The target attribute to use - * @param array An associative array of attributes to add - * @since 1.5 - */ - function link($url, $text, $attribs = null) - { - if (is_array( $attribs )) { - $attribs = JArrayHelper::toString( $attribs ); - } - - return ''.$text.''; - } - - /** - * Write a element - * - * @access public - * @param string The relative or absoluete URL to use for the src attribute - * @param string The target attribute to use - * @param array An associative array of attributes to add - * @since 1.5 - */ - function image($url, $alt, $attribs = null) - { - if (is_array($attribs)) { - $attribs = JArrayHelper::toString( $attribs ); - } - - if(strpos($url, 'http') !== 0) { - $url = JURI::root(true).'/'.$url; - }; - - return ''.$alt.''; - } - - /** - * Write a element - * - * @access public - * @param string The relative URL to use for the src attribute - * @param string The target attribute to use - * @param array An associative array of attributes to add - * @param string The message to display if the iframe tag is not supported - * @since 1.5 - */ - function iframe( $url, $name, $attribs = null, $noFrames = '' ) - { - if (is_array( $attribs )) { - $attribs = JArrayHelper::toString( $attribs ); - } - - return ''; - } - - /** - * Write a element - * - * @access public - * @param string The name of the script file - * * @param string The relative or absolute path of the script file - * @param boolean If true, the mootools library will be loaded - * @since 1.5 - */ - function script($filename, $path = 'media/system/js/', $mootools = true) - { - // Include mootools framework - if($mootools) { - JHTML::_('behavior.mootools'); - } - - if(strpos($path, 'http') !== 0) { - $path = JURI::root(true).'/'.$path; - }; - - $document = &JFactory::getDocument(); - $document->addScript( $path.$filename ); - return; - } - - /** - * Write a element - * - * @access public - * @param string The relative URL to use for the href attribute - * @since 1.5 - */ - function stylesheet($filename, $path = 'media/system/css/', $attribs = array()) - { - if(strpos($path, 'http') !== 0) { - $path = JURI::root(true).'/'.$path; - }; - - $document = &JFactory::getDocument(); - $document->addStylesheet( $path.$filename, 'text/css', null, $attribs ); - return; - } - - /** - * Returns formated date according to current local and adds time offset - * - * @access public - * @param string date in an US English date format - * @param string format optional format for strftime - * @returns string formated date - * @see strftime - * @since 1.5 - */ - function date($date, $format = null, $offset = NULL) - { - if ( ! $format ) { - $format = JText::_('DATE_FORMAT_LC1'); - } - - - - if(is_null($offset)) - { - $config =& JFactory::getConfig(); - $offset = $config->getValue('config.offset'); - } - $instance =& JFactory::getDate($date); - $instance->setOffset($offset); - - return $instance->toFormat($format); - } - - /** - * Creates a tooltip with an image as button - * - * @access public - * @param string $tooltip The tip string - * @param string $title The title of the tooltip - * @param string $image The image for the tip, if no text is provided - * @param string $text The text for the tip - * @param string $href An URL that will be used to create the link - * @param boolean depreciated - * @return string - * @since 1.5 - */ - function tooltip($tooltip, $title='', $image='tooltip.png', $text='', $href='', $link=1) - { - $tooltip = addslashes(htmlspecialchars($tooltip, ENT_QUOTES, 'UTF-8')); - $title = addslashes(htmlspecialchars($title, ENT_QUOTES, 'UTF-8')); - - if ( !$text ) { - $image = JURI::root(true).'/includes/js/ThemeOffice/'. $image; - $text = ''. JText::_( 'Tooltip' ) .''; - } else { - $text = JText::_( $text, true ); - } - - if($title) { - $title = $title.'::'; - } - - $style = 'style="text-decoration: none; color: #333;"'; - - if ( $href ) { - $href = JRoute::_( $href ); - $style = ''; - $tip = ''. $text .''; - } else { - $tip = ''. $text .''; - } - - return $tip; - } - - /** - * Displays a calendar control field - * - * @param string The date value - * @param string The name of the text field - * @param string The id of the text field - * @param string The date format - * @param array Additional html attributes - */ - function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null) - { - JHTML::_('behavior.calendar'); //load the calendar behavior - - if (is_array($attribs)) { - $attribs = JArrayHelper::toString( $attribs ); - } - $document =& JFactory::getDocument(); - $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({ - inputField : "'.$id.'", // id of the input field - ifFormat : "'.$format.'", // format of the input field - button : "'.$id.'_img", // trigger for the calendar (button ID) - align : "Tl", // alignment (defaults to "Bl") - singleClick : true - });});'); - - return ''. - 'calendar'; - } - - /** - * Add a directory where JHTML should search for helpers. You may - * either pass a string or an array of directories. - * - * @access public - * @param string A path to search. - * @return array An array with directory elements - * @since 1.5 - */ - function addIncludePath( $path='' ) - { - static $paths; - - if (!isset($paths)) { - $paths = array( JPATH_LIBRARIES.DS.'joomla'.DS.'html'.DS.'html' ); - } - - // force path to array - settype($path, 'array'); - - // loop through the path directories - foreach ($path as $dir) - { - if (!empty($dir) && !in_array($dir, $paths)) { - array_unshift($paths, JPath::clean( $dir )); - } - } - - return $paths; - } + /** + * Class loader method + * + * Additional arguments may be supplied and are passed to the sub-class. + * Additional include paths are also able to be specified for third-party use + * + * @param string The name of helper method to load, (prefix).(class).function + * prefix and class are optional and can be used to load custom + * html helpers. + */ + public static function _($type) { + //Initialise variables + $prefix = 'JHTML'; + $file = ''; + $func = $type; + + // Check to see if we need to load a helper file + $parts = explode('.', $type); + + switch (count($parts)) { + case 3: + $prefix = preg_replace( '#[^A-Z0-9_]#i', '', $parts[0] ); + $file = preg_replace( '#[^A-Z0-9_]#i', '', $parts[1] ); + $func = preg_replace( '#[^A-Z0-9_]#i', '', $parts[2] ); + break; + case 2: + $file = preg_replace( '#[^A-Z0-9_]#i', '', $parts[0] ); + $func = preg_replace( '#[^A-Z0-9_]#i', '', $parts[1] ); + break; + } + + $className = $prefix.ucfirst($file); + + if ( ! class_exists($className)) { + jimport('joomla.filesystem.path'); + if (($path = JPath::find(JHTML::addIncludePath(), strtolower($file).'.php'))) { + require_once $path; + + if ( ! class_exists($className)) { + JError::raiseWarning(0, $className.'::' .$func. ' not found in file.'); + return false; + } + } else { + JError::raiseWarning(0, $prefix.$file.' not supported. File not found.'); + return false; + } + } + + if (is_callable(array($className, $func))) { + $temp = func_get_args(); + array_shift( $temp ); + $args = array(); + foreach ($temp as $k => $v) { + $args[] = &$temp[$k]; + } + return call_user_func_array( array( $className, $func ), $args ); + } else { + JError::raiseWarning(0, $className.'::'.$func.' not supported.'); + return false; + } + } + + /** + * Write a element + * + * @access public + * @param string The relative URL to use for the href attribute + * @param string The target attribute to use + * @param array An associative array of attributes to add + * @since 1.5 + */ + public static function link($url, $text, $attribs = null) + { + if (is_array( $attribs )) { + $attribs = JArrayHelper::toString( $attribs ); + } + + return ''.$text.''; + } + + /** + * Write a element + * + * @access public + * @param string The relative or absoluete URL to use for the src attribute + * @param string The target attribute to use + * @param array An associative array of attributes to add + * @since 1.5 + */ + public static function image($url, $alt, $attribs = null) + { + if (is_array($attribs)) { + $attribs = JArrayHelper::toString( $attribs ); + } + + if (strpos($url, 'http') !== 0) { + $url = JURI::root(true).'/'.$url; + }; + + return ''.$alt.''; + } + + /** + * Write a element + * + * @access public + * @param string The relative URL to use for the src attribute + * @param string The target attribute to use + * @param array An associative array of attributes to add + * @param string The message to display if the iframe tag is not supported + * @since 1.5 + */ + public static function iframe( $url, $name, $attribs = null, $noFrames = '' ) + { + if (is_array( $attribs )) { + $attribs = JArrayHelper::toString( $attribs ); + } + + return ''; + } + + /** + * Write a element + * + * @access public + * @param string The name of the script file + * @param string The relative or absolute path of the script file + * @param boolean If true, the mootools library will be loaded + * @since 1.5 + */ + public static function script($filename, $path = 'media/system/js/', $mootools = true) + { + // Include mootools framework + if ($mootools) { + JHTML::_('behavior.mootools'); + } + + if (strpos($path, 'http') !== 0) { + $path = JURI::root(true).'/'.$path; + } + + $document = &JFactory::getDocument(); + $document->addScript( $path.$filename ); + return; + } + + /** + * Write a element + * + * @access public + * @param string The relative URL to use for the href attribute + * @since 1.5 + */ + public static function stylesheet($filename, $path = 'media/system/css/', $attribs = array()) + { + if (strpos($path, 'http') !== 0) { + $path = JURI::root(true).'/'.$path; + } + + $document = &JFactory::getDocument(); + $document->addStylesheet( $path.$filename, 'text/css', null, $attribs ); + return; + } + + /** + * Returns formated date according to current local and adds time offset + * + * @access public + * @param string date in an US English date format + * @param string format optional format for strftime + * @returns string formated date + * @see strftime + * @since 1.5 + */ + public static function date($date, $format = null, $offset = NULL) + { + if ( ! $format ) { + $format = JText::_('DATE_FORMAT_LC1'); + } + + if (is_null($offset)) { + $config =& JFactory::getConfig(); + $offset = $config->getValue('config.offset'); + } + $instance =& JFactory::getDate($date); + $instance->setOffset($offset); + + return $instance->toFormat($format); + } + + /** + * Creates a tooltip with an image as button + * + * @access public + * @param string $tooltip The tip string + * @param string $title The title of the tooltip + * @param string $image The image for the tip, if no text is provided + * @param string $text The text for the tip + * @param string $href An URL that will be used to create the link + * @param boolean depreciated + * @return string + * @since 1.5 + */ + public static function tooltip($tooltip, $title = '', $image = 'tooltip.png', $text = '', $href = '', $link = 1) + { + $tooltip = addslashes(htmlspecialchars($tooltip, ENT_QUOTES, 'UTF-8')); + $title = addslashes(htmlspecialchars($title, ENT_QUOTES, 'UTF-8')); + + if ( ! $text) { + $image = JURI::root(true).'/includes/js/ThemeOffice/'. $image; + $text = ''. JText::_('Tooltip') .''; + } else { + $text = JText::_( $text, true ); + } + + if ($title) { + $title = $title.'::'; + } + + $style = 'style="text-decoration: none; color: #333;"'; + + if ($href) { + $href = JRoute::_( $href ); + $style = ''; + $tip = ''. $text .''; + } else { + $tip = ''. $text .''; + } + + return $tip; + } + + /** + * Displays a calendar control field + * + * @param string The date value + * @param string The name of the text field + * @param string The id of the text field + * @param string The date format + * @param array Additional html attributes + */ + public static function calendar($value, $name, $id, $format = '%Y-%m-%d', $attribs = null) + { + JHTML::_('behavior.calendar'); //load the calendar behavior + + if (is_array($attribs)) { + $attribs = JArrayHelper::toString( $attribs ); + } + $document =& JFactory::getDocument(); + $document->addScriptDeclaration('window.addEvent(\'domready\', function() {Calendar.setup({ + inputField: "'.$id.'", // id of the input field + ifFormat: "'.$format.'", // format of the input field + button: "'.$id.'_img", // trigger for the calendar (button ID) + align: "Tl", // alignment (defaults to "Bl") + singleClick: true + });});'); + + return ''. + 'calendar'; + } + + /** + * Add a directory where JHTML should search for helpers. You may + * either pass a string or an array of directories. + * + * @access public + * @param string A path to search. + * @return array An array with directory elements + * @since 1.5 + */ + public static function addIncludePath($path = '') + { + static $paths; + + if ( ! isset($paths)) { + $paths = array(JPATH_LIBRARIES.DS.'joomla'.DS.'html'.DS.'html'); + } + + // force path to array + settype($path, 'array'); + + // loop through the path directories + foreach ($path as $dir) { + if ( ! empty($dir) && ! in_array($dir, $paths)) { + array_unshift($paths, JPath::clean($dir)); + } + } + + return $paths; + } } diff --git a/vendor/joomla/libraries/joomla/html/html/behavior.php b/vendor/joomla/libraries/joomla/html/html/behavior.php index 637cf3e1d..1b2a9d79f 100644 --- a/vendor/joomla/libraries/joomla/html/html/behavior.php +++ b/vendor/joomla/libraries/joomla/html/html/behavior.php @@ -1,383 +1,368 @@ getValue('config.debug'); - } - - // TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this - $konkcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror") : null; - + /** + * Method to load the mootools framework into the document head + * + * - If debugging mode is on an uncompressed version of mootools is included for easier debugging. + * + * @param boolean $debug Is debugging mode on? [optional] + * @return void + * @since 1.5 + */ + public static function mootools($debug = null) + { + static $loaded; + + // Only load once + if ($loaded) { + return; + } + + // If no debugging value is set, use the configuration setting + if ($debug === null) { + $config = &JFactory::getConfig(); + $debug = $config->getValue('config.debug'); + } + + // TODO NOTE: Here we are checking for Konqueror - If they fix thier issue with compressed, we will need to update this + $konkcheck = isset($_SERVER['HTTP_USER_AGENT']) ? strpos(strtolower($_SERVER['HTTP_USER_AGENT']), "konqueror") : null; + if ( JFactory::getApplication()->isAdmin() ) { JHTML::script('lib_anahita/js/production/mootools.js', 'media/', false); } - if ($debug || $konkcheck) { + if ($debug || $konkcheck) { //JHTML::script('lib_anahita/js/vendors/mootools-core.js', 'media/', false); //JHTML::script('lib_anahita/js/vendors/mootools-more.js', 'media/', false); //JHTML::script('lib_anahita/js/vendors/clientcide.js', 'media/', false); //JHTML::script('lib_anahita/js/min/mootools.js', 'media/', false); - } else { - //JHTML::script('lib_anahita/js/min/mootools.js', 'media/', false); - } - - $loaded = true; - return; - } - - function caption() { - JHTML::script('caption.js'); - } - - function formvalidation() { - JHTML::script('validate.js' ); - } - - function switcher() { - JHTML::script('switcher.js' ); - } - - function combobox() { - JHTML::script('combobox.js' ); - } - - function tooltip($selector='.hasTip', $params = array()) - { - static $tips; - - if (!isset($tips)) { - $tips = array(); - } - - // Include mootools framework - JHTMLBehavior::mootools(); - - $sig = md5(serialize(array($selector,$params))); - if (isset($tips[$sig]) && ($tips[$sig])) { - return; - } - - // Setup options object - $opt['maxTitleChars'] = (isset($params['maxTitleChars']) && ($params['maxTitleChars'])) ? (int)$params['maxTitleChars'] : 50 ; - // offsets needs an array in the format: array('x'=>20, 'y'=>30) - $opt['offsets'] = (isset($params['offsets']) && (is_array($params['offsets']))) ? $params['offsets'] : null; - $opt['showDelay'] = (isset($params['showDelay'])) ? (int)$params['showDelay'] : null; - $opt['hideDelay'] = (isset($params['hideDelay'])) ? (int)$params['hideDelay'] : null; - $opt['className'] = (isset($params['className'])) ? $params['className'] : null; - $opt['fixed'] = (isset($params['fixed']) && ($params['fixed'])) ? '\\true' : '\\false'; - $opt['onShow'] = (isset($params['onShow'])) ? '\\'.$params['onShow'] : null; - $opt['onHide'] = (isset($params['onHide'])) ? '\\'.$params['onHide'] : null; - - $options = JHTMLBehavior::_getJSObject($opt); - - // Attach tooltips to document - $document =& JFactory::getDocument(); - $tooltipInit = ' window.addEvent(\'domready\', function(){ var JTooltips = new Tips($$(\''.$selector.'\'), '.$options.'); });'; - $document->addScriptDeclaration($tooltipInit); - - // Set static array - $tips[$sig] = true; - return; - } - - function modal($selector='a.modal', $params = array()) - { - static $modals; - static $included; - - $document =& JFactory::getDocument(); - - // Load the necessary files if they haven't yet been loaded - if (!isset($included)) { - - // Load the javascript and css - JHTML::script('modal.js'); - JHTML::stylesheet('modal.css'); - - $included = true; - } - - if (!isset($modals)) { - $modals = array(); - } - - $sig = md5(serialize(array($selector,$params))); - if (isset($modals[$sig]) && ($modals[$sig])) { - return; - } - - // Setup options object - $opt['ajaxOptions'] = (isset($params['ajaxOptions']) && (is_array($params['ajaxOptions']))) ? $params['ajaxOptions'] : null; - $opt['size'] = (isset($params['size']) && (is_array($params['size']))) ? $params['size'] : null; - $opt['onOpen'] = (isset($params['onOpen'])) ? $params['onOpen'] : null; - $opt['onClose'] = (isset($params['onClose'])) ? $params['onClose'] : null; - $opt['onUpdate'] = (isset($params['onUpdate'])) ? $params['onUpdate'] : null; - $opt['onResize'] = (isset($params['onResize'])) ? $params['onResize'] : null; - $opt['onMove'] = (isset($params['onMove'])) ? $params['onMove'] : null; - $opt['onShow'] = (isset($params['onShow'])) ? $params['onShow'] : null; - $opt['onHide'] = (isset($params['onHide'])) ? $params['onHide'] : null; - - $options = JHTMLBehavior::_getJSObject($opt); - - // Attach modal behavior to document - $document->addScriptDeclaration(" - window.addEvent('domready', function() { - - SqueezeBox.initialize(".$options."); - - $$('".$selector."').each(function(el) { - el.addEvent('click', function(e) { - new Event(e).stop(); - SqueezeBox.fromElement(el); - }); - }); - });"); - - // Set static array - $modals[$sig] = true; - return; - } - - function uploader($id='file-upload', $params = array()) - { - JHTML::script('swf.js' ); - JHTML::script('uploader.js' ); - - static $uploaders; - - if (!isset($uploaders)) { - $uploaders = array(); - } - - if (isset($uploaders[$id]) && ($uploaders[$id])) { - return; - } - - // Setup options object - $opt['url'] = (isset($params['targetURL'])) ? $params['targetURL'] : null ; - $opt['swf'] = (isset($params['swf'])) ? $params['swf'] : JURI::root(true).'/media/system/swf/uploader.swf'; - $opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true'; - $opt['queued'] = (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true'; - $opt['queueList'] = (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue'; - $opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false'; - $opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true'; - $opt['limitSize'] = (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null; - $opt['limitFiles'] = (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null; - $opt['optionFxDuration'] = (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null; - $opt['container'] = (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()'; - $opt['types'] = (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}'; - - - // Optional functions - $opt['createReplacement'] = (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null; - $opt['onComplete'] = (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null; - $opt['onAllComplete'] = (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null; - -/* types: Object with (description: extension) pairs, default: Images (*.jpg; *.jpeg; *.gif; *.png) - */ - - $options = JHTMLBehavior::_getJSObject($opt); - - // Attach tooltips to document - $document =& JFactory::getDocument(); - $uploaderInit = 'sBrowseCaption=\''.JText::_('Browse Files', true).'\'; - sRemoveToolTip=\''.JText::_('Remove from queue', true).'\'; - window.addEvent(\'load\', function(){ - var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.'); - $(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.JText::_('Clear Completed').'\' })); });'; - $document->addScriptDeclaration($uploaderInit); - - // Set static array - $uploaders[$id] = true; - return; - } - - function tree($id, $params = array(), $root = array()) - { - static $trees; - - if (!isset($trees)) { - $trees = array(); - } - - // Include mootools framework - JHTMLBehavior::mootools(); - JHTML::script('mootree.js'); - JHTML::stylesheet('mootree.css'); - - if (isset($trees[$id]) && ($trees[$id])) { - return; - } - - // Setup options object - $opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id.'_tree'; - $opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders'; - $opt['grid'] = (array_key_exists('grid', $params)) ? '\\'.$params['grid'] : '\\true'; - $opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JURI::root(true).'/media/system/images/mootree.gif'; - - // Event handlers - $opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\'.$params['onExpand'] : null; - $opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\'.$params['onSelect'] : null; - $opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\'.$params['onClick'] : '\\function(node){ window.open(node.data.url, $chk(node.data.target) ? node.data.target : \'_self\'); }'; - $options = JHTMLBehavior::_getJSObject($opt); - - // Setup root node - $rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root'; - $rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null; - $rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null; - $rt['open'] = (array_key_exists('open', $root)) ? '\\'.$root['open'] : '\\true'; - $rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null; - $rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null; - $rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null; - $rootNode = JHTMLBehavior::_getJSObject($rt); - - $treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : ''; - - $js = ' window.addEvent(\'domready\', function(){ - tree'.$treeName.' = new MooTreeControl('.$options.','.$rootNode.'); - tree'.$treeName.'.adopt(\''.$id.'\');})'; - - // Attach tooltips to document - $document =& JFactory::getDocument(); - $document->addScriptDeclaration($js); - - // Set static array - $trees[$id] = true; - return; - } - - function calendar() - { - $document =& JFactory::getDocument(); - JHTML::stylesheet('calendar-jos.css', 'media/system/css/', array(' title' => JText::_( 'green' ) ,' media' => 'all' )); - JHTML::script( 'calendar.js', 'media/system/js/' ); - JHTML::script( 'calendar-setup.js', 'media/system/js/' ); - - $translation = JHTMLBehavior::_calendartranslation(); - if($translation) { - $document->addScriptDeclaration($translation); - } - } - - /** - * Keep session alive, for example, while editing or creating an article. - */ - function keepalive() - { - // Include mootools framework - JHTMLBehavior::mootools(); - - $config =& JFactory::getConfig(); - $lifetime = ( $config->getValue('lifetime') * 60000 ); - $refreshTime = ( $lifetime <= 60000 ) ? 30000 : $lifetime - 60000; - //refresh time is 1 minute less than the liftime assined in the configuration.php file - - $document =& JFactory::getDocument(); - $script = ''; - $script .= 'function keepAlive( ) {'; - $script .= ' var myAjax = new Request.HTML( "index.php", { method: "get" } ).send();'; - $script .= '}'; - $script .= ' window.addEvent("domready", function()'; - $script .= '{ keepAlive.periodical('.$refreshTime.' ); }'; - $script .= ');'; - - $document->addScriptDeclaration($script); - - return; - } - - /** - * Internal method to get a JavaScript object notation string from an array - * - * @param array $array The array to convert to JavaScript object notation - * @return string JavaScript object notation representation of the array - * @since 1.5 - */ - function _getJSObject($array=array()) - { - // Initialize variables - $object = '{'; - - // Iterate over array to build objects - foreach ((array)$array as $k => $v) - { - if (is_null($v)) { - continue; - } - if (!is_array($v) && !is_object($v)) { - $object .= ' '.$k.': '; - $object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'"; - $object .= ','; - } else { - $object .= ' '.$k.': '.JHTMLBehavior::_getJSObject($v).','; - } - } - if (substr($object, -1) == ',') { - $object = substr($object, 0, -1); - } - $object .= '}'; - - return $object; - } - - /** - * Internal method to translate the JavaScript Calendar - * - * @return string JavaScript that translates the object - * @since 1.5 - */ - function _calendartranslation() - { - static $jsscript = 0; - - if($jsscript == 0) - { - $return = 'Calendar._DN = new Array ("'.JText::_('Sunday').'", "'.JText::_('Monday').'", "'.JText::_('Tuesday').'", "'.JText::_('Wednesday').'", "'.JText::_('Thursday').'", "'.JText::_('Friday').'", "'.JText::_('Saturday').'", "'.JText::_('Sunday').'");Calendar._SDN = new Array ("'.JText::_('Sun').'", "'.JText::_('Mon').'", "'.JText::_('Tue').'", "'.JText::_('Wed').'", "'.JText::_('Thu').'", "'.JText::_('Fri').'", "'.JText::_('Sat').'", "'.JText::_('Sun').'"); Calendar._FD = 0; Calendar._MN = new Array ("'.JText::_('January').'", "'.JText::_('February').'", "'.JText::_('March').'", "'.JText::_('April').'", "'.JText::_('May').'", "'.JText::_('June').'", "'.JText::_('July').'", "'.JText::_('August').'", "'.JText::_('September').'", "'.JText::_('October').'", "'.JText::_('November').'", "'.JText::_('December').'"); Calendar._SMN = new Array ("'.JText::_('January_short').'", "'.JText::_('February_short').'", "'.JText::_('March_short').'", "'.JText::_('April_short').'", "'.JText::_('May_short').'", "'.JText::_('June_short').'", "'.JText::_('July_short').'", "'.JText::_('August_short').'", "'.JText::_('September_short').'", "'.JText::_('October_short').'", "'.JText::_('November_short').'", "'.JText::_('December_short').'");Calendar._TT = {};Calendar._TT["INFO"] = "'.JText::_('About the calendar').'"; - Calendar._TT["ABOUT"] = - "DHTML Date/Time Selector\n" + - "(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + + } else { + //JHTML::script('lib_anahita/js/min/mootools.js', 'media/', false); + } + + $loaded = true; + return; + } + + public static function caption() + { + JHTML::script('caption.js'); + } + + public static function formvalidation() + { + JHTML::script('validate.js'); + } + + public static function switcher() + { + JHTML::script('switcher.js'); + } + + public static function combobox() + { + JHTML::script('combobox.js' ); + } + + public static function tooltip($selector='.hasTip', $params = array()) + { + static $tips; + + if ( ! isset($tips)) { + $tips = array(); + } + + // Include mootools framework + JHTMLBehavior::mootools(); + + $sig = md5(serialize(array($selector,$params))); + if (isset($tips[$sig]) && ($tips[$sig])) { + return; + } + + // Setup options object + $opt['maxTitleChars'] = (isset($params['maxTitleChars']) && ($params['maxTitleChars'])) ? (int)$params['maxTitleChars'] : 50 ; + // offsets needs an array in the format: array('x'=>20, 'y'=>30) + $opt['offsets'] = (isset($params['offsets']) && (is_array($params['offsets']))) ? $params['offsets'] : null; + $opt['showDelay'] = (isset($params['showDelay'])) ? (int)$params['showDelay'] : null; + $opt['hideDelay'] = (isset($params['hideDelay'])) ? (int)$params['hideDelay'] : null; + $opt['className'] = (isset($params['className'])) ? $params['className'] : null; + $opt['fixed'] = (isset($params['fixed']) && ($params['fixed'])) ? '\\true' : '\\false'; + $opt['onShow'] = (isset($params['onShow'])) ? '\\'.$params['onShow'] : null; + $opt['onHide'] = (isset($params['onHide'])) ? '\\'.$params['onHide'] : null; + + $options = JHTMLBehavior::_getJSObject($opt); + + // Attach tooltips to document + $document =& JFactory::getDocument(); + $tooltipInit = ' window.addEvent(\'domready\', function(){ var JTooltips = new Tips($$(\''.$selector.'\'), '.$options.'); });'; + $document->addScriptDeclaration($tooltipInit); + + // Set static array + $tips[$sig] = true; + return; + } + + public static function modal($selector='a.modal', $params = array()) + { + static $modals; + static $included; + + $document =& JFactory::getDocument(); + + // Load the necessary files if they haven't yet been loaded + if ( ! isset($included)) { + // Load the javascript and css + JHTML::script('modal.js'); + JHTML::stylesheet('modal.css'); + + $included = true; + } + + if ( ! isset($modals)) { + $modals = array(); + } + + $sig = md5(serialize(array($selector,$params))); + if (isset($modals[$sig]) && ($modals[$sig])) { + return; + } + + // Setup options object + $opt['ajaxOptions'] = (isset($params['ajaxOptions']) && (is_array($params['ajaxOptions']))) ? $params['ajaxOptions'] : null; + $opt['size'] = (isset($params['size']) && (is_array($params['size']))) ? $params['size'] : null; + $opt['onOpen'] = (isset($params['onOpen'])) ? $params['onOpen'] : null; + $opt['onClose'] = (isset($params['onClose'])) ? $params['onClose'] : null; + $opt['onUpdate'] = (isset($params['onUpdate'])) ? $params['onUpdate'] : null; + $opt['onResize'] = (isset($params['onResize'])) ? $params['onResize'] : null; + $opt['onMove'] = (isset($params['onMove'])) ? $params['onMove'] : null; + $opt['onShow'] = (isset($params['onShow'])) ? $params['onShow'] : null; + $opt['onHide'] = (isset($params['onHide'])) ? $params['onHide'] : null; + + $options = JHTMLBehavior::_getJSObject($opt); + + // Attach modal behavior to document + $document->addScriptDeclaration(" + window.addEvent('domready', function() { + SqueezeBox.initialize(".$options."); + $$('".$selector."').each(function(el) { + el.addEvent('click', function(e) { + new Event(e).stop(); + SqueezeBox.fromElement(el); + }); + }); + });"); + + // Set static array + $modals[$sig] = true; + return; + } + + public static function uploader($id='file-upload', $params = array()) + { + JHTML::script('swf.js' ); + JHTML::script('uploader.js' ); + + static $uploaders; + + if (!isset($uploaders)) { + $uploaders = array(); + } + + if (isset($uploaders[$id]) && ($uploaders[$id])) { + return; + } + + // Setup options object + $opt['url'] = (isset($params['targetURL'])) ? $params['targetURL'] : null ; + $opt['swf'] = (isset($params['swf'])) ? $params['swf'] : JURI::root(true).'/media/system/swf/uploader.swf'; + $opt['multiple'] = (isset($params['multiple']) && !($params['multiple'])) ? '\\false' : '\\true'; + $opt['queued'] = (isset($params['queued']) && !($params['queued'])) ? '\\false' : '\\true'; + $opt['queueList'] = (isset($params['queueList'])) ? $params['queueList'] : 'upload-queue'; + $opt['instantStart'] = (isset($params['instantStart']) && ($params['instantStart'])) ? '\\true' : '\\false'; + $opt['allowDuplicates'] = (isset($params['allowDuplicates']) && !($params['allowDuplicates'])) ? '\\false' : '\\true'; + $opt['limitSize'] = (isset($params['limitSize']) && ($params['limitSize'])) ? (int)$params['limitSize'] : null; + $opt['limitFiles'] = (isset($params['limitFiles']) && ($params['limitFiles'])) ? (int)$params['limitFiles'] : null; + $opt['optionFxDuration'] = (isset($params['optionFxDuration'])) ? (int)$params['optionFxDuration'] : null; + $opt['container'] = (isset($params['container'])) ? '\\$('.$params['container'].')' : '\\$(\''.$id.'\').getParent()'; + $opt['types'] = (isset($params['types'])) ?'\\'.$params['types'] : '\\{\'All Files (*.*)\': \'*.*\'}'; + // Optional functions + $opt['createReplacement'] = (isset($params['createReplacement'])) ? '\\'.$params['createReplacement'] : null; + $opt['onComplete'] = (isset($params['onComplete'])) ? '\\'.$params['onComplete'] : null; + $opt['onAllComplete'] = (isset($params['onAllComplete'])) ? '\\'.$params['onAllComplete'] : null; + + /* + * types: Object with (description: extension) pairs, default: Images (*.jpg; *.jpeg; *.gif; *.png) + */ + $options = JHTMLBehavior::_getJSObject($opt); + + // Attach tooltips to document + $document =& JFactory::getDocument(); + $uploaderInit = 'sBrowseCaption=\''.JText::_('Browse Files', true).'\'; + sRemoveToolTip=\''.JText::_('Remove from queue', true).'\'; + window.addEvent(\'load\', function(){ + var Uploader = new FancyUpload($(\''.$id.'\'), '.$options.'); + $(\'upload-clear\').adopt(new Element(\'input\', { type: \'button\', events: { click: Uploader.clearList.bind(Uploader, [false])}, value: \''.JText::_('Clear Completed').'\' })); });'; + $document->addScriptDeclaration($uploaderInit); + + // Set static array + $uploaders[$id] = true; + return; + } + + public static function tree($id, $params = array(), $root = array()) + { + static $trees; + + if ( ! isset($trees)) { + $trees = array(); + } + + // Include mootools framework + JHTMLBehavior::mootools(); + JHTML::script('mootree.js'); + JHTML::stylesheet('mootree.css'); + + if (isset($trees[$id]) && ($trees[$id])) { + return; + } + + // Setup options object + $opt['div'] = (array_key_exists('div', $params)) ? $params['div'] : $id.'_tree'; + $opt['mode'] = (array_key_exists('mode', $params)) ? $params['mode'] : 'folders'; + $opt['grid'] = (array_key_exists('grid', $params)) ? '\\'.$params['grid'] : '\\true'; + $opt['theme'] = (array_key_exists('theme', $params)) ? $params['theme'] : JURI::root(true).'/media/system/images/mootree.gif'; + // Event handlers + $opt['onExpand'] = (array_key_exists('onExpand', $params)) ? '\\'.$params['onExpand'] : null; + $opt['onSelect'] = (array_key_exists('onSelect', $params)) ? '\\'.$params['onSelect'] : null; + $opt['onClick'] = (array_key_exists('onClick', $params)) ? '\\'.$params['onClick'] : '\\function(node){ window.open(node.data.url, $chk(node.data.target) ? node.data.target : \'_self\'); }'; + + $options = JHTMLBehavior::_getJSObject($opt); + + // Setup root node + $rt['text'] = (array_key_exists('text', $root)) ? $root['text'] : 'Root'; + $rt['id'] = (array_key_exists('id', $root)) ? $root['id'] : null; + $rt['color'] = (array_key_exists('color', $root)) ? $root['color'] : null; + $rt['open'] = (array_key_exists('open', $root)) ? '\\'.$root['open'] : '\\true'; + $rt['icon'] = (array_key_exists('icon', $root)) ? $root['icon'] : null; + $rt['openicon'] = (array_key_exists('openicon', $root)) ? $root['openicon'] : null; + $rt['data'] = (array_key_exists('data', $root)) ? $root['data'] : null; + + $rootNode = JHTMLBehavior::_getJSObject($rt); + $treeName = (array_key_exists('treeName', $params)) ? $params['treeName'] : ''; + + $js = ' window.addEvent(\'domready\', function(){ + tree'.$treeName.' = new MooTreeControl('.$options.','.$rootNode.'); + tree'.$treeName.'.adopt(\''.$id.'\');})'; + + // Attach tooltips to document + $document =& JFactory::getDocument(); + $document->addScriptDeclaration($js); + + // Set static array + $trees[$id] = true; + return; + } + + public static function calendar() + { + $document =& JFactory::getDocument(); + JHTML::stylesheet('calendar-jos.css', 'media/system/css/', array(' title' => JText::_( 'green' ) ,' media' => 'all' )); + JHTML::script( 'calendar.js', 'media/system/js/' ); + JHTML::script( 'calendar-setup.js', 'media/system/js/' ); + + $translation = JHTMLBehavior::_calendartranslation(); + if ($translation) { + $document->addScriptDeclaration($translation); + } + } + + /** + * Keep session alive, for example, while editing or creating an article. + */ + public static function keepalive() + { + // Include mootools framework + JHTMLBehavior::mootools(); + + $config =& JFactory::getConfig(); + $lifetime = ( $config->getValue('lifetime') * 60000 ); + $refreshTime = ( $lifetime <= 60000 ) ? 30000 : $lifetime - 60000; + //refresh time is 1 minute less than the liftime assined in the configuration.php file + + $document =& JFactory::getDocument(); + $script = ''; + $script .= 'function keepAlive( ) {'; + $script .= ' var myAjax = new Request.HTML( "index.php", { method: "get" } ).send();'; + $script .= '}'; + $script .= ' window.addEvent("domready", function()'; + $script .= '{ keepAlive.periodical('.$refreshTime.' ); }'; + $script .= ');'; + + $document->addScriptDeclaration($script); + + return; + } + + /** + * Internal method to get a JavaScript object notation string from an array + * + * @param array $array The array to convert to JavaScript object notation + * @return string JavaScript object notation representation of the array + * @since 1.5 + */ + protected static function _getJSObject($array=array()) + { + // Initialize variables + $object = '{'; + + // Iterate over array to build objects + foreach ((array)$array as $k => $v) { + if (is_null($v)) { + continue; + } + if ( ! is_array($v) && !is_object($v)) { + $object .= ' '.$k.': '; + $object .= (is_numeric($v) || strpos($v, '\\') === 0) ? (is_numeric($v)) ? $v : substr($v, 1) : "'".$v."'"; + $object .= ','; + } else { + $object .= ' '.$k.': '.JHTMLBehavior::_getJSObject($v).','; + } + } + if (substr($object, -1) == ',') { + $object = substr($object, 0, -1); + } + $object .= '}'; + + return $object; + } + + /** + * Internal method to translate the JavaScript Calendar + * + * @return string JavaScript that translates the object + * @since 1.5 + */ + protected static function _calendartranslation() + { + static $jsscript = 0; + + if ($jsscript == 0) { + $return = 'Calendar._DN = new Array ("'.JText::_('Sunday').'", "'.JText::_('Monday').'", "'.JText::_('Tuesday').'", "'.JText::_('Wednesday').'", "'.JText::_('Thursday').'", "'.JText::_('Friday').'", "'.JText::_('Saturday').'", "'.JText::_('Sunday').'");Calendar._SDN = new Array ("'.JText::_('Sun').'", "'.JText::_('Mon').'", "'.JText::_('Tue').'", "'.JText::_('Wed').'", "'.JText::_('Thu').'", "'.JText::_('Fri').'", "'.JText::_('Sat').'", "'.JText::_('Sun').'"); Calendar._FD = 0; Calendar._MN = new Array ("'.JText::_('January').'", "'.JText::_('February').'", "'.JText::_('March').'", "'.JText::_('April').'", "'.JText::_('May').'", "'.JText::_('June').'", "'.JText::_('July').'", "'.JText::_('August').'", "'.JText::_('September').'", "'.JText::_('October').'", "'.JText::_('November').'", "'.JText::_('December').'"); Calendar._SMN = new Array ("'.JText::_('January_short').'", "'.JText::_('February_short').'", "'.JText::_('March_short').'", "'.JText::_('April_short').'", "'.JText::_('May_short').'", "'.JText::_('June_short').'", "'.JText::_('July_short').'", "'.JText::_('August_short').'", "'.JText::_('September_short').'", "'.JText::_('October_short').'", "'.JText::_('November_short').'", "'.JText::_('December_short').'");Calendar._TT = {};Calendar._TT["INFO"] = "'.JText::_('About the calendar').'"; + Calendar._TT["ABOUT"] = +"DHTML Date/Time Selector\n" + +"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + "For latest version visit: http://www.dynarch.com/projects/calendar/\n" + "Distributed under GNU LGPL. See http://gnu.org/licenses/lgpl.html for details." + "\n\n" + @@ -391,12 +376,11 @@ function _calendartranslation() "- or Shift-click to decrease it\n" + "- or click and drag for faster selection."; - Calendar._TT["PREV_YEAR"] = "'.JText::_('Prev. year (hold for menu)').'";Calendar._TT["PREV_MONTH"] = "'.JText::_('Prev. month (hold for menu)').'"; Calendar._TT["GO_TODAY"] = "'.JText::_('Go Today').'";Calendar._TT["NEXT_MONTH"] = "'.JText::_('Next month (hold for menu)').'";Calendar._TT["NEXT_YEAR"] = "'.JText::_('Next year (hold for menu)').'";Calendar._TT["SEL_DATE"] = "'.JText::_('Select date').'";Calendar._TT["DRAG_TO_MOVE"] = "'.JText::_('Drag to move').'";Calendar._TT["PART_TODAY"] = "'.JText::_('(Today)').'";Calendar._TT["DAY_FIRST"] = "'.JText::_('Display %s first').'";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "'.JText::_('Close').'";Calendar._TT["TODAY"] = "'.JText::_('Today').'";Calendar._TT["TIME_PART"] = "'.JText::_('(Shift-)Click or drag to change value').'";Calendar._TT["DEF_DATE_FORMAT"] = "'.JText::_('%Y-%m-%d').'"; Calendar._TT["TT_DATE_FORMAT"] = "'.JText::_('%a, %b %e').'";Calendar._TT["WK"] = "'.JText::_('wk').'";Calendar._TT["TIME"] = "'.JText::_('Time:').'";'; - $jsscript = 1; - return $return; - } else { - return false; - } - } + Calendar._TT["PREV_YEAR"] = "'.JText::_('Prev. year (hold for menu)').'";Calendar._TT["PREV_MONTH"] = "'.JText::_('Prev. month (hold for menu)').'"; Calendar._TT["GO_TODAY"] = "'.JText::_('Go Today').'";Calendar._TT["NEXT_MONTH"] = "'.JText::_('Next month (hold for menu)').'";Calendar._TT["NEXT_YEAR"] = "'.JText::_('Next year (hold for menu)').'";Calendar._TT["SEL_DATE"] = "'.JText::_('Select date').'";Calendar._TT["DRAG_TO_MOVE"] = "'.JText::_('Drag to move').'";Calendar._TT["PART_TODAY"] = "'.JText::_('(Today)').'";Calendar._TT["DAY_FIRST"] = "'.JText::_('Display %s first').'";Calendar._TT["WEEKEND"] = "0,6";Calendar._TT["CLOSE"] = "'.JText::_('Close').'";Calendar._TT["TODAY"] = "'.JText::_('Today').'";Calendar._TT["TIME_PART"] = "'.JText::_('(Shift-)Click or drag to change value').'";Calendar._TT["DEF_DATE_FORMAT"] = "'.JText::_('%Y-%m-%d').'"; Calendar._TT["TT_DATE_FORMAT"] = "'.JText::_('%a, %b %e').'";Calendar._TT["WK"] = "'.JText::_('wk').'";Calendar._TT["TIME"] = "'.JText::_('Time:').'";'; + $jsscript = 1; + return $return; + } else { + return false; + } + } } - diff --git a/vendor/joomla/libraries/joomla/html/html/form.php b/vendor/joomla/libraries/joomla/html/html/form.php index 2e9b8734c..fe9e7d298 100644 --- a/vendor/joomla/libraries/joomla/html/html/form.php +++ b/vendor/joomla/libraries/joomla/html/html/form.php @@ -1,38 +1,26 @@ '; - } -} \ No newline at end of file + /** + * Displays a hidden token field to reduce the risk of CSRF exploits + * + * Use in conjuction with JRequest::checkToken + * + * @return void + * @since 1.5 + */ + public static function token() + { + return ''; + } +} diff --git a/vendor/joomla/libraries/joomla/html/html/grid.php b/vendor/joomla/libraries/joomla/html/html/grid.php index bc51fbd38..a6dd6d178 100644 --- a/vendor/joomla/libraries/joomla/html/html/grid.php +++ b/vendor/joomla/libraries/joomla/html/html/grid.php @@ -1,173 +1,148 @@ '; - $html .= JText::_( $title ); - if ($order == $selected ) { - $html .= JHTML::_('image.administrator', $images[$index], '/images/', NULL, NULL); - } - $html .= ''; - return $html; - } - - /** - * @param int The row index - * @param int The record id - * @param boolean - * @param string The name of the form element - * - * @return string - */ - function id( $rowNum, $recId, $checkedOut=false, $name='cid' ) - { - if ( $checkedOut ) { - return ''; - } else { - return ''; - } - } - - function access( &$row, $i, $archived = NULL ) - { - if ( !$row->access ) { - $color_access = 'style="color: green;"'; - $task_access = 'accessregistered'; - } else if ( $row->access == 1 ) { - $color_access = 'style="color: red;"'; - $task_access = 'accessspecial'; - } else { - $color_access = 'style="color: black;"'; - $task_access = 'accesspublic'; - } - - if ($archived == -1) - { - $href = JText::_( $row->groupname ); - } - else - { - $href = ' - - '. JText::_( $row->groupname ) .'' - ; - } - - return $href; - } - - function checkedOut( &$row, $i, $identifier = 'id' ) - { - $user =& JFactory::getUser(); - $userid = $user->get('id'); - - $result = false; - if(is_a($row, 'JTable')) { - $result = $row->isCheckedOut($userid); - } else { - $result = JTable::isCheckedOut($userid, $row->checked_out); - } - - $checked = ''; - if ( $result ) { - $checked = JHTMLGrid::_checkedOut( $row ); - } else { - $checked = JHTML::_('grid.id', $i, $row->$identifier ); - } - - return $checked; - } - - function published( &$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix='' ) - { - $img = $row->published ? $imgY : $imgX; - $task = $row->published ? 'unpublish' : 'publish'; - $alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' ); - $action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' ); - - $href = ' - - '. $alt .'' - ; - - return $href; - } - - function state( $filter_state='*', $published='Published', $unpublished='Unpublished', $archived=NULL, $trashed=NULL ) - { - $state[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' ); - //Jinx : Why is this used ? - //$state[] = JHTML::_('select.option', '*', JText::_( 'Any' ) ); - $state[] = JHTML::_('select.option', 'P', JText::_( $published ) ); - $state[] = JHTML::_('select.option', 'U', JText::_( $unpublished ) ); - - if ($archived) { - $state[] = JHTML::_('select.option', 'A', JText::_( $archived ) ); - } - - if ($trashed) { - $state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) ); - } - - return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state ); - } - - function order( $rows, $image='filesave.png', $task="saveorder" ) - { - $image = JHTML::_('image.administrator', $image, '/images/', NULL, NULL, JText::_( 'Save Order' ) ); - $href = ''.$image.''; - return $href; - } - - - function _checkedOut( &$row, $overlib = 1 ) - { - $hover = ''; - if ( $overlib ) - { - $text = addslashes(htmlspecialchars($row->editor)); - - $date = JHTML::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1') ); - $time = JHTML::_('date', $row->checked_out_time, '%H:%M' ); - - $hover = ''; - } - $checked = $hover .''; - - return $checked; - } + /** + * @param string The link title + * @param string The order field for the column + * @param string The current direction + * @param string The selected ordering + * @param string An optional task override + */ + public static function sort($title, $order, $direction = 'asc', $selected = 0, $task = NULL) + { + $direction = strtolower( $direction ); + $images = array( 'sort_asc.png', 'sort_desc.png' ); + $index = intval( $direction == 'desc' ); + $direction = ($direction == 'desc') ? 'asc' : 'desc'; + + $html = ''; + $html .= JText::_( $title ); + if ($order == $selected ) { + $html .= JHTML::_('image.administrator', $images[$index], '/images/', NULL, NULL); + } + $html .= ''; + return $html; + } + + /** + * @param int The row index + * @param int The record id + * @param boolean + * @param string The name of the form element + * + * @return string + */ + public static function id($rowNum, $recId, $checkedOut = false, $name = 'cid') + { + if ($checkedOut) { + return ''; + } else { + return ''; + } + } + + public static function access(&$row, $i, $archived = NULL) + { + if ( ! $row->access) { + $color_access = 'style="color: green;"'; + $task_access = 'accessregistered'; + } elseif ($row->access == 1) { + $color_access = 'style="color: red;"'; + $task_access = 'accessspecial'; + } else { + $color_access = 'style="color: black;"'; + $task_access = 'accesspublic'; + } + + if ($archived == -1) { + $href = JText::_( $row->groupname ); + } else { + $href = ' + + '. JText::_( $row->groupname ) .'' + ; + } + + return $href; + } + + public static function checkedOut( &$row, $i, $identifier = 'id' ) + { + $user =& JFactory::getUser(); + $userid = $user->get('id'); + $result = JTable::isCheckedOut($userid, $row->checked_out); + + $checked = ''; + if ($result) { + $checked = JHTMLGrid::_checkedOut( $row ); + } else { + $checked = JHTML::_('grid.id', $i, $row->$identifier ); + } + + return $checked; + } + + public static function published(&$row, $i, $imgY = 'tick.png', $imgX = 'publish_x.png', $prefix = '') { + $img = $row->published ? $imgY : $imgX; + $task = $row->published ? 'unpublish' : 'publish'; + $alt = $row->published ? JText::_( 'Published' ) : JText::_( 'Unpublished' ); + $action = $row->published ? JText::_( 'Unpublish Item' ) : JText::_( 'Publish item' ); + + $href = ' + + '. $alt .'' + ; + + return $href; + } + + public static function state($filter_state = '*', $published = 'Published', $unpublished = 'Unpublished', $archived = NULL, $trashed = NULL) + { + $state[] = JHTML::_('select.option', '', '- '. JText::_( 'Select State' ) .' -' ); + //Jinx : Why is this used ? + //$state[] = JHTML::_('select.option', '*', JText::_( 'Any' ) ); + $state[] = JHTML::_('select.option', 'P', JText::_( $published ) ); + $state[] = JHTML::_('select.option', 'U', JText::_( $unpublished ) ); + + if ($archived) { + $state[] = JHTML::_('select.option', 'A', JText::_( $archived ) ); + } + + if ($trashed) { + $state[] = JHTML::_('select.option', 'T', JText::_( $trashed ) ); + } + + return JHTML::_('select.genericlist', $state, 'filter_state', 'class="inputbox" size="1" onchange="submitform( );"', 'value', 'text', $filter_state ); + } + + public static function order($rows, $image = 'filesave.png', $task = "saveorder") + { + $image = JHTML::_('image.administrator', $image, '/images/', NULL, NULL, JText::_( 'Save Order' ) ); + $href = ''.$image.''; + return $href; + } + + protected static function _checkedOut( &$row, $overlib = 1 ) + { + $hover = ''; + if ($overlib) { + $text = addslashes(htmlspecialchars($row->editor)); + $date = JHTML::_('date', $row->checked_out_time, JText::_('DATE_FORMAT_LC1') ); + $time = JHTML::_('date', $row->checked_out_time, '%H:%M' ); + $hover = ''; + } + $checked = $hover .''; + + return $checked; + } } diff --git a/vendor/joomla/libraries/joomla/html/html/image.php b/vendor/joomla/libraries/joomla/html/html/image.php index 39712d1b3..bdda828e2 100644 --- a/vendor/joomla/libraries/joomla/html/html/image.php +++ b/vendor/joomla/libraries/joomla/html/html/image.php @@ -1,153 +1,137 @@ getTemplate(); - - if ( $altFile ) - { - // $param allows for an alternative file to be used - $src = $altFolder . $altFile; - } - else if ( $altFile == -1 ) - { - // Comes from an image list param field with 'Do not use' selected - return ''; - } else { - $path = JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file; - if (!isset( $paths[$path] )) - { - if ( file_exists( JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file ) ) { - $paths[$path] = 'templates/'. $cur_template .'/images/'. $file; - } else { - // outputs only path to image - $paths[$path] = $folder . $file; - } - } - $src = $paths[$path]; - } - - if (substr($src, 0, 1 ) == "/") { - $src = substr_replace($src, '', 0, 1); - } - - // Prepend the base path - $src = JURI::base(true).'/'.$src; - - // outputs actual html tag - if ($asTag) { - return ''. html_entity_decode( $alt ) .''; - } - - return $src; - } - - /** - * Checks to see if an image exists in the current templates image directory - * if it does it loads this image. Otherwise the default image is loaded. - * Also can be used in conjunction with the menulist param to create the chosen image - * load the default or use no image - * - * @param string The file name, eg foobar.png - * @param string The path to the image - * @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder - * @param string Another path. Only used for the contact us form based on the value of the imagelist parm - * @param string Alt text - * @param array An associative array of attributes to add - * @param boolean True (default) to display full tag, false to return just the path - */ - function administrator( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt = NULL, $attribs = null, $type = 1 ) - { - global $mainframe; - - if (is_array( $attribs )) { - $attribs = JArrayHelper::toString( $attribs ); - } - - $cur_template = $mainframe->getTemplate(); - - // strip html - $alt = html_entity_decode( $alt ); - - if ( $param ) { - $image = $param_directory . $param; - } else if ( $param == -1 ) { - $image = ''; - } else { - if ( file_exists( JPATH_ADMINISTRATOR .'/templates/'. $cur_template .'/images/'. $file ) ) { - $image = 'templates/'. $cur_template .'/images/'. $file; - } else { - // compability with previous versions - if ( substr($directory, 0, 14 )== "/administrator" ) { - $image = substr($directory,15) . $file; - } else { - $image = $directory . $file; - } - } - } - - if (substr($image, 0, 1 ) == "/") { - $image = substr_replace($image, '', 0, 1); - } - - // Prepend the base path - $image = JURI::base(true).'/'.$image; - - // outputs actual html tag - if ( $type ) { - $image = ''. $alt .''; - } - - return $image; - } -} \ No newline at end of file + /** + * Checks to see if an image exists in the current templates image directory + * if it does it loads this image. Otherwise the default image is loaded. + * Also can be used in conjunction with the menulist param to create the chosen image + * load the default or use no image + * + * @param string The file name, eg foobar.png + * @param string The path to the image + * @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder + * @param string Another path. Only used for the contact us form based on the value of the imagelist parm + * @param string Alt text + * @param array An associative array of attributes to add + * @param boolean True (default) to display full tag, false to return just the path + */ + public static function site($file, $folder='/images/M_images/', $altFile=NULL, $altFolder='/images/M_images/', $alt=NULL, $attribs = null, $asTag = 1) + { + static $paths; + global $mainframe; + + if ( ! $paths) { + $paths = array(); + } + + if (is_array( $attribs )) { + $attribs = JArrayHelper::toString( $attribs ); + } + + $cur_template = $mainframe->getTemplate(); + + if ($altFile) { + // $param allows for an alternative file to be used + $src = $altFolder . $altFile; + } elseif ($altFile == -1) { + // Comes from an image list param field with 'Do not use' selected + return ''; + } else { + $path = JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file; + if ( ! isset( $paths[$path])) { + if (file_exists( JPATH_SITE .'/templates/'. $cur_template .'/images/'. $file)) { + $paths[$path] = 'templates/'. $cur_template .'/images/'. $file; + } else { + // outputs only path to image + $paths[$path] = $folder . $file; + } + } + $src = $paths[$path]; + } + + if (substr($src, 0, 1 ) == "/") { + $src = substr_replace($src, '', 0, 1); + } + + // Prepend the base path + $src = JURI::base(true).'/'.$src; + + // outputs actual html tag + if ($asTag) { + return ''. html_entity_decode( $alt ) .''; + } + + return $src; + } + + /** + * Checks to see if an image exists in the current templates image directory + * if it does it loads this image. Otherwise the default image is loaded. + * Also can be used in conjunction with the menulist param to create the chosen image + * load the default or use no image + * + * @param string The file name, eg foobar.png + * @param string The path to the image + * @param int empty: use $file and $folder, -1: show no image, not-empty: use $altFile and $altFolder + * @param string Another path. Only used for the contact us form based on the value of the imagelist parm + * @param string Alt text + * @param array An associative array of attributes to add + * @param boolean True (default) to display full tag, false to return just the path + */ + public static function administrator( $file, $directory='/images/', $param=NULL, $param_directory='/images/', $alt = NULL, $attribs = null, $type = 1 ) + { + global $mainframe; + + if (is_array($attribs)) { + $attribs = JArrayHelper::toString( $attribs ); + } + + $cur_template = $mainframe->getTemplate(); + + // strip html + $alt = html_entity_decode( $alt ); + + if ($param) { + $image = $param_directory . $param; + } elseif ($param == -1) { + $image = ''; + } else { + if (file_exists( JPATH_ADMINISTRATOR.'/templates/'.$cur_template.'/images/'.$file)) { + $image = 'templates/'.$cur_template.'/images/'.$file; + } else { + // compability with previous versions + if (substr($directory, 0, 14) == "/administrator") { + $image = substr($directory,15) . $file; + } else { + $image = $directory . $file; + } + } + } + + if (substr($image, 0, 1 ) == "/") { + $image = substr_replace($image, '', 0, 1); + } + + // Prepend the base path + $image = JURI::base(true).'/'.$image; + + // outputs actual html tag + if ($type) { + $image = ''.$alt.''; + } + + return $image; + } +} diff --git a/vendor/joomla/libraries/joomla/html/html/list.php b/vendor/joomla/libraries/joomla/html/html/list.php index 76954e9dc..9ffc8b5c8 100644 --- a/vendor/joomla/libraries/joomla/html/html/list.php +++ b/vendor/joomla/libraries/joomla/html/html/list.php @@ -1,236 +1,222 @@ setQuery( $query ); - $groups = $db->loadObjectList(); - $access = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), '', 1 ); - - return $access; - } - - /** - * Build the select list to choose an image - */ - function images( $name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png" ) - { - if ( !$directory ) { - $directory = '/images/stories/'; - } - - if ( !$javascript ) { - $javascript = "onchange=\"javascript:if (document.forms.adminForm." . $name . ".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm." . $name . ".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; - } - - jimport( 'joomla.filesystem.folder' ); - $imageFiles = JFolder::files( JPATH_SITE.DS.$directory ); - $images = array( JHTML::_('select.option', '', '- '. JText::_( 'Select Image' ) .' -' ) ); - foreach ( $imageFiles as $file ) { - if ( preg_match( "#$extensions#i", $file ) ) { - $images[] = JHTML::_('select.option', $file ); - } - } - $images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); - - return $images; - } - - /** - * Description - * - * @param string SQL with ordering As value and 'name field' AS text - * @param integer The length of the truncated headline - * @since 1.5 - */ - function genericordering( $sql, $chop = '30' ) - { - $db =& JFactory::getDBO(); - $order = array(); - $db->setQuery( $sql ); - if (!($orders = $db->loadObjectList())) { - if ($db->getErrorNum()) { - echo $db->stderr(); - return false; - } else { - $order[] = JHTML::_('select.option', 1, JText::_( 'first' ) ); - return $order; - } - } - $order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) ); - for ($i=0, $n=count( $orders ); $i < $n; $i++) { - - if (JString::strlen($orders[$i]->text) > $chop) { - $text = JString::substr($orders[$i]->text,0,$chop)."..."; - } else { - $text = $orders[$i]->text; - } - - $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); - } - $order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) ); - - return $order; - } - - /** - * Build the select list for Ordering of a specified Table - */ - function specificordering( &$row, $id, $query, $neworder = 0 ) - { - $db =& JFactory::getDBO(); - - if ( $id ) { - $order = JHTML::_('list.genericordering', $query ); - $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); - } else { - if ( $neworder ) { - $text = JText::_( 'descNewItemsFirst' ); - } else { - $text = JText::_( 'descNewItemsLast' ); - } - $ordering = ''. $text; - } - return $ordering; - } - - /** - * Select list of active users - */ - function users( $name, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1 ) - { - $db =& JFactory::getDBO(); - - $and = ''; - if ( $reg ) { - // does not include registered users in the list - $and = ' AND gid > 18'; - } - - $query = 'SELECT id AS value, name AS text' - . ' FROM #__users' - . ' WHERE block = 0' - . $and - . ' ORDER BY '. $order - ; - $db->setQuery( $query ); - if ( $nouser ) { - $users[] = JHTML::_('select.option', '0', '- '. JText::_( 'No User' ) .' -' ); - $users = array_merge( $users, $db->loadObjectList() ); - } else { - $users = $db->loadObjectList(); - } - - $users = JHTML::_('select.genericlist', $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); - - return $users; - } - - /** - * Select list of positions - generally used for location of images - */ - function positions( $name, $active = NULL, $javascript = NULL, $none = 1, $center = 1, $left = 1, $right = 1, $id = false ) - { - if ( $none ) { - $pos[] = JHTML::_('select.option', '', JText::_( 'None' ) ); - } - if ( $center ) { - $pos[] = JHTML::_('select.option', 'center', JText::_( 'Center' ) ); - } - if ( $left ) { - $pos[] = JHTML::_('select.option', 'left', JText::_( 'Left' ) ); - } - if ( $right ) { - $pos[] = JHTML::_('select.option', 'right', JText::_( 'Right' ) ); - } - - $positions = JHTML::_('select.genericlist', $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active, $id ); - - return $positions; - } - - /** - * Select list of active categories for components - */ - function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 ) - { - $db =& JFactory::getDBO(); - - $query = 'SELECT id AS value, title AS text' - . ' FROM #__categories' - . ' WHERE section = '.$db->Quote($section) - . ' AND published = 1' - . ' ORDER BY '. $order - ; - $db->setQuery( $query ); - if ( $sel_cat ) { - $categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' ); - $categories = array_merge( $categories, $db->loadObjectList() ); - } else { - $categories = $db->loadObjectList(); - } - - $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); - return $category; - } - - /** - * Select list of active sections - */ - function section( $name, $active = NULL, $javascript = NULL, $order = 'ordering', $uncategorized = true, $scope = 'content' ) - { - $db =& JFactory::getDBO(); - - $categories[] = JHTML::_('select.option', '-1', '- '. JText::_( 'Select Section' ) .' -' ); - - if ($uncategorized) { - $categories[] = JHTML::_('select.option', '0', JText::_( 'Uncategorized' ) ); - } - - $query = 'SELECT id AS value, title AS text' - . ' FROM #__sections' - . ' WHERE published = 1' - . ' AND scope = ' . $db->Quote($scope) - . ' ORDER BY ' . $order - ; - $db->setQuery( $query ); - $sections = array_merge( $categories, $db->loadObjectList() ); - - $category = JHTML::_('select.genericlist', $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); - - return $category; - } + /** + * Build the select list for access level + */ + public static function accesslevel( &$row ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT id AS value, name AS text' + . ' FROM #__groups' + . ' ORDER BY id' + ; + $db->setQuery( $query ); + $groups = $db->loadObjectList(); + $access = JHTML::_('select.genericlist', $groups, 'access', 'class="inputbox" size="3"', 'value', 'text', intval( $row->access ), '', 1 ); + + return $access; + } + + /** + * Build the select list to choose an image + */ + public static function images($name, $active = NULL, $javascript = NULL, $directory = NULL, $extensions = "bmp|gif|jpg|png") + { + if ( ! $directory) { + $directory = '/images/stories/'; + } + + if ( ! $javascript) { + $javascript = "onchange=\"javascript:if (document.forms.adminForm.".$name.".options[selectedIndex].value!='') {document.imagelib.src='..$directory' + document.forms.adminForm.".$name.".options[selectedIndex].value} else {document.imagelib.src='../images/blank.png'}\""; + } + + jimport('joomla.filesystem.folder'); + $imageFiles = JFolder::files(JPATH_SITE.DS.$directory); + $images = array(JHTML::_('select.option', '', '- '. JText::_( 'Select Image' ) .' -')); + foreach ($imageFiles as $file) { + if (preg_match("#$extensions#i", $file)) { + $images[] = JHTML::_('select.option', $file ); + } + } + $images = JHTML::_('select.genericlist', $images, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); + + return $images; + } + + /** + * Description + * + * @param string SQL with ordering As value and 'name field' AS text + * @param integer The length of the truncated headline + * @since 1.5 + */ + public static function genericordering( $sql, $chop = '30' ) + { + $db =& JFactory::getDBO(); + $order = array(); + $db->setQuery( $sql ); + if ( ! ($orders = $db->loadObjectList())) { + if ($db->getErrorNum()) { + echo $db->stderr(); + return false; + } else { + $order[] = JHTML::_('select.option', 1, JText::_( 'first' ) ); + return $order; + } + } + $order[] = JHTML::_('select.option', 0, '0 '. JText::_( 'first' ) ); + for ($i = 0, $n = count( $orders ); $i < $n; $i++) { + if (JString::strlen($orders[$i]->text) > $chop) { + $text = JString::substr($orders[$i]->text,0,$chop)."..."; + } else { + $text = $orders[$i]->text; + } + + $order[] = JHTML::_('select.option', $orders[$i]->value, $orders[$i]->value.' ('.$text.')' ); + } + $order[] = JHTML::_('select.option', $orders[$i-1]->value+1, ($orders[$i-1]->value+1).' '. JText::_( 'last' ) ); + + return $order; + } + + /** + * Build the select list for Ordering of a specified Table + */ + public static function specificordering( &$row, $id, $query, $neworder = 0 ) + { + $db =& JFactory::getDBO(); + + if ($id) { + $order = JHTML::_('list.genericordering', $query ); + $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); + } else { + if ($neworder) { + $text = JText::_( 'descNewItemsFirst' ); + } else { + $text = JText::_( 'descNewItemsLast' ); + } + $ordering = ''. $text; + } + return $ordering; + } + + /** + * Select list of active users + */ + public static function users($name, $active, $nouser = 0, $javascript = NULL, $order = 'name', $reg = 1) + { + $db =& JFactory::getDBO(); + + $and = ''; + if ($reg) { + // does not include registered users in the list + $and = ' AND gid > 18'; + } + + $query = 'SELECT id AS value, name AS text' + . ' FROM #__users' + . ' WHERE block = 0' + . $and + . ' ORDER BY '. $order + ; + $db->setQuery( $query ); + if ($nouser) { + $users[] = JHTML::_('select.option', '0', '- '. JText::_( 'No User' ) .' -' ); + $users = array_merge( $users, $db->loadObjectList() ); + } else { + $users = $db->loadObjectList(); + } + + $users = JHTML::_('select.genericlist', $users, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active ); + + return $users; + } + + /** + * Select list of positions - generally used for location of images + */ + public static function positions( $name, $active = NULL, $javascript = NULL, $none = 1, $center = 1, $left = 1, $right = 1, $id = false ) + { + if ( $none ) { + $pos[] = JHTML::_('select.option', '', JText::_( 'None' ) ); + } + if ( $center ) { + $pos[] = JHTML::_('select.option', 'center', JText::_( 'Center' ) ); + } + if ( $left ) { + $pos[] = JHTML::_('select.option', 'left', JText::_( 'Left' ) ); + } + if ( $right ) { + $pos[] = JHTML::_('select.option', 'right', JText::_( 'Right' ) ); + } + + $positions = JHTML::_('select.genericlist', $pos, $name, 'class="inputbox" size="1"'. $javascript, 'value', 'text', $active, $id ); + + return $positions; + } + + /** + * Select list of active categories for components + */ + public static function category( $name, $section, $active = NULL, $javascript = NULL, $order = 'ordering', $size = 1, $sel_cat = 1 ) + { + $db =& JFactory::getDBO(); + + $query = 'SELECT id AS value, title AS text' + . ' FROM #__categories' + . ' WHERE section = '.$db->Quote($section) + . ' AND published = 1' + . ' ORDER BY '. $order + ; + $db->setQuery( $query ); + if ( $sel_cat ) { + $categories[] = JHTML::_('select.option', '0', '- '. JText::_( 'Select a Category' ) .' -' ); + $categories = array_merge( $categories, $db->loadObjectList() ); + } else { + $categories = $db->loadObjectList(); + } + + $category = JHTML::_('select.genericlist', $categories, $name, 'class="inputbox" size="'. $size .'" '. $javascript, 'value', 'text', $active ); + return $category; + } + + /** + * Select list of active sections + */ + public static function section( $name, $active = NULL, $javascript = NULL, $order = 'ordering', $uncategorized = true, $scope = 'content' ) + { + $db =& JFactory::getDBO(); + + $categories[] = JHTML::_('select.option', '-1', '- '. JText::_('Select Section') .' -' ); + + if ($uncategorized) { + $categories[] = JHTML::_('select.option', '0', JText::_('Uncategorized')); + } + + $query = 'SELECT id AS value, title AS text' + . ' FROM #__sections' + . ' WHERE published = 1' + . ' AND scope = ' . $db->Quote($scope) + . ' ORDER BY ' . $order + ; + $db->setQuery( $query ); + $sections = array_merge( $categories, $db->loadObjectList() ); + $category = JHTML::_('select.genericlist', $sections, $name, 'class="inputbox" size="1" '. $javascript, 'value', 'text', $active); + + return $category; + } } diff --git a/vendor/joomla/libraries/joomla/html/html/menu.php b/vendor/joomla/libraries/joomla/html/html/menu.php index bad42e865..20c87755e 100644 --- a/vendor/joomla/libraries/joomla/html/html/menu.php +++ b/vendor/joomla/libraries/joomla/html/html/menu.php @@ -1,17 +1,4 @@ Quote($row->menutype) - . ' AND parent = '.(int) $row->parent - . ' AND published != -2' - . ' ORDER BY ordering'; - $order = JHTML::_('list.genericordering', $query ); - $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); - } - else - { - $ordering = ''. JText::_( 'DESCNEWITEMSLAST' ); - } - return $ordering; - } - - /** - * Build the multiple select list for Menu Links/Pages - */ - function linkoptions( $all=false, $unassigned=false ) - { - $db =& JFactory::getDBO(); - - // get a list of the menu items - $query = 'SELECT m.id, m.parent, m.name, m.menutype' - . ' FROM #__menu AS m' - . ' WHERE m.published = 1' - . ' ORDER BY m.menutype, m.parent, m.ordering' - ; - $db->setQuery( $query ); - $mitems = $db->loadObjectList(); - $mitems_temp = $mitems; - - // establish the hierarchy of the menu - $children = array(); - // first pass - collect children - foreach ( $mitems as $v ) - { - $id = $v->id; - $pt = $v->parent; - $list = @$children[$pt] ? $children[$pt] : array(); - array_push( $list, $v ); - $children[$pt] = $list; - } - // second pass - get an indent list of the items - $list = JHTMLMenu::TreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); - - // Code that adds menu name to Display of Page(s) - $mitems_spacer = $mitems_temp[0]->menutype; - - $mitems = array(); - if ($all | $unassigned) { - $mitems[] = JHTML::_('select.option', '', JText::_( 'Menus' ) ); - - if ( $all ) { - $mitems[] = JHTML::_('select.option', 0, JText::_( 'All' ) ); - } - if ( $unassigned ) { - $mitems[] = JHTML::_('select.option', -1, JText::_( 'Unassigned' ) ); - } - - $mitems[] = JHTML::_('select.option', '' ); - } - - $lastMenuType = null; - $tmpMenuType = null; - foreach ($list as $list_a) - { - if ($list_a->menutype != $lastMenuType) - { - if ($tmpMenuType) { - $mitems[] = JHTML::_('select.option', '' ); - } - $mitems[] = JHTML::_('select.option', '', $list_a->menutype ); - $lastMenuType = $list_a->menutype; - $tmpMenuType = $list_a->menutype; - } - - $mitems[] = JHTML::_('select.option', $list_a->id, $list_a->treename ); - } - if ($lastMenuType !== null) { - $mitems[] = JHTML::_('select.option', '' ); - } - - return $mitems; - } - - function treerecurse( $id, $indent, $list, &$children, $maxlevel=9999, $level=0, $type=1 ) - { - if (@$children[$id] && $level <= $maxlevel) - { - foreach ($children[$id] as $v) - { - $id = $v->id; - - if ( $type ) { - $pre = '|_ '; - $spacer = '.      '; - } else { - $pre = '- '; - $spacer = '  '; - } - - if ( $v->parent == 0 ) { - $txt = $v->name; - } else { - $txt = $pre . $v->name; - } - $pt = $v->parent; - $list[$id] = $v; - $list[$id]->treename = "$indent$txt"; - $list[$id]->children = count( @$children[$id] ); - $list = JHTMLMenu::TreeRecurse( $id, $indent . $spacer, $list, $children, $maxlevel, $level+1, $type ); - } - } - return $list; - } -} \ No newline at end of file + /** + * Build the select list for Menu Ordering + */ + public static function ordering( &$row, $id ) + { + $db =& JFactory::getDBO(); + + if ($id) { + $query = 'SELECT ordering AS value, name AS text' + . ' FROM #__menu' + . ' WHERE menutype = '.$db->Quote($row->menutype) + . ' AND parent = '.(int) $row->parent + . ' AND published != -2' + . ' ORDER BY ordering'; + $order = JHTML::_('list.genericordering', $query ); + $ordering = JHTML::_('select.genericlist', $order, 'ordering', 'class="inputbox" size="1"', 'value', 'text', intval( $row->ordering ) ); + } else { + $ordering = ''. JText::_( 'DESCNEWITEMSLAST' ); + } + return $ordering; + } + + /** + * Build the multiple select list for Menu Links/Pages + */ + public static function linkoptions($all = false, $unassigned = false) + { + $db =& JFactory::getDBO(); + + // get a list of the menu items + $query = 'SELECT m.id, m.parent, m.name, m.menutype' + . ' FROM #__menu AS m' + . ' WHERE m.published = 1' + . ' ORDER BY m.menutype, m.parent, m.ordering' + ; + $db->setQuery( $query ); + $mitems = $db->loadObjectList(); + $mitems_temp = $mitems; + + // establish the hierarchy of the menu + $children = array(); + // first pass - collect children + foreach ($mitems as $v) { + $id = $v->id; + $pt = $v->parent; + $list = @$children[$pt] ? $children[$pt] : array(); + array_push( $list, $v ); + $children[$pt] = $list; + } + // second pass - get an indent list of the items + $list = JHTMLMenu::TreeRecurse( intval( $mitems[0]->parent ), '', array(), $children, 9999, 0, 0 ); + + // Code that adds menu name to Display of Page(s) + $mitems_spacer = $mitems_temp[0]->menutype; + + $mitems = array(); + if ($all | $unassigned) { + $mitems[] = JHTML::_('select.option', '', JText::_( 'Menus' ) ); + + if ( $all ) { + $mitems[] = JHTML::_('select.option', 0, JText::_( 'All' ) ); + } + if ( $unassigned ) { + $mitems[] = JHTML::_('select.option', -1, JText::_( 'Unassigned' ) ); + } + + $mitems[] = JHTML::_('select.option', '' ); + } + + $lastMenuType = null; + $tmpMenuType = null; + foreach ($list as $list_a) { + if ($list_a->menutype != $lastMenuType) { + if ($tmpMenuType) { + $mitems[] = JHTML::_('select.option', '' ); + } + $mitems[] = JHTML::_('select.option', '', $list_a->menutype ); + $lastMenuType = $list_a->menutype; + $tmpMenuType = $list_a->menutype; + } + + $mitems[] = JHTML::_('select.option', $list_a->id, $list_a->treename ); + } + if ($lastMenuType !== null) { + $mitems[] = JHTML::_('select.option', '' ); + } + + return $mitems; + } + + public static function treerecurse( $id, $indent, $list, &$children, $maxlevel = 9999, $level = 0, $type = 1) + { + if (@$children[$id] && $level <= $maxlevel) { + foreach ($children[$id] as $v) { + $id = $v->id; + + if ($type) { + $pre = '|_ '; + $spacer = '.      '; + } else { + $pre = '- '; + $spacer = '  '; + } + + if ( $v->parent == 0 ) { + $txt = $v->name; + } else { + $txt = $pre.$v->name; + } + $pt = $v->parent; + $list[$id] = $v; + $list[$id]->treename = "$indent$txt"; + $list[$id]->children = count(@$children[$id]); + $list = JHTMLMenu::TreeRecurse($id, $indent.$spacer, $list, $children, $maxlevel, $level + 1, $type); + } + } + return $list; + } +} diff --git a/vendor/joomla/libraries/joomla/html/html/select.php b/vendor/joomla/libraries/joomla/html/html/select.php index 8ca1767e5..e29e419c8 100644 --- a/vendor/joomla/libraries/joomla/html/html/select.php +++ b/vendor/joomla/libraries/joomla/html/html/select.php @@ -1,275 +1,251 @@ $value_name = $value; - $obj->$text_name = trim( $text ) ? $text : $value; - $obj->disable = $disable; - return $obj; - } - - /** - * @param string The text for the option - * @param string The returned object property name for the value - * @param string The returned object property name for the text - * @return object - */ - function optgroup( $text, $value_name = 'value', $text_name = 'text' ) - { - $obj = new stdClass; - $obj->$value_name = ''; - $obj->$text_name = $text; - return $obj; - } - - /** - * Generates just the option tags for an HTML select list - * - * @param array An array of objects - * @param string The name of the object variable for the option value - * @param string The name of the object variable for the option text - * @param mixed The key that is selected (accepts an array or a string) - * @returns string HTML for the select list - */ - function options( $arr, $key = 'value', $text = 'text', $selected = null, $translate = false ) - { - $html = ''; - - foreach ($arr as $i => $option) - { - $element =& $arr[$i]; // since current doesn't return a reference, need to do this - - $isArray = is_array( $element ); - $extra = ''; - if ($isArray) - { - $k = $element[$key]; - $t = $element[$text]; - $id = ( isset( $element['id'] ) ? $element['id'] : null ); - if(isset($element['disable']) && $element['disable']) { - $extra .= ' disabled="disabled"'; - } - } - else - { - $k = $element->$key; - $t = $element->$text; - $id = ( isset( $element->id ) ? $element->id : null ); - if(isset( $element->disable ) && $element->disable) { - $extra .= ' disabled="disabled"'; - } - } - - // This is real dirty, open to suggestions, - // barring doing a propper object to handle it - if ($k === '') { - $html .= ''; - } else if ($k === '') { - $html .= ''; - } - else - { - //if no string after hypen - take hypen out - $splitText = explode( ' - ', $t, 2 ); - $t = $splitText[0]; - if(isset($splitText[1])){ $t .= ' - '. $splitText[1]; } - - //$extra = ''; - //$extra .= $id ? ' id="' . $arr[$i]->id . '"' : ''; - if (is_array( $selected )) - { - foreach ($selected as $val) - { - $k2 = is_object( $val ) ? $val->$key : $val; - if ($k == $k2) - { - $extra .= ' selected="selected"'; - break; - } - } - } else { - $extra .= ( (string)$k == (string)$selected ? ' selected="selected"' : '' ); - } - - //if flag translate text - if ($translate) { - $t = JText::_( $t ); - } - - // ensure ampersands are encoded - $k = JFilterOutput::ampReplace($k); - $t = JFilterOutput::ampReplace($t); - - $html .= ''; - } - } - - return $html; - } - - /** - * Generates an HTML select list - * - * @param array An array of objects - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the '; - $html .= JHTMLSelect::Options( $arr, $key, $text, $selected, $translate ); - $html .= ''; - - return $html; - } - - /** - * Generates a select list of integers - * - * @param int The start integer - * @param int The end integer - * @param int The increment - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the tag - * @param mixed The key that is selected - * @param string The name of the object variable for the option value - * @param string The name of the object variable for the option text - * @returns string HTML for the select list - */ - function radiolist( $arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = null, $idtag = false, $translate = false ) - { - reset( $arr ); - $html = ''; - - if (is_array($attribs)) { - $attribs = JArrayHelper::toString($attribs); - } - - $id_text = $name; - if ( $idtag ) { - $id_text = $idtag; - } - - for ($i=0, $n=count( $arr ); $i < $n; $i++ ) - { - $k = $arr[$i]->$key; - $t = $translate ? JText::_( $arr[$i]->$text ) : $arr[$i]->$text; - $id = ( isset($arr[$i]->id) ? @$arr[$i]->id : null); - - $extra = ''; - $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; - if (is_array( $selected )) - { - foreach ($selected as $val) - { - $k2 = is_object( $val ) ? $val->$key : $val; - if ($k == $k2) - { - $extra .= " selected=\"selected\""; - break; - } - } - } else { - $extra .= ((string)$k == (string)$selected ? " checked=\"checked\"" : ''); - } - $html .= "\n\t"; - $html .= "\n\t"; - } - $html .= "\n"; - return $html; - } - - /** - * Generates a yes/no radio list - * - * @param string The value of the HTML name attribute - * @param string Additional HTML attributes for the tag + * @param string The name of the object variable for the option value + * @param string The name of the object variable for the option text + * @param mixed The key that is selected (accepts an array or a string) + * @returns string HTML for the select list + */ + public static function genericlist($arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = NULL, $idtag = false, $translate = false) + { + if ( is_array( $arr ) ) { + reset( $arr ); + } + + if (is_array($attribs)) { + $attribs = JArrayHelper::toString($attribs); + } + + $id = $name; + + if ($idtag) { + $id = $idtag; + } + + $id = str_replace('[','',$id); + $id = str_replace(']','',$id); + + $html = ''; + + return $html; + } + + /** + * Generates a select list of integers + * + * @param int The start integer + * @param int The end integer + * @param int The increment + * @param string The value of the HTML name attribute + * @param string Additional HTML attributes for the tag + * @param mixed The key that is selected + * @param string The name of the object variable for the option value + * @param string The name of the object variable for the option text + * @returns string HTML for the select list + */ + public static function radiolist( $arr, $name, $attribs = null, $key = 'value', $text = 'text', $selected = null, $idtag = false, $translate = false ) + { + reset( $arr ); + $html = ''; + + if (is_array($attribs)) { + $attribs = JArrayHelper::toString($attribs); + } + + $id_text = $name; + if ($idtag) { + $id_text = $idtag; + } + + for ($i = 0, $n=count( $arr ); $i < $n; $i++) { + $k = $arr[$i]->$key; + $t = $translate ? JText::_( $arr[$i]->$text ) : $arr[$i]->$text; + $id = isset($arr[$i]->id) ? @$arr[$i]->id : null; + + $extra = ''; + $extra .= $id ? " id=\"" . $arr[$i]->id . "\"" : ''; + if (is_array($selected)) { + foreach ($selected as $val) { + $k2 = is_object( $val ) ? $val->$key : $val; + if ($k == $k2) { + $extra .= " selected=\"selected\""; + break; + } + } + } else { + $extra .= ((string)$k == (string)$selected ? " checked=\"checked\"" : ''); + } + $html .= "\n\t"; + $html .= "\n\t"; + } + $html .= "\n"; + return $html; + } + + /** + * Generates a yes/no radio list + * + * @param string The value of the HTML name attribute + * @param string Additional HTML attributes for the '; foreach ($this->_getEditors() as $editor) { if ($myEditor->_name == $editor->element) $output .= ''; - else - $output .= ''; - + else + $output .= ''; } $output .= '
'; - + return $output; } - - - - } diff --git a/vendor/mc/rt_missioncontrol_j15/lib/rtmcupdater.class.php b/vendor/mc/rt_missioncontrol_j15/lib/rtmcupdater.class.php index 1a93a37e6..2fb0a7585 100644 --- a/vendor/mc/rt_missioncontrol_j15/lib/rtmcupdater.class.php +++ b/vendor/mc/rt_missioncontrol_j15/lib/rtmcupdater.class.php @@ -16,7 +16,7 @@ function display($update=false) { // see if $mctrl has been initiated yet, if not do so if (!$mctrl) { require_once(JPATH_ADMINISTRATOR.'/templates/rt_missioncontrol_j15/lib/missioncontrol.class.php'); - $mctrl =& MissionControl::getInstance(); + $mctrl = MissionControl::getInstance(); } $output = ''; @@ -26,8 +26,6 @@ function display($update=false) { if (!$update) $mctrl->addScript('MC.Updater.js'); $params =& $mctrl->params; - - $updater = new RokUpdater(); $updater->init($mctrl->updateUrl, $mctrl->updateSlug, $params, $params->get('updater_dl_method'), $params->get('updater_extract_method')); @@ -44,18 +42,15 @@ function display($update=false) { //get status details $details = $updater->updateAvailable(); - $errors = ob_get_clean(); if ($details === false || $errors) { - $output .= '
'; - $output .= 'There was an error processing your request:'; - $output .= $errors; - $output .= '

Force Update

'; - $output .= '
'; - + $output .= '
'; + $output .= 'There was an error processing your request:'; + $output .= $errors; + $output .= '

Force Update

'; + $output .= '
'; } else { - if ($details->updates) { $output .= '
'; $output .= $update_info.$details->name.' '.$details->version.' is now available. '; @@ -69,12 +64,6 @@ function display($update=false) { $output .= '
'; } } - return $output; } - - - - - -} \ No newline at end of file +} diff --git a/vendor/mc/rt_missioncontrol_j15/lib/toolbar/button/link.php b/vendor/mc/rt_missioncontrol_j15/lib/toolbar/button/link.php index 04cd7e1bf..612c72c94 100644 --- a/vendor/mc/rt_missioncontrol_j15/lib/toolbar/button/link.php +++ b/vendor/mc/rt_missioncontrol_j15/lib/toolbar/button/link.php @@ -51,7 +51,7 @@ function fetchButton( $type='Link', $name = 'back', $text = '', $url = null ) * @return string Button CSS Id * @since 1.5 */ - function fetchId($name) + function fetchId($name = null) { return $this->_parent->_name.'-'.$name; } diff --git a/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/module.php b/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/module.php index b425b3e7d..82bb4f06b 100644 --- a/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/module.php +++ b/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/module.php @@ -48,7 +48,7 @@ function install() // Set the extensions name $name =& $this->manifest->getElementByPath('name'); - $name = JFilterInput::clean($name->data(), 'string'); + $name = JFilterInput::getInstance()->clean($name->data(), 'string'); $this->set('name', $name); // Get the component description diff --git a/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/template.php b/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/template.php index f76c271f5..df317768f 100644 --- a/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/template.php +++ b/vendor/mc/rt_missioncontrol_j15/lib/updater/libraries/installer/adapters/template.php @@ -62,7 +62,7 @@ function install() // Set the extensions name $name =& $root->getElementByPath('name'); - $name = JFilterInput::clean($name->data(), 'cmd'); + $name = JFilterInput::getInstance()->clean($name->data(), 'cmd'); $this->set('name', $name); // Set the template root path diff --git a/vendor/mc/rt_missioncontrol_j15/login.php b/vendor/mc/rt_missioncontrol_j15/login.php index 48fbb5d5e..da433e194 100644 --- a/vendor/mc/rt_missioncontrol_j15/login.php +++ b/vendor/mc/rt_missioncontrol_j15/login.php @@ -12,7 +12,7 @@ require_once('lib/missioncontrol.class.php'); global $mctrl; -$mctrl =& MissionControl::getInstance(); +$mctrl = MissionControl::getInstance(); $mctrl->storeRedirect(); $mctrl->addStyle("core.css");